1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { ProjectIcon } from "components/icon/icon";
7 import { PROJECT_PANEL_RUN_ID } from "store/project-panel/project-panel-action-bind";
8 import { DataExplorer } from "views-components/data-explorer/data-explorer";
9 import { ProjectResource } from 'models/project';
10 import { DataColumns, SortDirection } from "components/data-table/data-column";
11 import { createTree } from "models/tree";
14 ResourceContainerUuid,
15 ResourceCreatedAtDate,
17 ResourceLastModifiedDate,
19 ResourceModifiedByUserUuid,
22 ResourceOwnerWithName,
23 ResourceParentProcess,
28 } from "views-components/data-explorer/renderers";
29 import { getInitialProcessStatusFilters, getInitialProcessTypeFilters } from "store/resource-type-filters/resource-type-filters";
30 import { SubprocessProgressBar } from "components/subprocess-progress-bar/subprocess-progress-bar";
31 import { connect } from "react-redux";
32 import { RootState } from "store/store";
33 import { getProjectPanelCurrentUuid } from "store/project-panel/project-panel-action";
34 import { getResource } from "store/resources/resources";
36 export enum ProjectPanelRunColumnNames {
41 PORTABLE_DATA_HASH = 'Portable Data Hash',
42 FILE_SIZE = 'File Size',
43 FILE_COUNT = 'File Count',
45 CONTAINER_UUID = 'Container UUID',
47 OUTPUT_UUID = 'Output UUID',
48 LOG_UUID = 'Log UUID',
49 PARENT_PROCESS = 'Parent Process UUID',
50 MODIFIED_BY_USER_UUID = 'Modified by User UUID',
52 CREATED_AT = 'Date Created',
53 LAST_MODIFIED = 'Last Modified',
54 TRASH_AT = 'Trash at',
55 DELETE_AT = 'Delete at',
58 export const projectPanelRunColumns: DataColumns<string, ProjectResource> = [
60 name: ProjectPanelRunColumnNames.NAME,
63 sort: { direction: SortDirection.NONE, field: 'name' },
64 filters: createTree(),
65 render: (uuid) => <ResourceName uuid={uuid} />,
68 name: ProjectPanelRunColumnNames.STATUS,
71 mutuallyExclusiveFilters: true,
72 filters: getInitialProcessStatusFilters(),
73 render: (uuid) => <ResourceStatus uuid={uuid} />,
76 name: ProjectPanelRunColumnNames.TYPE,
79 filters: getInitialProcessTypeFilters(),
80 render: (uuid) => <ResourceType uuid={uuid} />,
83 name: ProjectPanelRunColumnNames.OWNER,
86 filters: createTree(),
87 render: (uuid) => <ResourceOwnerWithName uuid={uuid} />,
90 name: ProjectPanelRunColumnNames.UUID,
93 filters: createTree(),
94 render: (uuid) => <ResourceUUID uuid={uuid} />,
97 name: ProjectPanelRunColumnNames.CONTAINER_UUID,
100 filters: createTree(),
101 render: (uuid) => <ResourceContainerUuid uuid={uuid} />,
104 name: ProjectPanelRunColumnNames.RUNTIME,
107 filters: createTree(),
108 render: (uuid) => <ContainerRunTime uuid={uuid} />,
111 name: ProjectPanelRunColumnNames.OUTPUT_UUID,
114 filters: createTree(),
115 render: (uuid) => <ResourceOutputUuid uuid={uuid} />,
118 name: ProjectPanelRunColumnNames.LOG_UUID,
121 filters: createTree(),
122 render: (uuid) => <ResourceLogUuid uuid={uuid} />,
125 name: ProjectPanelRunColumnNames.PARENT_PROCESS,
128 filters: createTree(),
129 render: (uuid) => <ResourceParentProcess uuid={uuid} />,
132 name: ProjectPanelRunColumnNames.MODIFIED_BY_USER_UUID,
135 filters: createTree(),
136 render: (uuid) => <ResourceModifiedByUserUuid uuid={uuid} />,
139 name: ProjectPanelRunColumnNames.CREATED_AT,
142 sort: { direction: SortDirection.NONE, field: 'createdAt' },
143 filters: createTree(),
144 render: (uuid) => <ResourceCreatedAtDate uuid={uuid} />,
147 name: ProjectPanelRunColumnNames.LAST_MODIFIED,
150 sort: { direction: SortDirection.DESC, field: 'modifiedAt' },
151 filters: createTree(),
152 render: (uuid) => <ResourceLastModifiedDate uuid={uuid} />,
155 name: ProjectPanelRunColumnNames.TRASH_AT,
158 sort: { direction: SortDirection.NONE, field: 'trashAt' },
159 filters: createTree(),
160 render: (uuid) => <ResourceTrashDate uuid={uuid} />,
163 name: ProjectPanelRunColumnNames.DELETE_AT,
166 sort: { direction: SortDirection.NONE, field: 'deleteAt' },
167 filters: createTree(),
168 render: (uuid) => <ResourceDeleteDate uuid={uuid} />,
172 const DEFAULT_VIEW_MESSAGES = ['No workflow runs found'];
174 interface ProjectPanelRunProps {
175 project?: ProjectResource;
176 paperClassName?: string;
177 onRowClick: (uuid: string) => void;
178 onRowDoubleClick: (uuid: string) => void;
179 onContextMenu: (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => void;
182 const mapStateToProps = (state: RootState): Pick<ProjectPanelRunProps, 'project'> => {
183 const projectUuid = getProjectPanelCurrentUuid(state) || "";
184 const project = getResource<ProjectResource>(projectUuid)(state.resources);
190 export const ProjectPanelRun = connect(mapStateToProps)((props: ProjectPanelRunProps) => {
192 id={PROJECT_PANEL_RUN_ID}
193 onRowClick={props.onRowClick}
194 onRowDoubleClick={props.onRowDoubleClick}
195 onContextMenu={props.onContextMenu}
196 contextMenuColumn={true}
197 defaultViewIcon={ProjectIcon}
198 defaultViewMessages={DEFAULT_VIEW_MESSAGES}
199 progressBar={<SubprocessProgressBar parentResource={props.project} dataExplorerId={PROJECT_PANEL_RUN_ID} />}
200 paperClassName={props.paperClassName}