Skip to content

Commit

Permalink
frontend details
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofia Sazonova committed Dec 5, 2024
1 parent 5fdc070 commit b8efec6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions backend/dataall/modules/metadata_forms/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,6 @@
fields=MetadataFormEnforcementRule.fields[:]
+ [
gql.Field(name='attached', type=gql.String),
gql.Field(name='metadataFormName', type=gql.String),
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,9 @@ def get_rules_that_affect_entity(entity_type, entity_uri):
)
)

for r in all_rules:
attached = MetadataFormEnforcementService.get_attachement_for_rule(r, entity_uri)
r.attached = attached.uri if attached else None
for r in all_rules:
attached = MetadataFormEnforcementService.get_attachement_for_rule(r, entity_uri)
r.attached = attached.uri if attached else None
r.metadataFormName = MetadataFormRepository.get_metadata_form(session, r.metadataFormUri).name

return all_rules
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ const CreateEnforcementRuleModal = (props) => {
await fetchOrganizations();
await fetchDatasets();
}
setEntityTypes([
...entityTypesOptions.map((t) => ({ ...t, disabled: false }))
]);
}, [client, open, dispatch]);

async function submit(values, setStatus, setSubmitting, setErrors) {
Expand Down Expand Up @@ -218,13 +221,20 @@ const CreateEnforcementRuleModal = (props) => {
};
})}
defaultValue={enforcementScopeDict['Global']}
onChange={(event, value) => {
setFieldValue('scope', value.value);
setEntityTypes(
entityTypesOptions.filter((entityType) => {
return entityType.levels.includes(value.value);
})
);
onChange={async (event, value) => {
entityTypesOptions.forEach((entityType) => {
entityType.disabled = !entityType.levels.includes(
value.value
);
});
setEntityTypes([...entityTypesOptions]);
const active = entityTypesOptions
.filter((t) => !t.disabled)
.map((t) => t.name);
await setFieldValue('scope', value.value);
await setFieldValue('entityTypes', [
...values.entityTypes.filter((t) => active.includes(t))
]);
}}
renderInput={(params) => (
<TextField
Expand Down Expand Up @@ -348,6 +358,10 @@ const CreateEnforcementRuleModal = (props) => {
<FormControlLabel
control={
<Checkbox
disabled={entityType.disabled}
checked={values.entityTypes.includes(
entityType.name
)}
id={entityType.name}
onChange={(event, value) => {
if (value) {
Expand Down Expand Up @@ -435,8 +449,8 @@ export const MetadataFormEnforcement = (props) => {
editable: false,
renderCell: (params) => {
return (
<Label color={params.attached ? 'success' : 'error'}>
{params.attached ? 'Yes' : 'No'}
<Label color={params.row.attached ? 'success' : 'error'}>
{params.row.attached ? 'Yes' : 'No'}
</Label>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const MetadataAttachment = (props) => {
maxLines: 1
}}
>
{rule.metadataFormUri + ' v.' + rule.version}
{rule.metadataFormName + ' v.' + rule.version}
</Typography>
</Grid>
<Grid item lg={3} xl={3}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const listRulesThatAffectEntity = (uri, type) => ({
homeEntityName
entityTypes
metadataFormUri
metadataFormName
version
severity
attached
Expand Down

0 comments on commit b8efec6

Please sign in to comment.