Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Update changed process properties
Browse files Browse the repository at this point in the history
- change process.pid to process.process_id
- change process.workflow to process.workflow_name
- change process.started to process.started_at
- change process.last_modified to process.last_modified_at
- change process.step to process.last_step
- change process.status to process.last_status
  • Loading branch information
tjeerddie committed Sep 20, 2023
1 parent 5dd116e commit cc6ef13
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 124 deletions.
8 changes: 4 additions & 4 deletions src/components/ProcessStateDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ function ProcessStateDetails({
};

const summaryKeys: (keyof ProcessWithDetails)[] = [
"status",
"last_status",
isProcess ? "assignee" : "created_by",
"step",
"started",
"last_modified",
"last_step",
"started_at",
"last_modified_at",
];
const renderSummaryValue = (value: string | number | any) =>
typeof value === "string" ? capitalize(value) : typeof value === "number" ? renderDateTime(value) : value;
Expand Down
6 changes: 1 addition & 5 deletions src/components/failedTaskBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import RunningProcessesContext from "contextProviders/runningProcessesProvider";
import { useCallback, useContext, useEffect, useState } from "react";
import { useHistory } from "react-router";
import ApplicationContext from "utils/ApplicationContext";
import { Process, ProcessStatus, ProcessStatusCounts } from "utils/types";
import { ProcessStatusCounts } from "utils/types";
import useHttpIntervalFallback from "utils/useHttpIntervalFallback";

import { failedTaskBannerStyling } from "./FailedTaskBannerStyling";
Expand All @@ -27,10 +27,6 @@ enum CheckboxStatus {
"OK" = "ok",
"FAILED" = "failed",
}
export interface ProcessData extends Process {
id: string;
status: ProcessStatus;
}

interface CountFailedTasks {
failed: number;
Expand Down
8 changes: 4 additions & 4 deletions src/components/subscriptionDetail/Renderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export function RenderProduct({ product }: { product?: Product }) {

export function RenderProcesses({ subscriptionProcesses }: { subscriptionProcesses: SubscriptionProcesses[] }) {
const { theme } = useContext(ApplicationContext);
const columns = ["target", "name", "id", "status", "started_at", "modified_at"];
const columns = ["target", "name", "id", "status", "started_at", "last_modified_at"];

const th = (index: number) => {
const name = columns[index];
Expand Down Expand Up @@ -344,10 +344,10 @@ export function RenderProcesses({ subscriptionProcesses }: { subscriptionProcess
{subscriptionProcesses.map((ps, index) => (
<tr key={index} className={theme}>
<td>{ps.workflow_target}</td>
<td>{ps.process.workflow}</td>
<td>{ps.process.workflow_name}</td>
<td>
<a target="_blank" rel="noopener noreferrer" href={`/processes/${ps.pid}`}>
{ps.pid}
<a target="_blank" rel="noopener noreferrer" href={`/processes/${ps.process_id}`}>
{ps.process_id}
</a>
</td>
<td>{ps.process.last_status}</td>
Expand Down
2 changes: 1 addition & 1 deletion src/components/subscriptionDetail/SubscriptionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function renderFailedTask(subscriptionProcesses: SubscriptionProcesses[]) {

if (failed_tasks.length) {
let process = failed_tasks[0];
let url = process.is_task ? `/task/${process.pid}` : `/process/${process.pid}`;
let url = process.is_task ? `/task/${process.process_id}` : `/process/${process.process_id}`;
return (
<a target="_blank" rel="noopener noreferrer" href={url}>
<FormattedMessage id="subscriptions.failed_task" values={process as any} />
Expand Down
40 changes: 21 additions & 19 deletions src/components/tables/Processes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ import { ProcessV2 } from "utils/types";
export function initialProcessesFilterAndSort(showTasks: boolean, statuses: string[]) {
const initialFilterBy = [
{ id: "isTask", values: [`${showTasks ? "true" : "false"}`] },
{ id: "status", values: statuses },
{ id: "lastStatus", values: statuses },
];
const initialSortBy = [{ id: "modified", desc: true }];
const initialSortBy = [{ id: "lastModifiedAt", desc: true }];
return { filterBy: initialFilterBy, sortBy: initialSortBy };
}

Expand Down Expand Up @@ -157,18 +157,18 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
return {
...props,
id: row.values.pid,
className: `${row.values.status}${highlighted}`,
className: `${row.values.last_status}${highlighted}`,
};
},
[highlightQ]
);

const renderSubComponent = useCallback(({ row }: { row: Row<ProcessV2> }) => {
const { status, step, info } = row.values;
const { last_status, last_step, info } = row.values;
return (
<div className={"expanded-row"}>
<h2>
<FormattedMessage id={`table.expanded_row.${status}`} values={{ step: step }} />
<FormattedMessage id={`table.expanded_row.${last_status}`} values={{ step: last_step }} />
</h2>
<pre>{info}</pre>
</div>
Expand All @@ -188,11 +188,11 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
<i className="fa fa-arrows-alt-v" onClick={() => toggleAllRowsExpanded()} />
),
Cell: ({ row }: { row: Row; cell: Cell }) => {
const caret = row.values.pid === highlightQ ? <i className={"fa fa-caret-right"} /> : null;
const caret = row.values.process_id === highlightQ ? <i className={"fa fa-caret-right"} /> : null;
const button = row.isExpanded ? (
<i className={`fa fa-minus-circle ${row.values.status}`} />
<i className={`fa fa-minus-circle ${row.values.last_status}`} />
) : (
<i className={`fa fa-plus-circle ${row.values.status}`} />
<i className={`fa fa-plus-circle ${row.values.last_status}`} />
);
return (
<div
Expand All @@ -210,7 +210,8 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
},
{
Header: "pid",
accessor: "pid",
id: "processId",
accessor: "process_id",
disableSortBy: true,
disableFilters: true,
Cell: renderPidCell,
Expand All @@ -222,14 +223,14 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
},
{
Header: "Last step",
id: "step",
id: "lastStep",
accessor: "last_step",
disableSortBy: true,
disableFilters: true,
},
{
Header: "Status",
id: "status",
Header: "Last status",
id: "lastStatus",
accessor: "last_status",
Filter: renderMultiSelectFilter.bind(null, processStatuses, "process_statuses"),
Cell: ({ cell }: { cell: Cell }) => {
Expand All @@ -238,7 +239,8 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
},
{
Header: "Workflow",
accessor: "workflow",
id: "workflowName",
accessor: "workflow_name",
Filter: renderILikeFilter,
Cell: renderWorkflowNameCell,
},
Expand Down Expand Up @@ -275,7 +277,7 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
},
{
Header: "Tag(s)",
id: "tag",
id: "productTag",
accessor: "subscriptions",
disableSortBy: true,
Cell: renderProductTagCell,
Expand All @@ -290,21 +292,21 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
},
{
Header: "Created by",
id: "creator",
id: "createdBy",
accessor: "created_by",
Filter: renderILikeFilter,
},
{
Header: "Started",
id: "started",
id: "startedAt",
accessor: "started_at",
Cell: renderTimestampCell,
disableFilters: true,
},
{
Header: "Modified",
id: "modified",
accessor: "last_modified_at",
id: "lastModifiedAt",
accessor: "last_lastModifiedAt_at",
Cell: renderTimestampCell,
disableFilters: true,
},
Expand Down Expand Up @@ -347,7 +349,7 @@ export function ProcessesTable({ initialTableSettings, renderActions }: Processe
[name, setFilterQ, setPageQ, setSortQ]
);

const excludeInFilter = ["info", "workflow"];
const excludeInFilter = ["info", "workflow_name"];
return (
<div key={name}>
<EuiPanel css={processesStyling} className="nwa-table" id={`${name}-processes`}>
Expand Down
14 changes: 7 additions & 7 deletions src/components/tables/cellRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,24 @@ export function renderTimestampCell({ cell }: { cell: Cell }): string | null {
}

export function renderPidCell({ cell }: { cell: Cell }) {
const pid: string = cell.value;
const processId: string = cell.value;
return (
<Link key={pid} onClick={(e) => e.stopPropagation()} to={`/processes/${pid}`} title={pid}>
{pid.slice(0, 8)}
<Link key={processId} onClick={(e) => e.stopPropagation()} to={`/processes/${processId}`} title={processId}>
{processId.slice(0, 8)}
</Link>
);
}

export function renderWorkflowNameCell({ cell }: { cell: Cell }) {
const name: string = cell.value;
const pid: string = cell.row.values.hasOwnProperty("pid") ? cell.row.values.pid : undefined;
const processId: string = cell.row.values.hasOwnProperty("processId") ? cell.row.values.processId : undefined;

return (
<Link
id={`process-detail-${pid}`}
key={pid}
id={`process-detail-${processId}`}
key={processId}
onClick={(e) => e.stopPropagation()}
to={`/processes/${pid}`}
to={`/processes/${processId}`}
title={name}
>
{name}
Expand Down
10 changes: 7 additions & 3 deletions src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ I18n.translations.en = {
assignee: "Assignee",
created_by: "Created by",
step: "Current step",
started: "Started",
last_modified: "Last updated",
started_at: "Started",
last_modified_at: "Last updated",
},
},
validations: {
Expand Down Expand Up @@ -405,7 +405,7 @@ I18n.translations.en = {
id: "Id",
started_at: "Started at",
status: "Status",
modified_at: "Modified at",
last_modified_at: "Modified at",
},
ims_service: {
id: "IMS service ID ({{id}})",
Expand Down Expand Up @@ -867,13 +867,17 @@ I18n.translations.en = {
description: "description...",
note: "notes...",
status: "status...",
lastStatus: "status...",
customer: "customer name...",
customer_id: "customer name...",
abbrev: "customer abbreviation...",
product: "product name...",
tag: "product tag...",
productTag: "product tag...",
creator: "creator..",
createdBy: "creator..",
workflow: "workflow name...",
workflowName: "workflow name...",
subscriptions: "description...",
target: "workflow target...",
subscription_id: "id",
Expand Down
14 changes: 7 additions & 7 deletions src/pages/ModifySubscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface IProps extends RouteComponentProps, WrappedComponentProps {

interface IState {
stepUserInput?: InputForm;
pid?: string;
processId?: string;
}

class ModifySubscription extends React.Component<IProps, IState> {
Expand All @@ -46,7 +46,7 @@ class ModifySubscription extends React.Component<IProps, IState> {
let promise = this.context.apiClient
.startProcess(workflowName, [{ subscription_id: subscriptionId }])
.then((res: { id: string }) => {
this.setState({ pid: res.id });
this.setState({ processId: res.id });
});
// @ts-ignore
this.context.apiClient.catchErrorStatus<FormNotCompleteResponse>(promise, 510, (json) => {
Expand All @@ -64,26 +64,26 @@ class ModifySubscription extends React.Component<IProps, IState> {
return this.context.apiClient
.startProcess(workflowName, [{ subscription_id: subscriptionId }, ...processInput])
.then((res: { id: string }) => {
this.setState({ pid: res.id });
this.setState({ processId: res.id });
});
};

render() {
const { stepUserInput, pid } = this.state;
const { stepUserInput, processId } = this.state;
const { subscriptionId, workflowName, intl } = this.props;

if (pid) {
if (processId) {
setFlash(
intl.formatMessage(
{ id: "process.flash.create_modify" },
{
name: intl.formatMessage({ id: `workflow.${workflowName}` }),
subscriptionId: subscriptionId,
pid: pid,
processId: processId,
}
)
);
return <Redirect to={`/processes/${pid}`} />;
return <Redirect to={`/processes/${processId}`} />;
}

if (!stepUserInput) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/NewProcess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function NewProcess(props: IProps) {
setFlash(
intl.formatMessage(
{ id: "process.flash.create_create" },
{ name: product.name, pid: process.id }
{ name: product.name, process_id: process.id }
)
);
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/NewTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class NewTask extends React.Component<WrappedComponentProps, IState> {
setFlash(
intl.formatMessage(
{ id: "task.flash.create" },
{ name: intl.formatMessage({ id: `workflow.${select_task}` }), pid: process.id }
{ name: intl.formatMessage({ id: `workflow.${select_task}` }), process_id: process.id }
)
);
});
Expand Down
8 changes: 4 additions & 4 deletions src/pages/ProcessDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function ProcessDetail({ match, query, setQuery }: IProps) {
onSuccess: (res) => {
setSubscriptionProcesses(res);
setLoaded(true);
if (process!.step !== "Done") {
if (process!.last_step !== "Done") {
}
},
}
Expand All @@ -113,7 +113,7 @@ function ProcessDetail({ match, query, setQuery }: IProps) {
};

const handleUpdateWebsocketProcess = (runningProcesses: WsProcessV2[]) => {
const localProcess = runningProcesses.find((p) => p.pid === match.params.id);
const localProcess = runningProcesses.find((p) => p.process_id === match.params.id);
if (wsProcess === localProcess || !localProcess) {
return;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ function ProcessDetail({ match, query, setQuery }: IProps) {
}
setObserver(localObserver);

if (autoScrollToLast && loaded && process!.step !== "Done") {
if (autoScrollToLast && loaded && process!.last_step !== "Done") {
console.log("Auto scroll enabled; scrolling to last");
const finished_steps = process?.steps.filter((step) => step.status !== "pending");
if (finished_steps) {
Expand Down Expand Up @@ -412,7 +412,7 @@ function ProcessDetail({ match, query, setQuery }: IProps) {
<EuiText>
<h3>
<FormattedMessage
id={`${processParam.is_task ? "task" : "process"}.workflow`}
id={`${processParam.is_task ? "task" : "process"}.workflow_name`}
values={{ name: processParam.workflow_name }}
/>
<br />
Expand Down
Loading

0 comments on commit cc6ef13

Please sign in to comment.