pentaho-kettle
pentaho-kettle copied to clipboard
Turn menu items on/off at run-time
Requested by a user company, menu items such as File > Save as... should be customizable. "Customizable" means each one of the items can be turned on/off individually at run-time by e.g., a config file.
Example config file:
<menu id="file">
<menuitem id="file-save-as" disabled="true" />
</menu>
Good idea! I think it will be better to make it based on user's roles and rights. For example, integrate with Spring Security.
That's an even better idea!
I'm not sure, but it would be an good idea to be able to turn them on/off in ui/menubar.xul
like
<menuitem id="file-save-as" label="${Spoon.Menu.File.SaveAs}" command="spoon.saveFileAs()" disabled="spoon.checkMenuPermission(\"file-save-as\")" />
Then spoon.checkMenuPermission(String id)
will check if the menu item should be disabled based on user's roles.
I found that even as of today menu items can be hidden by commenting out (or completely deleting) the corresponding XML element in ui/menubar.xul
.
For example, commenting out file-save-as-vfs
<menu id="file">
...
<!--<menuitem id="file-save-as-vfs" label="${Spoon.Menu.File.SaveAsVFS}" command="spoon.saveXMLFileToVfs()" />-->
...
</menu>
will give you a menu without the commented menuitem as below.
Update1: Commenting-out is not recommended because you'll get the following non-fatal error message.
2018/03/01 11:35:46 - Spoon - ERROR (version 8.0.0.0-28-14, build 8.0.0.0-28-14 from 2018-02-07 10.44.25 by jenkins) : Non-Fatal error : Menu Item with id = file-save-as-vfs does not exist! Check 'menubar.xul'
4d54235c60d9c21c89c0175be16f084aa2c58ceb supports attribute "disabled" to turn menuitems on/off.
The following ui/menubar.xul
<menu id="file">
...
<menuitem id="file-save-as" label="${Spoon.Menu.File.SaveAs}" command="spoon.saveFileAs()" disabled="true" />
<!--<menuitem id="file-save-as-vfs" label="${Spoon.Menu.File.SaveAsVFS}" command="spoon.saveXMLFileToVfs()" />-->
...
</menu>
will disable file-save-as
and hide file-save-as-vfs
.
Although Pentaho's XUL extends Mozilla's XUL (see here for details), it does not seem to support enable/disable items based on role/user. The XUL spec should be further extended to support it, which would need more holistic design hence more time. Thoughts, design/code contributions will be welcome.
Requested by a user company, menu items such as File > Save as... should be customizable. "Customizable" means each one of the items can be turned on/off individually at run-time by e.g., a config file.
Example config file:
<menu id="file"> <menuitem id="file-save-as" disabled="true" /> </menu>
is there any way to hidden or remove menubar ?
Currently, it is not possible to hide the entire menubar (File, Edit, View, Action, etc.). Can you tell us why you want to hide it?
I want to embed webspoon in a iframe. It satisfies the needs without menubar,and what's more, the whole page layout looks better.