Allow adding a data store at the top level (#1004)

* Show tiles at the top level

* Add a data store from the top level

* Pre pr cleanup
This commit is contained in:
jbirddog 2024-02-08 14:50:31 -05:00 committed by GitHub
parent 886f1f5757
commit b6bdd9780f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 11 deletions

View File

@ -41,10 +41,9 @@ export default function DataStoreListTiles({
if (defaultDataStores) { if (defaultDataStores) {
setDataStores(defaultDataStores); setDataStores(defaultDataStores);
} else { } else {
let queryParams = '?per_page=1000'; const queryParams = `?per_page=1000&process_group_identifier=${
if (processGroup) { processGroup?.id ?? ''
queryParams = `${queryParams}&process_group_identifier=${processGroup.id}`; }`;
}
HttpService.makeCallToBackend({ HttpService.makeCallToBackend({
path: `${targetUris.dataStoreListPath}${queryParams}`, path: `${targetUris.dataStoreListPath}${queryParams}`,
successCallback: setDataStores, successCallback: setDataStores,

View File

@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { import {
Button, Button,
Stack,
// @ts-ignore // @ts-ignore
} from '@carbon/react'; } from '@carbon/react';
import { Can } from '@casl/react'; import { Can } from '@casl/react';
@ -13,6 +14,7 @@ import { useUriListForPermissions } from '../hooks/UriListForPermissions';
import { usePermissionFetcher } from '../hooks/PermissionService'; import { usePermissionFetcher } from '../hooks/PermissionService';
import ProcessModelSearch from '../components/ProcessModelSearch'; import ProcessModelSearch from '../components/ProcessModelSearch';
import ProcessGroupListTiles from '../components/ProcessGroupListTiles'; import ProcessGroupListTiles from '../components/ProcessGroupListTiles';
import DataStoreListTiles from '../components/DataStoreListTiles';
export default function ProcessGroupList() { export default function ProcessGroupList() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -23,6 +25,7 @@ export default function ProcessGroupList() {
const { targetUris } = useUriListForPermissions(); const { targetUris } = useUriListForPermissions();
const permissionRequestData: PermissionsToCheck = { const permissionRequestData: PermissionsToCheck = {
[targetUris.dataStoreListPath]: ['POST'],
[targetUris.processGroupListPath]: ['POST'], [targetUris.processGroupListPath]: ['POST'],
}; };
const { ability } = usePermissionFetcher(permissionRequestData); const { ability } = usePermissionFetcher(permissionRequestData);
@ -69,17 +72,32 @@ export default function ProcessGroupList() {
return ( return (
<> <>
<ProcessBreadcrumb hotCrumbs={[['Process Groups']]} /> <ProcessBreadcrumb hotCrumbs={[['Process Groups']]} />
<Can I="POST" a={targetUris.processGroupListPath} ability={ability}> <Stack orientation="horizontal" gap={3}>
<Button kind="secondary" href="/process-groups/new"> <Can I="POST" a={targetUris.processGroupListPath} ability={ability}>
Add a process group <Button kind="secondary" href="/process-groups/new">
</Button> Add a process group
<br /> </Button>
<br /> </Can>
</Can> <Can I="POST" a={targetUris.dataStoreListPath} ability={ability}>
<Button href="/data-stores/new?parentGroupId=">
Add a data store
</Button>
</Can>
</Stack>
<br />
<br /> <br />
{processModelSearchArea()} {processModelSearchArea()}
<br /> <br />
<ProcessGroupListTiles showNoItemsDisplayText /> <ProcessGroupListTiles showNoItemsDisplayText />
<br />
<br />
<DataStoreListTiles
headerElement={<h2 className="clear-left">Data Stores</h2>}
userCanCreateDataStores={ability.can(
'POST',
targetUris.dataStoreListPath
)}
/>
</> </>
); );
} }