Skip to content

Commit

Permalink
MMT-3907: Updated provider dropdown so it is disabled on updating the…
Browse files Browse the repository at this point in the history
… ACL. Only creation of the ACL will it be enabled. (#1310)

* MMT-3907: Updated provider dropdown so it is disabled on updating the ACL.   Only creation of the ACL will it be enabled.
  • Loading branch information
cgokey authored Oct 4, 2024
1 parent c54d427 commit 1d4ad7a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
36 changes: 15 additions & 21 deletions static/src/js/components/PermissionForm/PermissionForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ const PermissionForm = ({ selectedCollectionsPageSize }) => {
const { conceptId = 'new' } = useParams()

const [focusField, setFocusField] = useState(null)
const [uiSchema, setUiSchema] = useState(collectionPermissionUiSchema)
const [uiSchema, setUiSchema] = useState({
...collectionPermissionUiSchema,
providers: {
...collectionPermissionUiSchema.providers,
'ui:disabled': (conceptId !== 'new')
}
})
const [schema, setSchema] = useState(collectionPermission)

const { providerIds } = useAvailableProviders()
Expand Down Expand Up @@ -309,33 +315,21 @@ const PermissionForm = ({ selectedCollectionsPageSize }) => {
* @param {boolean} formData.accessPermission.granule - The flag indicating if granule access is allowed.
*/
const showGranuleFields = (formData) => {
if (formData.accessPermission?.granule) {
if (formData.accessPermission) {
const newUiSchema = {
...collectionPermissionUiSchema,
...uiSchema,
accessConstraintFilter: {
...collectionPermissionUiSchema.accessConstraintFilter,
...uiSchema.accessConstraintFilter,
granuleAccessConstraint: {
...collectionPermissionUiSchema.accessConstraintFilter.granuleAccessConstraint,
'ui:disabled': false
...uiSchema.accessConstraintFilter.granuleAccessConstraint,
'ui:disabled': !formData.accessPermission?.granule
}
},
temporalConstraintFilter: {
...collectionPermissionUiSchema.temporalConstraintFilter,
...uiSchema.temporalConstraintFilter,
granuleTemporalConstraint: {
...collectionPermissionUiSchema.temporalConstraintFilter.granuleTemporalConstraint,
'ui:disabled': false
}
}
}
setUiSchema(newUiSchema)
} else {
const newUiSchema = {
...collectionPermissionUiSchema,
accessConstraintFilter: {
...collectionPermissionUiSchema.accessConstraintFilter,
granuleAccessConstraint: {
...collectionPermissionUiSchema.accessConstraintFilter.granuleAccessConstraint,
'ui:disabled': true
...uiSchema.temporalConstraintFilter.granuleTemporalConstraint,
'ui:disabled': !formData.accessPermission?.granule
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion static/src/js/schemas/collectionPermission.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const collectionPermission = {
type: 'object'
}
},
required: ['name', 'collectionSelection', 'accessPermission', 'groupPermissions'],
required: ['name', 'providers', 'collectionSelection', 'accessPermission', 'groupPermissions'],

definitions: {
collectionSelectionType: {
Expand Down
2 changes: 2 additions & 0 deletions static/src/js/schemas/uiSchemas/collectionPermission.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const collectionPermissionUiSchema = {
]
},
providers: {
'ui:title': 'Provider',
'ui:disabled': false,
'ui:required': true,
'ui:widget': CustomSelectWidget
},
Expand Down

0 comments on commit 1d4ad7a

Please sign in to comment.