From 7216a99f5344a6135a1b7987536cfcda7000da66 Mon Sep 17 00:00:00 2001 From: Albert <31214345+alozano3@users.noreply.github.com> Date: Wed, 17 Mar 2021 20:04:00 +0100 Subject: [PATCH] feat(connect): fix connect update permissions (#620) Co-authored-by: alozano3 --- .../ConnectConfigs/ConnectConfigs.jsx | 32 +++++++++++-------- .../Connect/ConnectList/ConnectList.jsx | 2 +- client/src/utils/Routes.js | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/client/src/containers/Connect/ConnectDetail/ConnectConfigs/ConnectConfigs.jsx b/client/src/containers/Connect/ConnectDetail/ConnectConfigs/ConnectConfigs.jsx index 30eb204a6..61355c38b 100644 --- a/client/src/containers/Connect/ConnectDetail/ConnectConfigs/ConnectConfigs.jsx +++ b/client/src/containers/Connect/ConnectDetail/ConnectConfigs/ConnectConfigs.jsx @@ -27,7 +27,8 @@ class ConnectConfigs extends Form { plugin: {}, config: {}, selectedType: '', - display: '' + display: '', + roles: JSON.parse(sessionStorage.getItem('roles')) }; schema = {}; @@ -138,6 +139,7 @@ class ConnectConfigs extends Form { let title = ''; let { formData } = this.state; const errors = []; + const roles = this.state.roles || {}; const errorMessage = this.validateProperty({ name: plugin.name, value: formData[plugin.name] }); if (errorMessage) { errors[plugin.name] = errorMessage; @@ -199,7 +201,7 @@ class ConnectConfigs extends Form { className="form-control" value={formData[plugin.name]} name={plugin.name} - disabled={plugin.name === 'name' || plugin.name === 'connector.class'} + disabled={plugin.name === 'name' || plugin.name === 'connector.class' || !(roles.connect && roles.connect['connect/update']) } placeholder={plugin.defaultValue > 0 ? plugin.defaultValue : ''} onChange={({ currentTarget: input }) => { let { formData } = this.state; @@ -260,6 +262,7 @@ class ConnectConfigs extends Form { group.forEach(element => { const rows = this.renderTableRows(element); const errors = []; + const roles = this.state.roles || {}; groupDisplay.push({rows}); if (element.name === 'transforms') { @@ -304,6 +307,7 @@ class ConnectConfigs extends Form { this.setState({ formData }); }} name="UNIQUE_ID_OF_DIV" + readOnly={!(roles.connect && roles.connect['connect/update'])} editorProps={{ $blockScrolling: true }} style={{ width: '100%', minHeight: '25vh' }} /> @@ -368,7 +372,7 @@ class ConnectConfigs extends Form { render() { const { plugin, display } = this.state; const { name } = this.state.formData; - + const roles = this.state.roles || {}; return (
{display}
-
- -
+ {roles.connect && roles.connect['connect/update'] && ( +
+ +
+ )} )} diff --git a/client/src/containers/Connect/ConnectList/ConnectList.jsx b/client/src/containers/Connect/ConnectList/ConnectList.jsx index c24321176..45c5f0b45 100644 --- a/client/src/containers/Connect/ConnectList/ConnectList.jsx +++ b/client/src/containers/Connect/ConnectList/ConnectList.jsx @@ -111,7 +111,7 @@ class ConnectList extends Root { const roles = this.state.roles || {}; let actions = []; - if (roles.connect && roles.connect['connect/update']) { + if (roles.connect && roles.connect['connect/read']) { actions.push(constants.TABLE_DETAILS); } if (roles.connect && roles.connect['connect/delete']) { diff --git a/client/src/utils/Routes.js b/client/src/utils/Routes.js index da6dc77f9..65132e046 100644 --- a/client/src/utils/Routes.js +++ b/client/src/utils/Routes.js @@ -240,7 +240,7 @@ class Routes extends Root { {roles && roles.connect && roles.connect['connect/read'] && ( )} - {roles && roles.connect && roles.connect['connect/update'] && ( + {roles && roles.connect && roles.connect['connect/read'] && (