Allow removal and adding for plugins in iconMenu - #861
Conversation
|
a353df3 to
6a19ea0
Compare
As decided in a not-yet-published architectural decision, we usually do not want to use watchers, but explicit mutations instead :-(
As decided in a not-yet-published architectural decision, we usually do not want to use watchers, but explicit mutations instead :-(
There was a problem hiding this comment.
These functions are not in use. Please remove them.
| if (open.value === props.id) { | ||
| open.value = null | ||
| useCoreStore().setMoveHandle(null) | ||
| iconMenuStore.openMenuById(null) | ||
| } else { | ||
| open.value = props.id | ||
| iconMenuStore.openInMoveHandle(props.id) | ||
| iconMenuStore.openMenuById(props.id) | ||
| } |
There was a problem hiding this comment.
Might as well just call iconMenuStore.openMenuById(open.value === props.id ? null : props.id)
| if (open.value === id) { | ||
| open.value = null | ||
| coreStore.setMoveHandle(null) | ||
| iconMenuStore.openMenuById(null) | ||
| } else { | ||
| open.value = id | ||
| iconMenuStore.openInMoveHandle(id) | ||
| iconMenuStore.openMenuById(id) | ||
| } |
There was a problem hiding this comment.
Might as well just call iconMenuStore.openMenuById(open.value === id ? null : id)
| * | ||
| * To change the open menu, use {@link openMenuById}. | ||
| * | ||
| * @readonly |
There was a problem hiding this comment.
| * @readonly | |
| * @readonly | |
| * @alpha |
| * | ||
| * To change the open focus menu, use {@link openFocusMenuById}. | ||
| * | ||
| * @readonly |
There was a problem hiding this comment.
| * @readonly | |
| * @readonly | |
| * @alpha |
| /** | ||
| * Appends a group of plugins to the icon menu. | ||
| * | ||
| * @param menu - The menu item group to add. |
There was a problem hiding this comment.
| * @param menu - The menu item group to add. | |
| * @param menu - The menu item group to add. | |
| * @alpha |
| /** | ||
| * Appends a plugin to the icon menu as a focus menu. | ||
| * | ||
| * @param menu - The focus menu item to add. |
There was a problem hiding this comment.
| * @param menu - The focus menu item to add. | |
| * @param menu - The focus menu item to add. | |
| * @alpha |
| /** | ||
| * Removes a plugin from the icon menu. | ||
| * | ||
| * @param pluginId - The ID of the plugin to remove. |
There was a problem hiding this comment.
| * @param pluginId - The ID of the plugin to remove. | |
| * @param pluginId - The ID of the plugin to remove. | |
| * @alpha |
| ) | ||
| filteredMenuGroup.forEach(({ plugin }) => { | ||
| if (plugin.component) { | ||
| markRaw(plugin.component) |
There was a problem hiding this comment.
It was previously more defensive with an additional toRaw. I feel like this should be readded here and in addFocusPlugin
| function isPluginInIconMenu(pluginId: string) { | ||
| const display = coreStore.configuration[pluginId]?.displayComponent | ||
| return typeof display === 'boolean' ? display : true | ||
| } |
There was a problem hiding this comment.
This is not related to the intention of this PR thus 🎩, but I realized that this never did anything if the configuration was directly added to the plugin. If you see a quick solution, add it here, otherwise, I'll make a note for myself.

Summary
Plugins in iconMenu can be added and removed at runtime.
Note:
coreStore.removePlugin(...)is still not supported for plugins within iconMenu. I deem this correct. As iconMenu adds the plugin, it should also be responsible for removal of the plugin. Otherwise, we'd need to breach the separation of core and plugins.Instructions for local reproduction and review
Relevant tickets, issues, et cetera
Fixes #668