do not tell users to add a process model/group if they do not have access to do so w/ burnettk

This commit is contained in:
jasquat 2023-11-13 16:56:41 -05:00
parent c122926e01
commit 1197a1a51a
4 changed files with 41 additions and 5 deletions

View File

@ -20,6 +20,16 @@ groups:
permissions:
admin:
groups: [admin, group1, group2]
groups: [admin, group1]
allowed_permissions: [create, read, update, delete]
uri: /*
basic:
groups: [group2]
allowed_permissions: [all]
uri: BASIC
basic-read:
groups: [group2]
allowed_permissions: [read]
uri: PG:ALL

View File

@ -20,6 +20,7 @@ type OwnProps = {
processGroup?: ProcessGroup;
headerElement?: ReactElement;
showNoItemsDisplayText?: boolean;
userCanCreateProcessModels?: boolean;
};
export default function ProcessGroupListTiles({
@ -27,6 +28,7 @@ export default function ProcessGroupListTiles({
processGroup,
headerElement,
showNoItemsDisplayText,
userCanCreateProcessModels,
}: OwnProps) {
const [searchParams] = useSearchParams();
@ -84,7 +86,7 @@ export default function ProcessGroupListTiles({
</ClickableTile>
);
});
} else {
} else if (userCanCreateProcessModels) {
displayText = (
<p className="no-results-message">
There are no process groups to display. You can add one by clicking
@ -92,6 +94,12 @@ export default function ProcessGroupListTiles({
additional process groups and / or process models.
</p>
);
} else {
displayText = (
<p className="no-results-message">
There are no process groups to display
</p>
);
}
return displayText;
};

View File

@ -19,6 +19,7 @@ type OwnProps = {
checkPermissions?: boolean;
onLoadFunction?: Function;
showNoItemsDisplayText?: boolean;
userCanCreateProcessModels?: boolean;
};
export default function ProcessModelListTiles({
@ -28,6 +29,7 @@ export default function ProcessModelListTiles({
checkPermissions = true,
onLoadFunction,
showNoItemsDisplayText,
userCanCreateProcessModels,
}: OwnProps) {
const [searchParams] = useSearchParams();
const [processModels, setProcessModels] = useState<ProcessModel[] | null>(
@ -94,7 +96,7 @@ export default function ProcessModelListTiles({
</Tile>
);
});
} else {
} else if (userCanCreateProcessModels) {
displayText = (
<p className="no-results-message">
There are no process models to display. You can add one by clicking
@ -103,6 +105,12 @@ export default function ProcessModelListTiles({
runnable workflow.
</p>
);
} else {
displayText = (
<p className="no-results-message">
There are no process models to display
</p>
);
}
return displayText;
};

View File

@ -34,7 +34,9 @@ export default function ProcessGroupShow() {
[targetUris.processGroupShowPath]: ['PUT', 'DELETE'],
[targetUris.processModelCreatePath]: ['POST'],
};
const { ability } = usePermissionFetcher(permissionRequestData);
const { ability, permissionsLoaded } = usePermissionFetcher(
permissionRequestData
);
useEffect(() => {
const processResult = (result: any) => {
@ -63,7 +65,7 @@ export default function ProcessGroupShow() {
}
};
if (processGroup) {
if (processGroup && permissionsLoaded) {
const modifiedProcessGroupId = modifyProcessIdentifierForPathParam(
processGroup.id
);
@ -137,6 +139,10 @@ export default function ProcessGroupShow() {
processGroup={processGroup}
defaultProcessModels={processGroup.process_models}
showNoItemsDisplayText={showNoItemsDisplayText}
userCanCreateProcessModels={ability.can(
'POST',
targetUris.processModelCreatePath
)}
/>
<br />
<br />
@ -145,6 +151,10 @@ export default function ProcessGroupShow() {
headerElement={<h2 className="clear-left">Process Groups</h2>}
defaultProcessGroups={processGroup.process_groups}
showNoItemsDisplayText={showNoItemsDisplayText}
userCanCreateProcessModels={ability.can(
'POST',
targetUris.processGroupListPath
)}
/>
</ul>
</>