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 } from '~/store/context-menu/context-menu-actions';
18 import { GroupResource } from '~/models/group';
19 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
21 type CssRules = "toolbar" | "button";
23 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
25 paddingBottom: theme.spacing.unit * 3,
29 marginLeft: theme.spacing.unit
33 interface SharedWithMePanelDataProps {
34 resources: ResourcesState;
37 type SharedWithMePanelProps = SharedWithMePanelDataProps & DispatchProp & WithStyles<CssRules>;
39 export const SharedWithMePanel = withStyles(styles)(
40 connect((state: RootState) => ({
41 resources: state.resources
43 class extends React.Component<SharedWithMePanelProps> {
46 id={SHARED_WITH_ME_PANEL_ID}
47 onRowClick={this.handleRowClick}
48 onRowDoubleClick={this.handleRowDoubleClick}
49 onContextMenu={this.handleContextMenu}
50 contextMenuColumn={false}
51 dataTableDefaultView={<DataTableDefaultView icon={ShareMeIcon} />} />;
54 handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
55 const resource = getResource<GroupResource>(resourceUuid)(this.props.resources);
57 this.props.dispatch<any>(openContextMenu(event, {
60 ownerUuid: resource.ownerUuid,
61 isTrashed: resource.isTrashed,
63 menuKind: ContextMenuKind.PROJECT,
68 handleRowDoubleClick = (uuid: string) => {
69 this.props.dispatch<any>(navigateTo(uuid));
72 handleRowClick = (uuid: string) => {
73 this.props.dispatch(loadDetailsPanel(uuid));