1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
7 import { DataExplorer } from "views-components/data-explorer/data-explorer";
8 import { connect, DispatchProp } from 'react-redux';
9 import { RootState } from 'store/store';
10 import { ArvadosTheme } from 'common/custom-theme';
11 import { ShareMeIcon } from 'components/icon/icon';
12 import { ResourcesState, getResource } from 'store/resources/resources';
13 import { navigateTo } from "store/navigation/navigation-action";
14 import { loadDetailsPanel } from "store/details-panel/details-panel-action";
15 import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view';
16 import { SHARED_WITH_ME_PANEL_ID } from 'store/shared-with-me-panel/shared-with-me-panel-actions';
19 resourceUuidToContextMenuKind
20 } from 'store/context-menu/context-menu-actions';
21 import { GroupContentsResource } from 'services/groups-service/groups-service';
23 type CssRules = "toolbar" | "button";
25 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
27 paddingBottom: theme.spacing.unit * 3,
31 marginLeft: theme.spacing.unit
35 interface SharedWithMePanelDataProps {
36 resources: ResourcesState;
40 type SharedWithMePanelProps = SharedWithMePanelDataProps & DispatchProp & WithStyles<CssRules>;
42 export const SharedWithMePanel = withStyles(styles)(
43 connect((state: RootState) => ({
44 resources: state.resources,
45 userUuid: state.auth.user!.uuid,
47 class extends React.Component<SharedWithMePanelProps> {
50 id={SHARED_WITH_ME_PANEL_ID}
51 onRowClick={this.handleRowClick}
52 onRowDoubleClick={this.handleRowDoubleClick}
53 onContextMenu={this.handleContextMenu}
54 contextMenuColumn={false}
55 dataTableDefaultView={<DataTableDefaultView icon={ShareMeIcon} />} />;
58 handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
59 const { resources } = this.props;
60 const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
61 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
62 if (menuKind && resource) {
63 this.props.dispatch<any>(openContextMenu(event, {
66 ownerUuid: resource.ownerUuid,
67 isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
72 this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
75 handleRowDoubleClick = (uuid: string) => {
76 this.props.dispatch<any>(navigateTo(uuid));
79 handleRowClick = (uuid: string) => {
80 this.props.dispatch<any>(loadDetailsPanel(uuid));