-
-
Notifications
You must be signed in to change notification settings - Fork 13
Added support for middleware in edit menu #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think it would be useful to have async function support here! Ex: |
|
There are two problems: First, the The second problem is that it doesn't support adding an item in a place other than the end of menu items (which is not very important for me). |
|
To make it async, just place an osjs-filemanager-application/index.js Line 577 in d5319ee
Then osjs-filemanager-application/index.js Line 580 in d5319ee
And finally osjs-filemanager-application/index.js Line 479 in d5319ee
|
|
Thanks for your help 😁 To make it possible for any application to add multiple items we need to assume that they will return an array, so |
|
No problem!
Ah, yeah. These callbacks should probably only be able to return arrays. To flatten it out simply do the following (as I'm not sure if the current babel setup does polyfills of const promises = editMenuMiddlewares
.map(fn => fn({file: item, menuItems: items, isContextMenu}))
const appendItems = await Promise.all(promises)
const menuItems = [...editMenuItems, ...([].concat(...appendItems))] |
|
Maybe also sanitize it :) |
|
Do you mean |
|
Ops. Yeah, filter 😊 |
|
You have confirmed that the latest changes and everything works with this ? 🤓 |
|
Now it's working 😁 I'd missed an |
|
Sweet! Then I'll merge and release this one as well :) |
|
Again, thank you very much for this! |
|
I really enjoyed it, thank you too 😊 |
It adds support for the dynamic edit menu in the application. Any other application can now use the
osjs/filemanager:contextmenu:editmiddleware group to change context/edit menu.Here is an example of how an application can use this feature:
middleware.jsfile at the root of your application.middleware.jsas a separate entry.{ "filename": "middleware.js", "type": "background" }to thefilesproperty in the metadata config.middleware.jsfile:Closes os-js/OS.js#752.