Remove CSS editor on Preview page in OEN workflow for all users except admins and Global Production Editors
Desired behaviour
Users in the OEN instance should not be able to modify existing templates or create new templates. We already somewhat covered this in #465 (closed) for the templates page, but we also need to cover that for the preview page.
Current behaviour
You can edit template CSS from the book preview, but those changes don't reflect until you save, and when you save it you need to choose to either modify the existing template (which you are the not the creator or owner of) or create a new template (which will then be available to everyone else, and it hasn't been tested thoroughly or approved more broadly so might cause other users to experience issues).
Instead of removing or changing the save modal, we should remove the CSS editor on the left entirely, along with its control buttons, because this panel is useless without supporting modifications to and creation of templates, which both introduce problems as described above.
Another benefit of removing the CSS editor (besides for avoiding the above problems around saving) is that we have more space to see the preview for double page spreads.
Note that admins and Global Production Editors should still be able to see the CSS editor and its controls on previews.
Steps to reproduce
- Go to any book in the OEN instance
- Choose Export book
- Select the preview option (it should be selected by default) and pick a template
- Edit the template CSS and press Save.
- See that you can modify the existing template (which you are the not the creator or owner of) or create a new template.
- See that without saving changes to the CSS panel, your changes don't show on the preview.
- See that using a template with a double page spread layout (for example Apollo), you can't see the full page spread without scrolling horizontally.
Environment
Possible solution
- add isGlobal after this line https://gitlab.coko.foundation/ketida/server/-/blob/main/api/graphql/user/user.graphql#L2
- implement isGlobal here https://gitlab.coko.foundation/ketida/server/-/blob/main/controllers/user.controller.js#L17 (as role you should use the global roles provided here, excluding the
admin
role, https://gitlab.coko.foundation/ketida/server/-/blob/main/config/default.js#L94) - use the above as a custom field resolver here https://gitlab.coko.foundation/ketida/server/-/blob/main/api/graphql/user/user.resolvers.js#L25
- add isGlobal field request below this line https://gitlab.coko.foundation/ketida/vanilla-client/-/blob/main/app/components/navigation/src/queries/currentUser.js#L12
- make modifications https://gitlab.coko.foundation/ketida/vanilla-client/-/blob/main/app/components/navigation/src/Navigation.js#L20 in order for the case of
oen
to check if a user is either admin or global - inject current user here https://gitlab.coko.foundation/ketida/vanilla-client/-/blob/main/app/components/bookbuilder/src/PagedStyler/ConnectedPagedStyler.js#L126 and pass it down (e.g. https://gitlab.coko.foundation/ketida/vanilla-client/-/blob/main/app/components/navigation/src/Navigation.js#L20)
- make modification here https://gitlab.coko.foundation/ketida/vanilla-client/-/blob/main/app/components/bookbuilder/src/PagedStyler/PagedStyler.js in order for only admins or global users to be able to see the left panel area. All the other users should be able to just see the preview.