removed the format header method from frontend so we only use the columns that come from the metadata now w/ burnettk
This commit is contained in:
parent
a779fcd97b
commit
4832256fc5
|
@ -100,7 +100,7 @@ class ProcessInstanceReportService:
|
|||
{"Header": "Waiting For", "accessor": "waiting_for", "filterable": False},
|
||||
{"Header": "Started", "accessor": "start_in_seconds", "filterable": False},
|
||||
{"Header": "Last Updated", "accessor": "task_updated_at_in_seconds", "filterable": False},
|
||||
{"Header": "status", "accessor": "status", "filterable": False},
|
||||
{"Header": "Status", "accessor": "status", "filterable": False},
|
||||
],
|
||||
"filter_by": [
|
||||
{"field_name": "initiated_by_me", "field_value": True, "operator": "equals"},
|
||||
|
|
|
@ -138,7 +138,9 @@ export default function ProcessInstanceListTable({
|
|||
);
|
||||
const canSearchUsers: boolean = ability.can('GET', targetUris.userSearch);
|
||||
|
||||
const [processInstances, setProcessInstances] = useState([]);
|
||||
const [processInstances, setProcessInstances] = useState<ProcessInstance[]>(
|
||||
[]
|
||||
);
|
||||
const [reportMetadata, setReportMetadata] = useState<ReportMetadata | null>();
|
||||
const [pagination, setPagination] = useState<PaginationObject | null>(null);
|
||||
|
||||
|
@ -1509,7 +1511,7 @@ export default function ProcessInstanceListTable({
|
|||
return value;
|
||||
};
|
||||
|
||||
const formattedColumn = (row: any, column: any) => {
|
||||
const formattedColumn = (row: ProcessInstance, column: ReportColumn) => {
|
||||
const reportColumnFormatters: Record<string, any> = {
|
||||
id: formatProcessInstanceId,
|
||||
process_model_identifier: formatProcessModelIdentifier,
|
||||
|
@ -1520,40 +1522,41 @@ export default function ProcessInstanceListTable({
|
|||
updated_at_in_seconds: formatSecondsForDisplay,
|
||||
task_updated_at_in_seconds: formatSecondsForDisplay,
|
||||
};
|
||||
const columnAccessor = column.accessor as keyof ProcessInstance;
|
||||
const formatter =
|
||||
reportColumnFormatters[column.accessor] ?? defaultFormatter;
|
||||
const value = row[column.accessor];
|
||||
reportColumnFormatters[columnAccessor] ?? defaultFormatter;
|
||||
const value = row[columnAccessor];
|
||||
|
||||
if (column.accessor === 'status') {
|
||||
if (columnAccessor === 'status') {
|
||||
return (
|
||||
<td data-qa={`process-instance-status-${value}`}>
|
||||
{formatter(row, value)}
|
||||
</td>
|
||||
);
|
||||
}
|
||||
if (column.accessor === 'process_model_display_name') {
|
||||
if (columnAccessor === 'process_model_display_name') {
|
||||
return <td> {formatter(row, value)} </td>;
|
||||
}
|
||||
if (column.accessor === 'waiting_for') {
|
||||
if (columnAccessor === 'waiting_for') {
|
||||
return <td> {getWaitingForTableCellComponent(row)} </td>;
|
||||
}
|
||||
if (column.accessor === 'updated_at_in_seconds') {
|
||||
if (columnAccessor === 'updated_at_in_seconds') {
|
||||
return (
|
||||
<TableCellWithTimeAgoInWords
|
||||
timeInSeconds={row.updated_at_in_seconds}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (column.accessor === 'task_updated_at_in_seconds') {
|
||||
if (columnAccessor === 'task_updated_at_in_seconds') {
|
||||
return (
|
||||
<TableCellWithTimeAgoInWords
|
||||
timeInSeconds={row.task_updated_at_in_seconds}
|
||||
timeInSeconds={row.task_updated_at_in_seconds || 0}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
||||
<td data-qa={`process-instance-show-link-${column.accessor}`}>
|
||||
<td data-qa={`process-instance-show-link-${columnAccessor}`}>
|
||||
{formatter(row, value)}
|
||||
</td>
|
||||
);
|
||||
|
@ -1561,27 +1564,15 @@ export default function ProcessInstanceListTable({
|
|||
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
const buildTable = () => {
|
||||
const headerLabels: Record<string, string> = {
|
||||
id: 'Id',
|
||||
process_model_identifier: 'Process',
|
||||
process_model_display_name: 'Process',
|
||||
start_in_seconds: 'Start Time',
|
||||
end_in_seconds: 'End Time',
|
||||
status: 'Status',
|
||||
process_initiator_username: 'Started By',
|
||||
};
|
||||
const getHeaderLabel = (header: string) => {
|
||||
return headerLabels[header] ?? header;
|
||||
};
|
||||
const headers = reportColumns().map((column: any) => {
|
||||
return getHeaderLabel((column as any).Header);
|
||||
const headers = reportColumns().map((column: ReportColumn) => {
|
||||
return column.Header;
|
||||
});
|
||||
if (showActionsColumn) {
|
||||
headers.push('Action');
|
||||
}
|
||||
|
||||
const rows = processInstances.map((row: any) => {
|
||||
const currentRow = reportColumns().map((column: any) => {
|
||||
const rows = processInstances.map((row: ProcessInstance) => {
|
||||
const currentRow = reportColumns().map((column: ReportColumn) => {
|
||||
return formattedColumn(row, column);
|
||||
});
|
||||
if (showActionsColumn) {
|
||||
|
|
|
@ -143,6 +143,12 @@ export interface ProcessInstance {
|
|||
bpmn_version_control_type: string;
|
||||
process_metadata?: ProcessInstanceMetadata[];
|
||||
process_model_with_diagram_identifier?: string;
|
||||
|
||||
// from tasks
|
||||
potential_owner_usernames?: string;
|
||||
task_id?: string;
|
||||
task_updated_at_in_seconds?: number;
|
||||
waiting_for?: string;
|
||||
}
|
||||
|
||||
export interface MessageCorrelationProperties {
|
||||
|
|
Loading…
Reference in New Issue