Repository navigation
Sidebar file actions - #18178
Sidebar file actions#18178
Conversation
|
another challenge:
A clean way for that is listening to changes on the file model. |
|
|
Basically the tough part is to be able to have a shared FileInfoModel instance that is accessible both by the FileList and also by the DetailsView. Since refactoring the FileList to use Backbone collections is out of scope, I'd need to introduce a method Complex stuff... navigating through spaghetti legacy code without breaking any existing APIs... |
|
Ah yes, and the problem with |
|
Raised #18211 to port the FileList and its arrays to backbone. I realize that the most problematic is the FileActions class for which I'm trying to keep the API stable, which makes it more difficult to modify event handlers to also pass models. I am still not clear whether we should call FileActions.triggerAction(fileInfoModel) or the reverse FileInfoModel.triggerAction() combined with FileInfoModel.setFileActions(fileActions) (to have access to the action list). The latter makes it possible to pass a single model everywhere and trigger actions on it. The drawback is that we need to inject the FileActions object into it. So now I'm still trying to think of a good code design for this. |
|
Decoupling FileActions from the file list and DOM is close to impossible as it requires rewriting every action handler. And some action handlers are registered by third party apps. So, regardless of the clean solution, we still need to provide a fallback for the legacy action handlers. I'd still like to decouple FileActions.display() from the file list, because at the time we render the actions we don't have a model for the row, so we can't bind the model to the action handler. But also, binding the model/context to the action handler is a bad approach because it means every file row will have several closures. The best is if the FileList would trigger the action on click and then pass the matching row + model + context to the action handler instead of having the FileActions do it through the closure. |
|
Well, or we make the filelist work with backbone collections #18211, this way we'd already have a model for each row so we could just pass it along in the But there is still the problem of invoking file actions outside of the file list like in the sidebar. I don't want the sidebar to know anything about the |
|
Arghh, now I realize that since we want the thumbnail to trigger a default action, it means the action handler for that must also support working with file models instead of the file list object. This will be impossible. Seems like for now there is no way around, we need to pass the FileList and FileActions objects to DetailsView, or embed them into the FileInfoModel, which is super-ugly... |
|
Raised #18230 to redesign FileActions. I give up for now and will pass the FileList object to the sidebar, which will make the sidebar less portable. This problem will need to be addressed before the sidebar moves to the core API. |
|
Let's focus on the short term now: inject the filelist in the sidebar components. |
FileInfoModel is a backbone model that will make it possible to track changes and update views accordingly
The favorite icon in the sidebar now triggers the file action and also updates itself according to the model's state when triggered from the file row. The thumbnail triggers the default action. Currently only one FileInfoModel is used for the selection and state synchronization between views. FileList reload now auto-closes the sidebar.
b1e8ecc to
c964eff
Compare
|
A new inspection was created. |
|
The solution was actually to pass FileList and FileActions to the MainFileInfoDetailsView before it gets registered into the sidebar. This only couples that panel with the filelist, not the whole sidebar. This PR is ready for review:
Please review @blizzz @jancborchardt @rullzer |
|
Tested and works 👍 code looks good |
|
Needs a second review. This is blocking other tasks. |
|
Nice, everything works! 👍 |
|
Thanks 😄 |

Fix for #18169
It doesn't work yet. The file actions are requiring too much context.
But I'll explore another interesting idea: DetailsViewModel. That one could contain all the required information like FileInfo, FileActions and FileList. (even though I'd eventually like the DetailsView to be able to work without knowing anything about the list)
CC @blizzz