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 { DataColumns } from 'components/data-table/data-table';
9 import { DataExplorer } from "views-components/data-explorer/data-explorer";
10 import { ProjectResource } from 'models/project';
11 import { SortDirection } from "components/data-table/data-column";
12 import { createTree } from "models/tree";
15 ResourceContainerUuid,
16 ResourceCreatedAtDate,
18 ResourceLastModifiedDate,
20 ResourceModifiedByUserUuid,
23 ResourceOwnerWithName,
24 ResourceParentProcess,
29 } from "views-components/data-explorer/renderers";
30 import { getInitialProcessStatusFilters, getInitialProcessTypeFilters } from "store/resource-type-filters/resource-type-filters";
31 import { SubprocessProgressBar } from "components/subprocess-progress-bar/subprocess-progress-bar";
32 import { connect } from "react-redux";
33 import { RootState } from "store/store";
34 import { getProjectPanelCurrentUuid } from "store/project-panel/project-panel-action";
35 import { getResource } from "store/resources/resources";
37 export enum ProjectPanelRunColumnNames {
42 PORTABLE_DATA_HASH = 'Portable Data Hash',
43 FILE_SIZE = 'File Size',
44 FILE_COUNT = 'File Count',
46 CONTAINER_UUID = 'Container UUID',
48 OUTPUT_UUID = 'Output UUID',
49 LOG_UUID = 'Log UUID',
50 PARENT_PROCESS = 'Parent Process UUID',
51 MODIFIED_BY_USER_UUID = 'Modified by User UUID',
53 CREATED_AT = 'Date Created',
54 LAST_MODIFIED = 'Last Modified',
55 TRASH_AT = 'Trash at',
56 DELETE_AT = 'Delete at',
59 export const projectPanelRunColumns: DataColumns<string, ProjectResource> = [
61 name: ProjectPanelRunColumnNames.NAME,
64 sort: { direction: SortDirection.NONE, field: 'name' },
65 filters: createTree(),
66 render: (uuid) => <ResourceName uuid={uuid} />,
69 name: ProjectPanelRunColumnNames.STATUS,
72 mutuallyExclusiveFilters: true,
73 filters: getInitialProcessStatusFilters(),
74 render: (uuid) => <ResourceStatus uuid={uuid} />,
77 name: ProjectPanelRunColumnNames.TYPE,
80 filters: getInitialProcessTypeFilters(),
81 render: (uuid) => <ResourceType uuid={uuid} />,
84 name: ProjectPanelRunColumnNames.OWNER,
87 filters: createTree(),
88 render: (uuid) => <ResourceOwnerWithName uuid={uuid} />,
91 name: ProjectPanelRunColumnNames.UUID,
94 filters: createTree(),
95 render: (uuid) => <ResourceUUID uuid={uuid} />,
98 name: ProjectPanelRunColumnNames.CONTAINER_UUID,
101 filters: createTree(),
102 render: (uuid) => <ResourceContainerUuid uuid={uuid} />,
105 name: ProjectPanelRunColumnNames.RUNTIME,
108 filters: createTree(),
109 render: (uuid) => <ContainerRunTime uuid={uuid} />,
112 name: ProjectPanelRunColumnNames.OUTPUT_UUID,
115 filters: createTree(),
116 render: (uuid) => <ResourceOutputUuid uuid={uuid} />,
119 name: ProjectPanelRunColumnNames.LOG_UUID,
122 filters: createTree(),
123 render: (uuid) => <ResourceLogUuid uuid={uuid} />,
126 name: ProjectPanelRunColumnNames.PARENT_PROCESS,
129 filters: createTree(),
130 render: (uuid) => <ResourceParentProcess uuid={uuid} />,
133 name: ProjectPanelRunColumnNames.MODIFIED_BY_USER_UUID,
136 filters: createTree(),
137 render: (uuid) => <ResourceModifiedByUserUuid uuid={uuid} />,
140 name: ProjectPanelRunColumnNames.CREATED_AT,
143 sort: { direction: SortDirection.NONE, field: 'createdAt' },
144 filters: createTree(),
145 render: (uuid) => <ResourceCreatedAtDate uuid={uuid} />,
148 name: ProjectPanelRunColumnNames.LAST_MODIFIED,
151 sort: { direction: SortDirection.DESC, field: 'modifiedAt' },
152 filters: createTree(),
153 render: (uuid) => <ResourceLastModifiedDate uuid={uuid} />,
156 name: ProjectPanelRunColumnNames.TRASH_AT,
159 sort: { direction: SortDirection.NONE, field: 'trashAt' },
160 filters: createTree(),
161 render: (uuid) => <ResourceTrashDate uuid={uuid} />,
164 name: ProjectPanelRunColumnNames.DELETE_AT,
167 sort: { direction: SortDirection.NONE, field: 'deleteAt' },
168 filters: createTree(),
169 render: (uuid) => <ResourceDeleteDate uuid={uuid} />,
173 const DEFAULT_VIEW_MESSAGES = ['No workflow runs found'];
175 interface ProjectPanelRunProps {
176 project?: ProjectResource;
177 paperClassName?: string;
178 onRowClick: (uuid: string) => void;
179 onRowDoubleClick: (uuid: string) => void;
180 onContextMenu: (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => void;
183 const mapStateToProps = (state: RootState): Pick<ProjectPanelRunProps, 'project'> => {
184 const projectUuid = getProjectPanelCurrentUuid(state) || "";
185 const project = getResource<ProjectResource>(projectUuid)(state.resources);
191 export const ProjectPanelRun = connect(mapStateToProps)((props: ProjectPanelRunProps) => {
193 id={PROJECT_PANEL_RUN_ID}
194 onRowClick={props.onRowClick}
195 onRowDoubleClick={props.onRowDoubleClick}
196 onContextMenu={props.onContextMenu}
197 contextMenuColumn={true}
198 defaultViewIcon={ProjectIcon}
199 defaultViewMessages={DEFAULT_VIEW_MESSAGES}
200 progressBar={<SubprocessProgressBar parentResource={props.project} dataExplorerId={PROJECT_PANEL_RUN_ID} />}
201 paperClassName={props.paperClassName}