[WIP] Backbonize FileList#25909
Conversation
|
FileInfoModel is the base. From here one can either call Goal is to try to move as much logic as possible to the models or collection like sorting and file actions. |
|
Backbone models should have an id. In theory the real ID is actually the Webdav HREF, not the file's file id (which we can store in a separate property). Path and name can be derived from the href. |
ecab1b1 to
0b1be11
Compare
|
Finally, that's some proper backbone here !
|
|
there's still a lot of work to be done, I'll likely move all the filesClient actions directly to the model. Goal is that anyone with access to the collection/model (sidebar, alternate view) can still perform actions on file/folders without any direct connection to the list |
cd32319 to
0d3b73d
Compare
|
Just made more progression, now the following operations are moved to the model
The remaining ones:
Once this is done the FileList doesn't need to know anything about FilesClient any more and can receive the model/collection injected from the outside ! Some challenges:
|
0d3b73d to
ce03d8c
Compare
|
|
|
hmm, I realize that we need the concept of "file action class" (command pattern) because we want file actions to be undoable but also resumable in a modified state. The resumable case is for example when moving/copying a file and the conflict dialog pops up. |
|
file action command pattern concept ideas: #26296 |
|
@mjobst-necls since you already got to know a lot of the mess that is the FileList code, I'd appreciate if you could give me some feedback on this PR 😄 |
|
To summarize quickly: the goal is to move the file action logic to the backbone models and collections. Then the views (FileList needs to become one and MainFileInfoView is one too) only listen to model/collection changes to adjust themselves accordingly. |
|
... and additionally the Views also gain the ability to execute file actions directly on the models like refetching properties, renaming, etc. |
Based on davSync
Now file-upload.js only uses the model and doesn't necessarily requires the list view
No need to manually update every time
Like _.trim() and all which would be very useful
Improve model's fetch to do a PROPFIND and parse the response properly
ce03d8c to
955531f
Compare
|
Rebased. Make sure to rerun |
|
Well, guys. I'm currently working on a Diagram to get a better overview of the javascript code. Here is a link, if someone is interested: The model is not correct at all and not complete, but it supports understanding pretty much, I think. |
|
While adding the all the functions to the OCA.Files.FileList, I saw a lot of function that are marked as deprecated. How long do these function have to exist? If they have to be existing for longer term, they could at least be moved to a separate file like 'filelist.deprecated.js' to make the filelist.js more clear. What do you think? |
|
The coupling of the main JS-objects is very high. The collection attribute of OCA.Files.FileList is only dependent on the model. We should remove that attribute and get the collection out of the model. The new button should be a separate object of type OCA.Files.NewFileButton. The following functions/attributes can be moved to this type:
The sort functionality should be a part of the OCA.Files.FileInfoCollection or even better capsulated in a new class like OCA.Files.FileSort. The following function/attributes could be moved:
The class OCA.Files.FileList contains properties like breadcrumb, newbutton, _selectedCollection, _selectionSummary, _lastChecked, _dragOptions, _folderDropOptions, _uploader that are not used by OCA.Files.FavoriteFileList, OCA.Sharing.FileList, and OCA.Trashbin.FileList. We could create a new OCA.Files.FileListBase that only provides general behavior. Because the OCA.Files.FileList is a view, it should not have a filesClient attribute, but be able to create a new instance. The filesClient is used in OCA.Files.FileList with its functions
I propose that we keep the OC.Files.Client class and also add a function for ajax api calls. The client can thereby act as a proxy object, and inside the client we can decide whether we use own written requests or use the backbone webdav dav/sync.
Using the webdav href property in the js would probably not make sense, because we don't have this information in the share views. There will not be a need to identify a model system wide, but client wide. We just need an identifier to able to get the correct model from the collection. I think the fileid is an appropriate value. |
|
@PVince81: I'm looking forward to your comments. |
Indeed. In this iteration the goal is to separate the model/collection from the FileList view better.
If possible I'd kill them as soon as possible. Currently I'm not sure yet how many other bundled apps are using them so I left them. But we can aim to remove them within this PR before merging.
Sounds good.
Indeed, it shouldl get its separate view. This is even something that could be done first in a separate PR as it doesn't affect the file list directly.
Yeah, ideal would be to move a lot to the outside and only losely link them together through events.
Ideally I'd remove filesClient completely from the FileList and only have it inside the models where all the server requests are supposed to take place. And since the model/collection gets injected from the outside eventually, the FilesClient would then be instantiated outside of FileList too.
Part of collection sounds good.
Yes, collection.createDirectory().
This is the part where I struggle a bit. In the past it was the FileList that specified which properties it required, and that one got extended by plugins like tagsplugins. But now in this PR I'd like to move the PROPFIND to the model's fetch. It is currently possible to call
Not sure if a proxy object would be useful here. We already have backbone Webdav sync which is more an adapter than a proxy. It's just that Files Client is a more functional way of requesting properties while backbone is more object oriented.
Indeed, that's a good argument. Thanks. @mjobst-necls thanks a lot for your feedback and interest 😄 |
|
If we can solve the remaining todos from #25909 (comment) and if everything still works including the sub-class lists, then we could in theory merge this already. One challenge as said before is that currently the "webdav properties selection through plugins" is broken, so some information is missing.
|
|
Will likely require #26842 to be able to use MKCOL from the directory model to create new directories. |
|
or maybe we just redesign and rewrite the whole files app from scratch instead of doing gymnastics with the old code... |
|
this won't work out, the current code is too messy to be able to iteratively improve it. also I'm having doubts whether Backbone is the right solution here. there's a mock up with Vue JS here which might be more suited once we wire it up: https://central.owncloud.org/t/gsoc18-project-proposal-new-files-app-written-in-vue-js/11569 |
No description provided.