pentaho-kettle icon indicating copy to clipboard operation
pentaho-kettle copied to clipboard

Turn menu items on/off at run-time

Open HiromuHota opened this issue 7 years ago • 8 comments

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.

screen shot 2018-02-09 at 10 16 02 am

Example config file:

<menu id="file">
  <menuitem id="file-save-as" disabled="true" />
</menu>

HiromuHota avatar Feb 09 '18 18:02 HiromuHota

Good idea! I think it will be better to make it based on user's roles and rights. For example, integrate with Spring Security.

delfer avatar Feb 09 '18 20:02 delfer

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.

HiromuHota avatar Feb 09 '18 21:02 HiromuHota

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.

screen shot 2018-03-01 at 1 17 27 pm

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'

HiromuHota avatar Mar 01 '18 18:03 HiromuHota

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. screen shot 2018-03-01 at 11 35 53 am

HiromuHota avatar Mar 01 '18 19:03 HiromuHota

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.

HiromuHota avatar Mar 01 '18 19:03 HiromuHota

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.

screen shot 2018-02-09 at 10 16 02 am

Example config file:

<menu id="file">
  <menuitem id="file-save-as" disabled="true" />
</menu>

is there any way to hidden or remove menubar ?

yuanxuzhang avatar Sep 16 '19 07:09 yuanxuzhang

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?

HiromuHota avatar Sep 16 '19 16:09 HiromuHota

I want to embed webspoon in a iframe. It satisfies the needs without menubar,and what's more, the whole page layout looks better.

yuanxuzhang avatar Sep 17 '19 00:09 yuanxuzhang