When a row is clicked in a Process Instance list take the end user to that process instance UNLESS they click on the column containing the process name, in which case take them to that process model. Belugh.

This commit is contained in:
Dan 2023-03-10 10:36:42 -05:00
parent 91ddb0cbdd
commit aa2c21efb4
1 changed files with 54 additions and 31 deletions

View File

@ -1,10 +1,5 @@
import { useEffect, useMemo, useRef, useState } from 'react'; import { useEffect, useMemo, useRef, useState } from 'react';
import { import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
Link,
useNavigate,
useParams,
useSearchParams,
} from 'react-router-dom';
// @ts-ignore // @ts-ignore
import { Filter, Close, AddAlt } from '@carbon/icons-react'; import { Filter, Close, AddAlt } from '@carbon/icons-react';
@ -66,7 +61,6 @@ import ProcessModelSearch from './ProcessModelSearch';
import ProcessInstanceReportSearch from './ProcessInstanceReportSearch'; import ProcessInstanceReportSearch from './ProcessInstanceReportSearch';
import ProcessInstanceListDeleteReport from './ProcessInstanceListDeleteReport'; import ProcessInstanceListDeleteReport from './ProcessInstanceListDeleteReport';
import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport'; import ProcessInstanceListSaveAsReport from './ProcessInstanceListSaveAsReport';
import { FormatProcessModelDisplayName } from './MiniComponents';
import { Notification } from './Notification'; import { Notification } from './Notification';
import useAPIError from '../hooks/UseApiError'; import useAPIError from '../hooks/UseApiError';
@ -1203,28 +1197,13 @@ export default function ProcessInstanceListTable({
}); });
const formatProcessInstanceId = (row: ProcessInstance, id: number) => { const formatProcessInstanceId = (row: ProcessInstance, id: number) => {
const modifiedProcessModelId: String = return <span data-qa="paginated-entity-id">{id}</span>;
modifyProcessIdentifierForPathParam(row.process_model_identifier);
return (
<Link
data-qa="process-instance-show-link"
to={`${processInstanceShowPathPrefix}/${modifiedProcessModelId}/${id}`}
title={`View process instance ${id}`}
>
<span data-qa="paginated-entity-id">{id}</span>
</Link>
);
}; };
const formatProcessModelIdentifier = (_row: any, identifier: any) => { const formatProcessModelIdentifier = (_row: any, identifier: any) => {
return ( return <span>{identifier}</span>;
<Link };
to={`/admin/process-models/${modifyProcessIdentifierForPathParam( const formatProcessModelDisplayName = (_row: any, identifier: any) => {
identifier return <span>{identifier}</span>;
)}`}
>
{identifier}
</Link>
);
}; };
const formatSecondsForDisplay = (_row: any, seconds: any) => { const formatSecondsForDisplay = (_row: any, seconds: any) => {
@ -1237,7 +1216,7 @@ export default function ProcessInstanceListTable({
const reportColumnFormatters: Record<string, any> = { const reportColumnFormatters: Record<string, any> = {
id: formatProcessInstanceId, id: formatProcessInstanceId,
process_model_identifier: formatProcessModelIdentifier, process_model_identifier: formatProcessModelIdentifier,
process_model_display_name: FormatProcessModelDisplayName, process_model_display_name: formatProcessModelDisplayName,
start_in_seconds: formatSecondsForDisplay, start_in_seconds: formatSecondsForDisplay,
end_in_seconds: formatSecondsForDisplay, end_in_seconds: formatSecondsForDisplay,
}; };
@ -1245,21 +1224,65 @@ export default function ProcessInstanceListTable({
const formatter = const formatter =
reportColumnFormatters[column.accessor] ?? defaultFormatter; reportColumnFormatters[column.accessor] ?? defaultFormatter;
const value = row[column.accessor]; const value = row[column.accessor];
const modifiedModelId = modifyProcessIdentifierForPathParam(
row.process_model_identifier
);
const navigateToProcessInstance = () => {
navigate(
`${processInstanceShowPathPrefix}/${modifiedModelId}/${row.id}`
);
};
const navigateToProcessModel = () => {
navigate(`/admin/process-models/${modifiedModelId}`);
};
if (column.accessor === 'status') { if (column.accessor === 'status') {
return ( return (
<td data-qa={`process-instance-status-${value}`}> // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<td
onClick={navigateToProcessInstance}
onKeyDown={navigateToProcessInstance}
data-qa={`process-instance-status-${value}`}
>
{formatter(row, value)} {formatter(row, value)}
</td> </td>
); );
} }
return <td>{formatter(row, value)}</td>; console.log(column.accessor);
if (column.accessor === 'process_model_display_name') {
const pmStyle = { background: 'rgba(0, 0, 0, .02)' };
return (
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<td
style={pmStyle}
onClick={navigateToProcessModel}
onKeyDown={navigateToProcessModel}
>
{formatter(row, value)}
</td>
);
}
return (
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<td
onKeyDown={navigateToProcessModel}
onClick={navigateToProcessInstance}
>
{formatter(row, value)}
</td>
);
}; };
const rows = processInstances.map((row: any) => { const rows = processInstances.map((row: any) => {
const currentRow = reportColumns().map((column: any) => { const currentRow = reportColumns().map((column: any) => {
return formattedColumn(row, column); return formattedColumn(row, column);
}); });
return <tr key={row.id}>{currentRow}</tr>; const rowStyle = { cursor: 'pointer' };
return (
<tr style={rowStyle} key={row.id}>
{currentRow}
</tr>
);
}); });
return ( return (