xod icon indicating copy to clipboard operation
xod copied to clipboard

As enterprise admin I want to disable some features via IDE config

Open brusherru opened this issue 5 years ago • 2 comments

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:

  • switchWorkspace
  • addLibary
  • publishLibrary
  • getApiToken to hide a components in Project Preferences to specify a token for XOD Cloud API
  • accountPane to hide account pane, switch visibility button and View > Toggle Acount Pane menu item
  • help - for anything that relates to Help menu:
    • version
    • openTutorialProject
    • documentation
    • shortcutsDoc
    • forum
  • deploy - for anything that relates to deploy:
    • uploadToArduino
    • runSimulation
    • showCodeForArduino
    • connectSerial
    • updatePackages

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

  1. Place a config.json in a separate Webpack chunk
  2. Add featureName: [FeatureName] property to each menu item
  3. Import config where it needed (E.G., xod-client/src/utils/menu.js)
  4. 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.
  5. Use this function in each getMenuBarItems method of App container in xod-client-browser and xod-client-electron to avoid rendering hidden menu items (even it defined in this method, like Help -> Version)
  6. In addition, filter out separators from menus, which placed in the beginning, in the end, or more than one in a row.
  7. 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

brusherru avatar Aug 10 '20 16:08 brusherru

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

nkrkv avatar Aug 11 '20 08:08 nkrkv

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.

nkrkv avatar Aug 12 '20 10:08 nkrkv