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 } from "~/store/resources/resources";
13 import { navigateTo } from "~/store/navigation/navigation-action";
14 import { loadDetailsPanel } from "~/store/details-panel/details-panel-action";
15 import { PanelDefaultView } from '~/components/panel-default-view/panel-default-view';
16 import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
17 import { SHARED_WITH_ME_PANEL_ID } from '~/store/shared-with-me-panel/shared-with-me-panel-actions';
19 type CssRules = "toolbar" | "button";
21 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
23 paddingBottom: theme.spacing.unit * 3,
27 marginLeft: theme.spacing.unit
31 interface SharedWithMePanelDataProps {
32 resources: ResourcesState;
35 type SharedWithMePanelProps = SharedWithMePanelDataProps & DispatchProp & WithStyles<CssRules>;
37 export const SharedWithMePanel = withStyles(styles)(
38 connect((state: RootState) => ({
39 resources: state.resources
41 class extends React.Component<SharedWithMePanelProps> {
43 return this.hasAnyTrashedResources()
45 id={SHARED_WITH_ME_PANEL_ID}
46 onRowClick={this.handleRowClick}
47 onRowDoubleClick={this.handleRowDoubleClick}
48 onContextMenu={this.handleContextMenu}
49 contextMenuColumn={false}
50 dataTableDefaultView={<DataTableDefaultView icon={ShareMeIcon} />} />
53 messages={['No shared items.']} />;
56 hasAnyTrashedResources = () => {
57 // TODO: implement check if there is anything in the trash,
58 // without taking pagination into the account
62 handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
63 // const resource = getResource<TrashableResource>(resourceUuid)(this.props.resources);
65 // this.props.dispatch<any>(openContextMenu(event, {
67 // uuid: resource.uuid,
68 // ownerUuid: resource.ownerUuid,
69 // isTrashed: resource.isTrashed,
70 // kind: resource.kind,
71 // menuKind: ContextMenuKind.TRASH
76 handleRowDoubleClick = (uuid: string) => {
77 this.props.dispatch<any>(navigateTo(uuid));
80 handleRowClick = (uuid: string) => {
81 this.props.dispatch(loadDetailsPanel(uuid));