1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
7 import { WorkflowIcon } from '~/components/icon/icon';
8 import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
9 import { WORKFLOW_PANEL_ID } from '~/store/workflow-panel/workflow-panel-actions';
11 ResourceLastModifiedDate,
13 ResourceWorkflowStatus,
15 } from "~/views-components/data-explorer/renderers";
16 import { SortDirection } from '~/components/data-table/data-column';
17 import { DataColumns } from '~/components/data-table/data-table';
18 import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
19 import { Grid, Paper } from '@material-ui/core';
20 import { WorkflowDetailsCard } from './workflow-description-card';
21 import { WorkflowResource } from '../../models/workflow';
23 export enum WorkflowPanelColumnNames {
25 AUTHORISATION = "Authorisation",
26 LAST_MODIFIED = "Last modified",
30 export interface WorkflowPanelFilter extends DataTableFilterItem {
34 export interface WorkflowPanelDataProps {
35 workflow?: WorkflowResource;
38 export interface WorfklowPanelActionProps {
39 handleRowDoubleClick: (workflowUuid: string) => void;
40 handleRowClick: (workflowUuid: string) => void;
43 export type WorkflowPanelProps = WorkflowPanelDataProps & WorfklowPanelActionProps;
45 export enum ResourceStatus {
51 const resourceStatus = (type: string) => {
53 case ResourceStatus.PUBLIC:
55 case ResourceStatus.PRIVATE:
57 case ResourceStatus.SHARED:
64 export const workflowPanelColumns: DataColumns<string, WorkflowPanelFilter> = [
66 name: WorkflowPanelColumnNames.NAME,
69 sortDirection: SortDirection.ASC,
71 render: (uuid: string) => <RosurceWorkflowName uuid={uuid} />
74 name: WorkflowPanelColumnNames.AUTHORISATION,
79 name: resourceStatus(ResourceStatus.PUBLIC),
81 type: ResourceStatus.PUBLIC
84 name: resourceStatus(ResourceStatus.PRIVATE),
86 type: ResourceStatus.PRIVATE
89 name: resourceStatus(ResourceStatus.SHARED),
91 type: ResourceStatus.SHARED
94 render: (uuid: string) => <ResourceWorkflowStatus uuid={uuid} />,
97 name: WorkflowPanelColumnNames.LAST_MODIFIED,
100 sortDirection: SortDirection.NONE,
102 render: (uuid: string) => <ResourceLastModifiedDate uuid={uuid} />
109 render: (uuid: string) => <ResourceShare uuid={uuid} />
113 export const WorkflowPanelView = (props: WorkflowPanelProps) => {
114 return <Grid container spacing={16} style={{minHeight: '500px'}}>
117 id={WORKFLOW_PANEL_ID}
118 onRowClick={props.handleRowClick}
119 onRowDoubleClick={props.handleRowDoubleClick}
120 contextMenuColumn={false}
121 onContextMenu={e => e}
122 dataTableDefaultView={<DataTableDefaultView icon={WorkflowIcon} />} />
125 <Paper style={{ height: '100%' }}>
126 <WorkflowDetailsCard workflow={props.workflow} />