Skip to content

Commit 7bbea66

Browse files
ohltylergithub-actions[bot]
authored andcommitted
Integrate with update timestamps (#115)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> (cherry picked from commit b3e0305)
1 parent 7ff6377 commit 7bbea66

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

common/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ export const GET_PRESET_WORKFLOWS_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH
3737
export const NEW_WORKFLOW_ID_URL = 'new';
3838
export const START_FROM_SCRATCH_WORKFLOW_NAME = 'Start From Scratch';
3939
export const DEFAULT_NEW_WORKFLOW_NAME = 'new_workflow';
40+
export const DATE_FORMAT_PATTERN = 'MM/DD/YY hh:mm A';
41+
export const EMPTY_FIELD_STRING = '--';

common/utils.ts

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import moment from 'moment';
67
import {
78
WorkspaceFlowState,
89
ReactFlowComponent,
@@ -13,6 +14,7 @@ import {
1314
ReactFlowEdge,
1415
TemplateFlows,
1516
WorkflowTemplate,
17+
DATE_FORMAT_PATTERN,
1618
} from './';
1719

1820
// TODO: implement this and remove hardcoded return values
@@ -91,3 +93,7 @@ export function validateWorkflowTemplate(
9193
): boolean {
9294
return true;
9395
}
96+
97+
export function toFormattedDate(timestampMillis: number): String {
98+
return moment(new Date(timestampMillis)).format(DATE_FORMAT_PATTERN);
99+
}

public/pages/workflows/workflow_list/columns.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55

66
import React from 'react';
77
import { EuiLink } from '@elastic/eui';
8-
import { PLUGIN_ID, Workflow } from '../../../../common';
8+
import {
9+
EMPTY_FIELD_STRING,
10+
PLUGIN_ID,
11+
Workflow,
12+
toFormattedDate,
13+
} from '../../../../common';
914

1015
export const columns = (actions: any[]) => [
1116
{
@@ -30,11 +35,19 @@ export const columns = (actions: any[]) => [
3035
field: 'lastUpdated',
3136
name: 'Last updated',
3237
sortable: true,
38+
render: (lastUpdated: number) =>
39+
lastUpdated !== undefined
40+
? toFormattedDate(lastUpdated)
41+
: EMPTY_FIELD_STRING,
3342
},
3443
{
3544
field: 'lastLaunched',
3645
name: 'Last launched',
3746
sortable: true,
47+
render: (lastLaunched: number) =>
48+
lastLaunched !== undefined
49+
? toFormattedDate(lastLaunched)
50+
: EMPTY_FIELD_STRING,
3851
},
3952
{
4053
name: 'Actions',

server/routes/helpers.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ function toWorkflowObj(workflowHit: any): Workflow {
3030
description: hitSource.description || '',
3131
version: hitSource.version,
3232
workflows: hitSource.workflows,
33-
// TODO: this needs to be persisted by backend. Tracking issue:
34-
// https://github.com/opensearch-project/flow-framework/issues/548
35-
lastUpdated: 1234,
33+
lastUpdated: hitSource.last_updated_time,
34+
lastLaunched: hitSource.last_provisioned_time,
3635
} as Workflow;
3736
}
3837

@@ -57,9 +56,6 @@ export function getWorkflowsFromResponses(
5756
...workflowDict[workflowHit._id],
5857
// @ts-ignore
5958
state: WORKFLOW_STATE[workflowState],
60-
// TODO: this needs to be persisted by backend. Tracking issue:
61-
// https://github.com/opensearch-project/flow-framework/issues/548
62-
lastLaunched: 1234,
6359
};
6460
}
6561
});

0 commit comments

Comments
 (0)