wip.
This commit is contained in:
parent
52d1df5c0f
commit
417bd63e45
|
@ -744,7 +744,7 @@ export default function ProcessInstanceListTable({
|
||||||
undefined,
|
undefined,
|
||||||
paginationQueryParamPrefix
|
paginationQueryParamPrefix
|
||||||
);
|
);
|
||||||
page = 1; // Reset page back to 0
|
page = 1;
|
||||||
|
|
||||||
const newReportMetadata = getNewReportMetadataBasedOnPageWidgets();
|
const newReportMetadata = getNewReportMetadataBasedOnPageWidgets();
|
||||||
setListHasBeenFiltered(true);
|
setListHasBeenFiltered(true);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Loading, Grid, Column, Button } from '@carbon/react';
|
import { Loading, Grid, Column, Button } from '@carbon/react';
|
||||||
|
@ -7,30 +7,36 @@ import { BACKEND_BASE_URL } from '../config';
|
||||||
import { getBasicHeaders } from '../services/HttpService';
|
import { getBasicHeaders } from '../services/HttpService';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import InstructionsForEndUser from '../components/InstructionsForEndUser';
|
import InstructionsForEndUser from './InstructionsForEndUser';
|
||||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
import ProcessBreadcrumb from './ProcessBreadcrumb';
|
||||||
import { ProcessInstance, ProcessInstanceTask } from '../interfaces';
|
import { ProcessInstance, ProcessInstanceTask } from '../interfaces';
|
||||||
import useAPIError from '../hooks/UseApiError';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
|
||||||
export default function ProcessInterstitial() {
|
type OwnProps = {
|
||||||
|
processInstanceId: number;
|
||||||
|
modifiedProcessModelIdentifier: string;
|
||||||
|
allowRedirect: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ProcessInterstitial({
|
||||||
|
processInstanceId,
|
||||||
|
modifiedProcessModelIdentifier,
|
||||||
|
allowRedirect,
|
||||||
|
}: OwnProps) {
|
||||||
const [data, setData] = useState<any[]>([]);
|
const [data, setData] = useState<any[]>([]);
|
||||||
const [lastTask, setLastTask] = useState<any>(null);
|
const [lastTask, setLastTask] = useState<any>(null);
|
||||||
|
const [state, setState] = useState<string>('RUNNING');
|
||||||
const [processInstance, setProcessInstance] =
|
const [processInstance, setProcessInstance] =
|
||||||
useState<ProcessInstance | null>(null);
|
useState<ProcessInstance | null>(null);
|
||||||
const [state, setState] = useState<string>('RUNNING');
|
const processInstanceShowPageBaseUrl = `/admin/process-instances/for-me/${modifiedProcessModelIdentifier}`;
|
||||||
const params = useParams();
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const userTasks = useMemo(() => {
|
const userTasks = useMemo(() => {
|
||||||
return ['User Task', 'Manual Task'];
|
return ['User Task', 'Manual Task'];
|
||||||
}, []);
|
}, []);
|
||||||
const { addError } = useAPIError();
|
const { addError } = useAPIError();
|
||||||
|
|
||||||
const processInstanceShowPageBaseUrl = `/admin/process-instances/for-me/${params.modified_process_model_identifier}`;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchEventSource(
|
fetchEventSource(`${BACKEND_BASE_URL}/tasks/${processInstanceId}`, {
|
||||||
`${BACKEND_BASE_URL}/tasks/${params.process_instance_id}`,
|
|
||||||
{
|
|
||||||
headers: getBasicHeaders(),
|
headers: getBasicHeaders(),
|
||||||
onmessage(ev) {
|
onmessage(ev) {
|
||||||
const retValue = JSON.parse(ev.data);
|
const retValue = JSON.parse(ev.data);
|
||||||
|
@ -46,14 +52,14 @@ export default function ProcessInterstitial() {
|
||||||
onclose() {
|
onclose() {
|
||||||
setState('CLOSED');
|
setState('CLOSED');
|
||||||
},
|
},
|
||||||
}
|
});
|
||||||
);
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []); // it is critical to only run this once.
|
}, []); // it is critical to only run this once.
|
||||||
|
|
||||||
const shouldRedirect = useCallback(
|
const shouldRedirect = useCallback(
|
||||||
(myTask: ProcessInstanceTask): boolean => {
|
(myTask: ProcessInstanceTask): boolean => {
|
||||||
return (
|
return (
|
||||||
|
allowRedirect &&
|
||||||
!processInstance &&
|
!processInstance &&
|
||||||
myTask &&
|
myTask &&
|
||||||
myTask.can_complete &&
|
myTask.can_complete &&
|
||||||
|
@ -166,6 +172,9 @@ export default function ProcessInterstitial() {
|
||||||
if (shouldRedirect(myTask)) {
|
if (shouldRedirect(myTask)) {
|
||||||
return <div>Redirecting you to the next task now ...</div>;
|
return <div>Redirecting you to the next task now ...</div>;
|
||||||
}
|
}
|
||||||
|
if (myTask && myTask.can_complete && userTasks.includes(myTask.type)) {
|
||||||
|
return `The task ${myTask.title} is ready for you to complete.`;
|
||||||
|
}
|
||||||
if (myTask.error_message) {
|
if (myTask.error_message) {
|
||||||
return <div>{myTask.error_message}</div>;
|
return <div>{myTask.error_message}</div>;
|
||||||
}
|
}
|
||||||
|
@ -201,8 +210,8 @@ export default function ProcessInterstitial() {
|
||||||
linkLastItem: true,
|
linkLastItem: true,
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
`Process Instance: ${params.process_instance_id}`,
|
`Process Instance: ${processInstanceId}`,
|
||||||
`${processInstanceShowPageBaseUrl}/${params.process_instance_id}`,
|
`${processInstanceShowPageBaseUrl}/${processInstanceId}`,
|
||||||
],
|
],
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
|
@ -23,6 +23,7 @@ export interface RecentProcessModel {
|
||||||
|
|
||||||
export interface TaskPropertiesJson {
|
export interface TaskPropertiesJson {
|
||||||
parent: string;
|
parent: string;
|
||||||
|
last_state_change: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TaskDefinitionPropertiesJson {
|
export interface TaskDefinitionPropertiesJson {
|
||||||
|
|
|
@ -53,6 +53,7 @@ import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||||
import ProcessInstanceClass from '../classes/ProcessInstanceClass';
|
import ProcessInstanceClass from '../classes/ProcessInstanceClass';
|
||||||
import TaskListTable from '../components/TaskListTable';
|
import TaskListTable from '../components/TaskListTable';
|
||||||
import useAPIError from '../hooks/UseApiError';
|
import useAPIError from '../hooks/UseApiError';
|
||||||
|
import ProcessInterstitial from "../components/ProcessInterstitial";
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
variant: string;
|
variant: string;
|
||||||
|
@ -1092,23 +1093,9 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ProcessBreadcrumb
|
<ProcessInterstitial processInstanceId={processInstance.id} modifiedProcessModelIdentifier={String(modifiedProcessModelId)} allowRedirect={false}/>
|
||||||
hotCrumbs={[
|
|
||||||
['Process Groups', '/admin'],
|
|
||||||
{
|
|
||||||
entityToExplode: processModelId,
|
|
||||||
entityType: 'process-model-id',
|
|
||||||
linkLastItem: true,
|
|
||||||
},
|
|
||||||
[`Process Instance Id: ${processInstance.id}`],
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<Stack orientation="horizontal" gap={1}>
|
|
||||||
<h1 className="with-icons">
|
|
||||||
Process Instance Id: {processInstance.id}
|
|
||||||
</h1>
|
|
||||||
{buttonIcons()}
|
{buttonIcons()}
|
||||||
</Stack>
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<Grid condensed fullWidth>
|
<Grid condensed fullWidth>
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
// @ts-ignore
|
||||||
|
import ProcessInterstitial from '../components/ProcessInterstitial';
|
||||||
|
|
||||||
|
export default function ProcessInterstitialPage() {
|
||||||
|
const params = useParams();
|
||||||
|
// @ts-ignore
|
||||||
|
return (
|
||||||
|
<ProcessInterstitial
|
||||||
|
processInstanceId={Number(params.process_instance_id)}
|
||||||
|
modifiedProcessModelIdentifier={String(
|
||||||
|
params.modified_process_model_identifier
|
||||||
|
)}
|
||||||
|
allowRedirect
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
import { Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import ProcessInterstitial from './ProcessInterstitial';
|
import ProcessInterstitialPage from './ProcessInterstitialPage';
|
||||||
|
|
||||||
export default function ProcessRoutes() {
|
export default function ProcessRoutes() {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route
|
<Route
|
||||||
path=":modified_process_model_identifier/:process_instance_id/interstitial"
|
path=":modified_process_model_identifier/:process_instance_id/interstitial"
|
||||||
element={<ProcessInterstitial />}
|
element={<ProcessInterstitialPage />}
|
||||||
/>
|
/>
|
||||||
</Routes>
|
</Routes>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue