Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks
brusherru opened this issue Aug 10, 2020 · 2 comments
Open
4 tasks

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

brusherru opened this issue Aug 10, 2020 · 2 comments

Comments

@brusherru
Copy link
Contributor

brusherru commented Aug 10, 2020

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: electron-userland/spectron#21 (comment)

@nkrkv
Copy link
Member

nkrkv commented Aug 11, 2020

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 nkrkv changed the title As Enterprise Customer I want to hide some menu items and buttons based on config As enterprise admin I want to hide some menu items and buttons based on config Aug 11, 2020
@nkrkv
Copy link
Member

nkrkv commented Aug 12, 2020

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.

@brusherru brusherru changed the title As enterprise admin I want to hide some menu items and buttons based on config As enterprise admin I want to disable some features via IDE config Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants