1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as 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';
17 import { openContextMenu, resourceKindToContextMenuKind } from '~/store/context-menu/context-menu-actions';
18 import { GroupResource } from '~/models/group';
20 type CssRules = "toolbar" | "button";
22 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
24 paddingBottom: theme.spacing.unit * 3,
28 marginLeft: theme.spacing.unit
32 interface SharedWithMePanelDataProps {
33 resources: ResourcesState;
37 type SharedWithMePanelProps = SharedWithMePanelDataProps & DispatchProp & WithStyles<CssRules>;
39 export const SharedWithMePanel = withStyles(styles)(
40 connect((state: RootState) => ({
41 resources: state.resources,
42 isAdmin: state.auth.user!.isAdmin
44 class extends React.Component<SharedWithMePanelProps> {
47 id={SHARED_WITH_ME_PANEL_ID}
48 onRowClick={this.handleRowClick}
49 onRowDoubleClick={this.handleRowDoubleClick}
50 onContextMenu={this.handleContextMenu}
51 contextMenuColumn={false}
52 dataTableDefaultView={<DataTableDefaultView icon={ShareMeIcon} />} />;
55 handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
56 const menuKind = resourceKindToContextMenuKind(resourceUuid, this.props.isAdmin);
57 const resource = getResource<GroupResource>(resourceUuid)(this.props.resources);
58 if (menuKind && resource) {
59 this.props.dispatch<any>(openContextMenu(event, {
62 ownerUuid: resource.ownerUuid,
63 isTrashed: resource.isTrashed,
68 this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
71 handleRowDoubleClick = (uuid: string) => {
72 this.props.dispatch<any>(navigateTo(uuid));
75 handleRowClick = (uuid: string) => {
76 this.props.dispatch(loadDetailsPanel(uuid));