1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import withStyles from '@mui/styles/withStyles';
7 import { DispatchProp, connect } from 'react-redux';
8 import { RouteComponentProps } from 'react-router';
9 import { WithStyles } from '@mui/styles';
10 import { CustomStyleRulesCallback } from 'common/custom-theme';
11 import { RootState } from 'store/store';
12 import { Resource } from 'models/resource';
13 import { ResourcesState, getResource } from 'store/resources/resources';
14 import { loadDetailsPanel } from 'store/details-panel/details-panel-action';
15 import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions';
16 import { navigateTo } from 'store/navigation/navigation-action';
17 import { getProperty } from 'store/properties/properties';
18 import { PROJECT_PANEL_CURRENT_UUID } from 'store/project-panel/project-panel-action';
19 import { ArvadosTheme } from 'common/custom-theme';
20 import { GroupContentsResource } from 'services/groups-service/groups-service';
21 import { GroupClass, GroupResource } from 'models/group';
22 import { CollectionResource } from 'models/collection';
23 import { resourceIsFrozen } from 'common/frozen-resources';
24 import { deselectAllOthers, toggleOne } from 'store/multiselect/multiselect-actions';
25 import { DetailsCardRoot } from 'views-components/details-card/details-card-root';
26 import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view';
27 import { ProjectPanelData } from './project-panel-data';
28 import { ProjectPanelRun } from './project-panel-run';
30 type CssRules = 'root' | 'button' | 'mpvRoot' | 'dataExplorer';
32 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
36 flexDirection: 'column',
39 marginLeft: theme.spacing(1),
44 flexDirection: 'column',
54 const panelsData: MPVPanelState[] = [
55 { name: "Data", visible: true },
56 { name: "Workflow Runs", visible: false },
59 interface ProjectPanelDataProps {
60 currentItemId: string;
61 resources: ResourcesState;
62 project: GroupResource;
65 dataExplorerItems: any;
69 type ProjectPanelProps = ProjectPanelDataProps & DispatchProp & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
71 const mapStateToProps = (state: RootState) => {
72 const currentItemId = getProperty<string>(PROJECT_PANEL_CURRENT_UUID)(state.properties);
73 const project = getResource<GroupResource>(currentItemId || "")(state.resources);
77 resources: state.resources,
78 userUuid: state.auth.user!.uuid,
82 export const ProjectPanel = withStyles(styles)(
83 connect(mapStateToProps)(
84 class extends React.Component<ProjectPanelProps> {
87 const { classes } = this.props;
88 return <div data-cy='project-panel' className={classes.root}>
91 className={classes.mpvRoot}
93 panelStates={panelsData}
95 justify-content="flex-start"
101 data-cy="process-data"
102 className={classes.dataExplorer}>
104 onRowClick={this.handleRowClick}
105 onRowDoubleClick={this.handleRowDoubleClick}
106 onContextMenu={this.handleContextMenu}
112 data-cy="process-run"
113 className={classes.dataExplorer}>
115 onRowClick={this.handleRowClick}
116 onRowDoubleClick={this.handleRowDoubleClick}
117 onContextMenu={this.handleContextMenu}
124 isCurrentItemChild = (resource: Resource) => {
125 return resource.ownerUuid === this.props.currentItemId;
128 handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
129 const { resources, isAdmin } = this.props;
130 const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
131 // When viewing the contents of a filter group, all contents should be treated as read only.
132 let readonly = false;
133 const project = getResource<GroupResource>(this.props.currentItemId)(resources);
134 if (project && project.groupClass === GroupClass.FILTER) {
138 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid, readonly));
139 if (menuKind && resource) {
140 this.props.dispatch<any>(
141 openContextMenu(event, {
144 ownerUuid: resource.ownerUuid,
145 isTrashed: 'isTrashed' in resource ? resource.isTrashed : false,
149 isFrozen: resourceIsFrozen(resource, resources),
150 description: resource.description,
151 storageClassesDesired: (resource as CollectionResource).storageClassesDesired,
152 properties: 'properties' in resource ? resource.properties : {},
156 this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
159 handleRowDoubleClick = (uuid: string) => {
160 this.props.dispatch<any>(navigateTo(uuid));
163 handleRowClick = (uuid: string) => {
164 this.props.dispatch<any>(toggleOne(uuid))
165 this.props.dispatch<any>(deselectAllOthers(uuid))
166 this.props.dispatch<any>(loadDetailsPanel(uuid));