-
Notifications
You must be signed in to change notification settings - Fork 429
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
fix: Metadata UI improvements #4327
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5afb4a7
fix: metadata UI improvements
novakzaballa d49bb9e
Add textArea for multiline metadata type
novakzaballa 2db3272
Add error toast in the environment settings
novakzaballa 6c18b75
Update url type validation
novakzaballa 6a9759e
Add error toasts, update input components
novakzaballa c9c7645
Merge branch 'main' into fix/metadata-ui-improvements
novakzaballa 1d9f0de
Rename placeholder
novakzaballa 9049a65
Only entterprise org can use custom fields/metadata
novakzaballa 6c6d355
Improve code
novakzaballa bfb8616
Improve UI
novakzaballa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ import { getSupportedContentType } from 'common/services/useSupportedContentType | |
import { getGithubIntegration } from 'common/services/useGithubIntegration' | ||
import { removeUserOverride } from 'components/RemoveUserOverride' | ||
import ExternalResourcesLinkTab from 'components/ExternalResourcesLinkTab' | ||
import MetadataTitle from 'components/metadata/MetadataTitle' | ||
import { saveFeatureWithValidation } from 'components/saveFeatureWithValidation' | ||
|
||
const CreateFlag = class extends Component { | ||
|
@@ -182,7 +181,10 @@ const CreateFlag = class extends Component { | |
) { | ||
this.getFeatureUsage() | ||
} | ||
if (Utils.getFlagsmithHasFeature('enable_metadata')) { | ||
if ( | ||
Utils.getPlansPermission('METADATA') && | ||
Utils.getFlagsmithHasFeature('enable_metadata') | ||
) { | ||
getSupportedContentType(getStore(), { | ||
organisation_id: AccountStore.getOrganisation().id, | ||
}).then((res) => { | ||
|
@@ -550,7 +552,9 @@ const CreateFlag = class extends Component { | |
const hideIdentityOverridesTab = Utils.getShouldHideIdentityOverridesTab() | ||
const noPermissions = this.props.noPermissions | ||
let regexValid = true | ||
const metadataEnable = Utils.getFlagsmithHasFeature('enable_metadata') | ||
const metadataEnable = | ||
Utils.getPlansPermission('METADATA') && | ||
Utils.getFlagsmithHasFeature('enable_metadata') | ||
try { | ||
if (!isEdit && name && regex) { | ||
regexValid = name.match(new RegExp(regex)) | ||
|
@@ -580,32 +584,24 @@ const CreateFlag = class extends Component { | |
)} | ||
{metadataEnable && featureContentType?.id && ( | ||
<> | ||
<MetadataTitle | ||
visible={this.state.visible} | ||
onVisibleChange={(v) => { | ||
this.setState({ visible: v }) | ||
<label className='mt-1'>Custom Fields</label> | ||
<AddMetadataToEntity | ||
organisationId={AccountStore.getOrganisation().id} | ||
projectId={this.props.projectId} | ||
entityId={projectFlag?.id} | ||
entityContentType={featureContentType?.id} | ||
entity={featureContentType?.model} | ||
setHasMetadataRequired={(b) => { | ||
this.setState({ | ||
hasMetadataRequired: b, | ||
}) | ||
}} | ||
onChange={(m) => { | ||
this.setState({ | ||
metadata: m, | ||
}) | ||
}} | ||
hasRequiredMetadata={this.state.hasMetadataRequired} | ||
/> | ||
{(this.state.hasMetadataRequired || this.state.visible) && ( | ||
<AddMetadataToEntity | ||
organisationId={AccountStore.getOrganisation().id} | ||
projectId={this.props.projectId} | ||
entityId={projectFlag?.id} | ||
entityContentType={featureContentType?.id} | ||
entity={featureContentType?.model} | ||
setHasMetadataRequired={(b) => { | ||
this.setState({ | ||
hasMetadataRequired: b, | ||
}) | ||
}} | ||
onChange={(m) => { | ||
this.setState({ | ||
metadata: m, | ||
}) | ||
}} | ||
/> | ||
)} | ||
</> | ||
)} | ||
{!identity && projectFlag && ( | ||
|
@@ -1961,12 +1957,23 @@ const FeatureProvider = (WrappedComponent) => { | |
this.listenTo( | ||
FeatureListStore, | ||
'saved', | ||
({ changeRequest, createdFlag, isCreate } = {}) => { | ||
toast( | ||
`${createdFlag || isCreate ? 'Created' : 'Updated'} ${ | ||
changeRequest ? 'Change Request' : 'Feature' | ||
}`, | ||
) | ||
({ changeRequest, createdFlag, error, isCreate } = {}) => { | ||
if (error?.data?.metadata) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error could be defined but not error?.data?.metadata. With this code any other error will show a success message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
error.data.metadata?.forEach((m) => { | ||
if (Object.keys(m).length > 0) { | ||
toast(m.non_field_errors[0], 'danger') | ||
} | ||
}) | ||
} else if (error?.data) { | ||
toast('Error updating the Flag', 'danger') | ||
return | ||
} else { | ||
toast( | ||
`${createdFlag || isCreate ? 'Created' : 'Updated'} ${ | ||
changeRequest ? 'Change Request' : 'Feature' | ||
}`, | ||
) | ||
} | ||
const envFlags = FeatureListStore.getEnvironmentFlags() | ||
|
||
if (createdFlag) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: this affects #4281