From a940e9a8a740735ff63b3034b460b0371efbcd8b Mon Sep 17 00:00:00 2001 From: kyle-ssg Date: Tue, 12 Nov 2024 14:33:52 +0000 Subject: [PATCH] Better permissions view for create feature --- frontend/web/components/modals/CreateFlag.js | 333 +++++++++---------- 1 file changed, 166 insertions(+), 167 deletions(-) diff --git a/frontend/web/components/modals/CreateFlag.js b/frontend/web/components/modals/CreateFlag.js index dc2dd0913b29..4e555a938b5f 100644 --- a/frontend/web/components/modals/CreateFlag.js +++ b/frontend/web/components/modals/CreateFlag.js @@ -575,151 +575,161 @@ const CreateFlag = class extends Component { } catch (e) { regexValid = false } - const Settings = (projectAdmin, createFeature, featureContentType) => ( - <> - {!identity && this.state.tags && ( + const Settings = (projectAdmin, createFeature, featureContentType) => + !createFeature ? ( + +
+ + ) : ( + <> + {!identity && this.state.tags && ( + + + this.setState({ settingsChanged: true, tags }) + } + /> + } + /> + + )} + {metadataEnable && featureContentType?.id && ( + <> + + { + this.setState({ + hasMetadataRequired: b, + }) + }} + onChange={(m) => { + this.setState({ + metadata: m, + }) + }} + /> + + )} + {!identity && projectFlag && ( + + {({ permission }) => + permission && ( + <> + + + + + + + + + ) + } + + )} - this.setState({ settingsChanged: true, tags }) - } - /> - } - /> - - )} - {metadataEnable && featureContentType?.id && ( - <> - - { - this.setState({ - hasMetadataRequired: b, - }) + value={description} + data-test='featureDesc' + inputProps={{ + className: 'full-width', + name: 'featureDesc', }} - onChange={(m) => { + onChange={(e) => this.setState({ - metadata: m, + description: Utils.safeParseEventValue(e), + settingsChanged: true, }) - }} + } + ds + type='text' + title={identity ? 'Description' : 'Description (optional)'} + placeholder="e.g. 'This determines what size the header is' " /> - - )} - {!identity && projectFlag && ( - - {({ permission }) => - permission && ( - <> - - - - - - - - - ) - } - - )} - - - this.setState({ - description: Utils.safeParseEventValue(e), - settingsChanged: true, - }) - } - ds - type='text' - title={identity ? 'Description' : 'Description (optional)'} - placeholder="e.g. 'This determines what size the header is' " - /> - - - {!identity && ( - - - - this.setState({ is_server_key_only, settingsChanged: true }) - } - className='ml-0' - /> - - Server-side only - - } - > - Prevent this feature from being accessed with client-side SDKs. - - - )} - {!identity && isEdit && ( - - - { - this.setState({ is_archived, settingsChanged: true }) - }} - className='ml-0' - /> - - Archived - - } - > - {`Archiving a flag allows you to filter out flags from the + {!identity && ( + + + + this.setState({ is_server_key_only, settingsChanged: true }) + } + className='ml-0' + /> + + Server-side only + + } + > + Prevent this feature from being accessed with client-side + SDKs. + + + + )} + + {!identity && isEdit && ( + + + { + this.setState({ is_archived, settingsChanged: true }) + }} + className='ml-0' + /> + + Archived + + } + > + {`Archiving a flag allows you to filter out flags from the Flagsmith dashboard that are no longer relevant.
An archived flag will still return as normal in all SDK endpoints.`} -
-
-
- )} - - ) +
+
+
+ )} + + ) const Value = (error, projectAdmin, createFeature, hideValue) => { const { featureError, featureWarning } = this.parseError(error) @@ -1865,7 +1875,7 @@ const CreateFlag = class extends Component { /> )} - {!existingChangeRequest && createFeature && ( + {!existingChangeRequest && ( {isEdit && (
- {createFeature ? ( -

- This will save the above settings{' '} - all environments. -

- ) : ( -

- To edit this feature's settings, you - will need{' '} - - Project Administrator permissions - - . Please contact your project - administrator. -

+ {!!createFeature && ( + <> +

+ This will save the above settings{' '} + all environments. +

+ + )} - - {createFeature ? ( - - ) : null}
)}