Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with workflow timestamp fields #115

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading