use id_for_file_path when using the process model id as a path for windows and added some more permission stuff to the frontend w/ burnettk
This commit is contained in:
parent
0520a9f9f6
commit
7cd4f43ad9
|
@ -47,7 +47,7 @@ class SpecReferenceCache(SpiffworkflowBaseDBModel):
|
|||
file_name = db.Column(db.String(255))
|
||||
relative_path = db.Column(db.String(255))
|
||||
has_lanes = db.Column(db.Boolean())
|
||||
is_executable = db.Column(db.Boolean()) # either 'process' or 'decision'
|
||||
is_executable = db.Column(db.Boolean())
|
||||
is_primary = db.Column(db.Boolean())
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -54,7 +54,8 @@ class FileSystemService:
|
|||
@staticmethod
|
||||
def process_group_path_for_spec(spec: ProcessModelInfo) -> str:
|
||||
"""Category_path_for_spec."""
|
||||
process_group_id, _ = os.path.split(spec.id)
|
||||
# os.path.split apparently returns 2 element tulple like: (first/path, last_item)
|
||||
process_group_id, _ = os.path.split(spec.id_for_file_path())
|
||||
return FileSystemService.process_group_path(process_group_id)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -45,7 +45,9 @@ class SpecFileService(FileSystemService):
|
|||
) -> List[File]:
|
||||
"""Return all files associated with a workflow specification."""
|
||||
# path = SpecFileService.workflow_path(process_model_info)
|
||||
path = os.path.join(FileSystemService.root_path(), process_model_info.id)
|
||||
path = os.path.join(
|
||||
FileSystemService.root_path(), process_model_info.id_for_file_path()
|
||||
)
|
||||
files = SpecFileService._get_files(path, file_name)
|
||||
if extension_filter != "":
|
||||
files = list(
|
||||
|
@ -88,7 +90,7 @@ class SpecFileService(FileSystemService):
|
|||
"""
|
||||
references: list[SpecReference] = []
|
||||
full_file_path = SpecFileService.full_file_path(process_model_info, file.name)
|
||||
file_path = os.path.join(process_model_info.id, file.name)
|
||||
file_path = os.path.join(process_model_info.id_for_file_path(), file.name)
|
||||
parser = MyCustomParser()
|
||||
parser_type = None
|
||||
sub_parser = None
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import { useParams } from 'react-router-dom';
|
||||
|
||||
export const useUriListForPermissions = () => {
|
||||
const params = useParams();
|
||||
const targetUris = {
|
||||
processGroupListPath: `/v1.0/process-groups`,
|
||||
processGroupShowPath: `/v1.0/process-groups/${params.process_group_id}`,
|
||||
processModelListPath: `/v1.0/process-models`,
|
||||
processModelShowPath: `/v1.0/process-models/${params.process_model_id}`,
|
||||
processInstanceListPath: `/v1.0/process-instances`,
|
||||
processInstanceActionPath: `/v1.0/process-models/${params.process_model_id}/process-instances`,
|
||||
};
|
||||
|
||||
return { targetUris };
|
||||
};
|
|
@ -10,6 +10,7 @@ import {
|
|||
// ClickableTile,
|
||||
// @ts-ignore
|
||||
} from '@carbon/react';
|
||||
import { Can } from '@casl/react';
|
||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||
import PaginationForTable from '../components/PaginationForTable';
|
||||
import HttpService from '../services/HttpService';
|
||||
|
@ -17,8 +18,14 @@ import {
|
|||
getPageInfoFromSearchParams,
|
||||
modifyProcessModelPath,
|
||||
} from '../helpers';
|
||||
import { CarbonComboBoxSelection, ProcessGroup } from '../interfaces';
|
||||
import {
|
||||
CarbonComboBoxSelection,
|
||||
PermissionsToCheck,
|
||||
ProcessGroup,
|
||||
} from '../interfaces';
|
||||
import ProcessModelSearch from '../components/ProcessModelSearch';
|
||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||
|
||||
// Example process group json
|
||||
// {'process_group_id': 'sure', 'display_name': 'Test Workflows', 'id': 'test_process_group'}
|
||||
|
@ -32,6 +39,12 @@ export default function ProcessGroupList() {
|
|||
[]
|
||||
);
|
||||
|
||||
const { targetUris } = useUriListForPermissions();
|
||||
const permissionRequestData: PermissionsToCheck = {
|
||||
[targetUris.processGroupListPath]: ['POST'],
|
||||
};
|
||||
const { ability } = usePermissionFetcher(permissionRequestData);
|
||||
|
||||
useEffect(() => {
|
||||
const setProcessGroupsFromResult = (result: any) => {
|
||||
setProcessGroups(result.results);
|
||||
|
@ -84,17 +97,6 @@ export default function ProcessGroupList() {
|
|||
<tbody>{rows}</tbody>
|
||||
</Table>
|
||||
);
|
||||
// const rows = processGroups.map((row: ProcessGroup) => {
|
||||
// return (
|
||||
// <span>
|
||||
// <ClickableTile href={`/admin/process-groups/${row.id}`}>
|
||||
// {row.display_name}
|
||||
// </ClickableTile>
|
||||
// </span>
|
||||
// );
|
||||
// });
|
||||
//
|
||||
// return <div style={{ width: '400px' }}>{rows}</div>;
|
||||
};
|
||||
|
||||
const processGroupsDisplayArea = () => {
|
||||
|
@ -138,11 +140,13 @@ export default function ProcessGroupList() {
|
|||
return (
|
||||
<>
|
||||
<ProcessBreadcrumb hotCrumbs={[['Process Groups']]} />
|
||||
<Button kind="secondary" href="/admin/process-groups/new">
|
||||
Add a process group
|
||||
</Button>
|
||||
<br />
|
||||
<br />
|
||||
<Can I="POST" a={targetUris.processGroupListPath} ability={ability}>
|
||||
<Button kind="secondary" href="/admin/process-groups/new">
|
||||
Add a process group
|
||||
</Button>
|
||||
<br />
|
||||
<br />
|
||||
</Can>
|
||||
{processModelSearchArea()}
|
||||
<br />
|
||||
{processGroupsDisplayArea()}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
|||
import { Link, useSearchParams, useParams } from 'react-router-dom';
|
||||
// @ts-ignore
|
||||
import { Button, Table, Stack } from '@carbon/react';
|
||||
import { Can } from '@casl/react';
|
||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||
import PaginationForTable from '../components/PaginationForTable';
|
||||
import HttpService from '../services/HttpService';
|
||||
|
@ -10,7 +11,14 @@ import {
|
|||
modifyProcessModelPath,
|
||||
unModifyProcessModelPath,
|
||||
} from '../helpers';
|
||||
import { PaginationObject, ProcessGroup, ProcessModel } from '../interfaces';
|
||||
import {
|
||||
PaginationObject,
|
||||
PermissionsToCheck,
|
||||
ProcessGroup,
|
||||
ProcessModel,
|
||||
} from '../interfaces';
|
||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||
|
||||
export default function ProcessGroupShow() {
|
||||
const params = useParams();
|
||||
|
@ -24,6 +32,12 @@ export default function ProcessGroupShow() {
|
|||
const [groupPagination, setGroupPagination] =
|
||||
useState<PaginationObject | null>(null);
|
||||
|
||||
const { targetUris } = useUriListForPermissions();
|
||||
const permissionRequestData: PermissionsToCheck = {
|
||||
[targetUris.processGroupListPath]: ['POST'],
|
||||
};
|
||||
const { ability } = usePermissionFetcher(permissionRequestData);
|
||||
|
||||
useEffect(() => {
|
||||
const { page, perPage } = getPageInfoFromSearchParams(searchParams);
|
||||
|
||||
|
@ -143,12 +157,14 @@ export default function ProcessGroupShow() {
|
|||
<h1>Process Group: {processGroup.display_name}</h1>
|
||||
<ul>
|
||||
<Stack orientation="horizontal" gap={3}>
|
||||
<Button
|
||||
kind="secondary"
|
||||
href={`/admin/process-groups/new?parentGroupId=${processGroup.id}`}
|
||||
>
|
||||
Add a process group
|
||||
</Button>
|
||||
<Can I="POST" a={targetUris.processGroupListPath} ability={ability}>
|
||||
<Button
|
||||
kind="secondary"
|
||||
href={`/admin/process-groups/new?parentGroupId=${processGroup.id}`}
|
||||
>
|
||||
Add a process group
|
||||
</Button>
|
||||
</Can>
|
||||
<Button
|
||||
href={`/admin/process-models/${modifiedProcessGroupId}/new`}
|
||||
>
|
||||
|
|
|
@ -40,7 +40,8 @@ import {
|
|||
} from '../interfaces';
|
||||
import ButtonWithConfirmation from '../components/ButtonWithConfirmation';
|
||||
import ProcessInstanceListTable from '../components/ProcessInstanceListTable';
|
||||
import { usePermissionFetcher } from '../components/PermissionService';
|
||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||
|
||||
const storeRecentProcessModelInLocalStorage = (
|
||||
processModelForStorage: ProcessModel
|
||||
|
@ -103,16 +104,11 @@ export default function ProcessModelShow() {
|
|||
useState<boolean>(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const targetUris = {
|
||||
processModelPath: `/process-models/${params.process_model_id}`,
|
||||
processInstancesPath: `/process-instances`,
|
||||
};
|
||||
const { targetUris } = useUriListForPermissions();
|
||||
const permissionRequestData: PermissionsToCheck = {
|
||||
[`/v1.0${targetUris.processModelPath}`]: ['GET', 'PUT'],
|
||||
[`/v1.0${targetUris.processInstancesPath}`]: ['GET'],
|
||||
[`/v1.0${targetUris.processModelPath}${targetUris.processInstancesPath}`]: [
|
||||
'POST',
|
||||
],
|
||||
[targetUris.processModelShowPath]: ['GET', 'PUT'],
|
||||
[targetUris.processInstanceListPath]: ['GET'],
|
||||
[targetUris.processInstanceActionPath]: ['POST'],
|
||||
};
|
||||
const { ability } = usePermissionFetcher(permissionRequestData);
|
||||
|
||||
|
@ -513,18 +509,14 @@ export default function ProcessModelShow() {
|
|||
<Stack orientation="horizontal" gap={3}>
|
||||
<Can
|
||||
I="POST"
|
||||
a={`/v1.0${targetUris.processModelPath}${targetUris.processInstancesPath}`}
|
||||
a={targetUris.processInstanceActionPath}
|
||||
ability={ability}
|
||||
>
|
||||
<Button onClick={processInstanceCreateAndRun} variant="primary">
|
||||
Run
|
||||
</Button>
|
||||
</Can>
|
||||
<Can
|
||||
I="PUT"
|
||||
a={`/v1.0${targetUris.processModelPath}`}
|
||||
ability={ability}
|
||||
>
|
||||
<Can I="PUT" a={targetUris.processModelShowPath} ability={ability}>
|
||||
<Button
|
||||
href={`/admin/process-models/${modifiedProcessModelId}/edit`}
|
||||
variant="secondary"
|
||||
|
@ -537,11 +529,7 @@ export default function ProcessModelShow() {
|
|||
<br />
|
||||
{processInstanceRunResultTag()}
|
||||
<br />
|
||||
<Can
|
||||
I="GET"
|
||||
a={`/v1.0${targetUris.processInstancesPath}`}
|
||||
ability={ability}
|
||||
>
|
||||
<Can I="GET" a={targetUris.processInstanceListPath} ability={ability}>
|
||||
<ProcessInstanceListTable
|
||||
filtersEnabled={false}
|
||||
processModelFullIdentifier={processModel.id}
|
||||
|
|
Loading…
Reference in New Issue