xod
xod copied to clipboard
As enterprise admin I want to disable some features via IDE config
Rationale
At the moment, we have all menu items, buttons and other user interface components hard-coded in xod-client, xod-client-browser, and xod-client-electron without grouping by feature name. We want to add the possibility to disable some features, which means that disabled feature hides related menu items and components.
User story
To disable features I need to edit config.json in the xod-client package (or dist/config.json).
For example, I want to hide the whole Deploy menu item with all children elements and buttons in the UI, also I want to disable a possibility to change a workspace and add a library:
{
"disableFeatures": ["deploy", "switchWorkspace", "addLibrary"]
}
Here is a list of features, that can be disabled within this issue:
switchWorkspaceaddLibarypublishLibrarygetApiTokento hide a components in Project Preferences to specify a token for XOD Cloud APIaccountPaneto hide account pane, switch visibility button andView > Toggle Acount Panemenu itemhelp- for anything that relates to Help menu:versionopenTutorialProjectdocumentationshortcutsDocforum
deploy- for anything that relates to deploy:uploadToArduinorunSimulationshowCodeForArduinoconnectSerialupdatePackages
In case that all features listed in a menu item are disabled, the whole parent menu item should be hidden. But it should not affect other features with the parent menu item feature name.
Acceptance criteria
- [ ] properties in config file effects to menu items and UI components visibility
- [ ] config file is a separate chunk (does not included in the
bundle.js) - [ ] after hiding some menu items there should be no more than one separator in a row
- [ ] if all features in a menu are hidden (without grouping), the parent menu item should be hidden too. But it should not affect other components, which relates to the feature name of the parent menu item.
How to implement
- Place a
config.jsonin a separate Webpack chunk - Add
featureName: [FeatureName]property to each menu item - Import config where it needed (E.G.,
xod-client/src/utils/menu.js) - Introduce a new filtering function in
xod-client/src/utils/menu.js, which will reject menu items (pay attention, menu items are nested) if at least one feature from the list mentioned above is disabled. - Use this function in each
getMenuBarItemsmethod ofAppcontainer inxod-client-browserandxod-client-electronto avoid rendering hidden menu items (even it defined in this method, like Help -> Version) - In addition, filter out separators from menus, which placed in the beginning, in the end, or more than one in a row.
- Wrap some React components with HOC
Feature :: [FeatureName] -> Component -> Component, which avoids rendering it if the at least one feature from the list is disabled
How to test
Mock the imported config.json with test config that hides some menu items and check does it exists on the page using puppeteer.
To mock the import, we probably need to install one new dev dependency, like testdouble.js.
For the electron version, probably we need to do something like suggested in this comment: https://github.com/electron-userland/spectron/issues/21#issuecomment-373982282
Please, elaborate on User Story. An example of config.json to hide, say, “Upload to Arduino” and “Update packages” is much desired.
Also, keep Grammarly enabled
Now, the scope of the feature should be defined. It would be quite pointless to hide Edit → Copy, for example. From the input info and some thoughts, the following is the subject to be hidden:
- File → Switch Workspace
- File → Add Library / Publish Library
- Deploy →
<every item> - Help → Open Tutorial Project
- Help → Documentation
- Help → Forum
Please, give these action consistent names and add to the issue body.