Skip to content

Commit

Permalink
Integrate with update timestamps
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Mar 26, 2024
1 parent 83835c2 commit ae7920a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ export const GET_PRESET_WORKFLOWS_NODE_API_PATH = `${BASE_WORKFLOW_NODE_API_PATH
export const NEW_WORKFLOW_ID_URL = 'new';
export const START_FROM_SCRATCH_WORKFLOW_NAME = 'Start From Scratch';
export const DEFAULT_NEW_WORKFLOW_NAME = 'new_workflow';
export const DATE_FORMAT_PATTERN = 'MM/DD/YY hh:mm A';
export const EMPTY_FIELD_STRING = '--';
6 changes: 6 additions & 0 deletions common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import moment from 'moment';
import {
WorkspaceFlowState,
ReactFlowComponent,
Expand All @@ -13,6 +14,7 @@ import {
ReactFlowEdge,
TemplateFlows,
WorkflowTemplate,
DATE_FORMAT_PATTERN,
} from './';

// TODO: implement this and remove hardcoded return values
Expand Down Expand Up @@ -91,3 +93,7 @@ export function validateWorkflowTemplate(
): boolean {
return true;
}

export function toFormattedDate(timestampMillis: number): String {
return moment(new Date(timestampMillis)).format(DATE_FORMAT_PATTERN);
}
15 changes: 14 additions & 1 deletion public/pages/workflows/workflow_list/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

import React from 'react';
import { EuiLink } from '@elastic/eui';
import { PLUGIN_ID, Workflow } from '../../../../common';
import {
EMPTY_FIELD_STRING,
PLUGIN_ID,
Workflow,
toFormattedDate,
} from '../../../../common';

export const columns = (actions: any[]) => [
{
Expand All @@ -30,11 +35,19 @@ export const columns = (actions: any[]) => [
field: 'lastUpdated',
name: 'Last updated',
sortable: true,
render: (lastUpdated: number) =>
lastUpdated !== undefined
? toFormattedDate(lastUpdated)
: EMPTY_FIELD_STRING,
},
{
field: 'lastLaunched',
name: 'Last launched',
sortable: true,
render: (lastLaunched: number) =>
lastLaunched !== undefined
? toFormattedDate(lastLaunched)
: EMPTY_FIELD_STRING,
},
{
name: 'Actions',
Expand Down
8 changes: 2 additions & 6 deletions server/routes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ function toWorkflowObj(workflowHit: any): Workflow {
description: hitSource.description || '',
version: hitSource.version,
workflows: hitSource.workflows,
// TODO: this needs to be persisted by backend. Tracking issue:
// https://github.com/opensearch-project/flow-framework/issues/548
lastUpdated: 1234,
lastUpdated: hitSource.last_updated_time,
lastLaunched: hitSource.last_provisioned_time,
} as Workflow;
}

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

0 comments on commit ae7920a

Please sign in to comment.