1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { LINK_PANEL_ID } from 'store/link-panel/link-panel-actions';
7 import { DataExplorer } from 'views-components/data-explorer/data-explorer';
8 import { SortDirection } from 'components/data-table/data-column';
9 import { DataColumns } from 'components/data-table/data-table';
10 import { ResourcesState } from 'store/resources/resources';
11 import { ShareMeIcon } from 'components/icon/icon';
12 import { createTree } from 'models/tree';
14 ResourceLinkUuid, ResourceLinkHead, ResourceLinkTail,
15 ResourceLinkClass, ResourceLinkName }
16 from 'views-components/data-explorer/renderers';
17 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
18 import { ArvadosTheme } from 'common/custom-theme';
19 import { LinkResource } from 'models/link';
21 type CssRules = "root";
23 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
29 export enum LinkPanelColumnNames {
31 LINK_CLASS = "Link Class",
37 export const linkPanelColumns: DataColumns<string, LinkResource> = [
39 name: LinkPanelColumnNames.NAME,
42 sort: {direction: SortDirection.NONE, field: "name"},
43 filters: createTree(),
44 render: uuid => <ResourceLinkName uuid={uuid} />
47 name: LinkPanelColumnNames.LINK_CLASS,
50 filters: createTree(),
51 render: uuid => <ResourceLinkClass uuid={uuid} />
54 name: LinkPanelColumnNames.TAIL,
57 filters: createTree(),
58 render: uuid => <ResourceLinkTail uuid={uuid} />
61 name: LinkPanelColumnNames.HEAD,
64 filters: createTree(),
65 render: uuid => <ResourceLinkHead uuid={uuid} />
68 name: LinkPanelColumnNames.UUID,
71 filters: createTree(),
72 render: uuid => <ResourceLinkUuid uuid={uuid} />
76 export interface LinkPanelRootDataProps {
77 resources: ResourcesState;
80 export interface LinkPanelRootActionProps {
81 onItemClick: (item: string) => void;
82 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
83 onItemDoubleClick: (item: string) => void;
86 export type LinkPanelRootProps = LinkPanelRootDataProps & LinkPanelRootActionProps & WithStyles<CssRules>;
88 export const LinkPanelRoot = withStyles(styles)((props: LinkPanelRootProps) => {
89 return <div className={props.classes.root}><DataExplorer
91 onRowClick={props.onItemClick}
92 onRowDoubleClick={props.onItemDoubleClick}
93 onContextMenu={props.onContextMenu}
94 contextMenuColumn={true}
97 defaultViewIcon={ShareMeIcon}
98 defaultViewMessages={['Your link list is empty.']} />