X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/808b1f59d53a83c9ad456931c7e38f127b4d8342..f5e55e7a71f2fc2390d392af752c61b4d3135cb6:/src/components/data-explorer/data-explorer.tsx diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx index 9b099acb2c..9085b1f1f0 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -5,10 +5,8 @@ import * as React from 'react'; import { Grid, Paper, Toolbar, StyleRulesCallback, withStyles, Theme, WithStyles, TablePagination, IconButton } from '@material-ui/core'; import MoreVertIcon from "@material-ui/icons/MoreVert"; -import ContextMenu, { ContextMenuActionGroup, ContextMenuAction } from "../../components/context-menu/context-menu"; import ColumnSelector from "../../components/column-selector/column-selector"; import DataTable, { DataColumns, DataItem } from "../../components/data-table/data-table"; -import { mockAnchorFromMouseEvent } from "../../components/popover/helpers"; import { DataColumn } from "../../components/data-table/data-column"; import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters'; import SearchInput from '../search-input/search-input'; @@ -17,7 +15,6 @@ interface DataExplorerProps { items: T[]; itemsAvailable: number; columns: DataColumns; - contextActions: ContextMenuActionGroup[]; searchValue: string; rowsPerPage: number; rowsPerPageOptions?: number[]; @@ -26,32 +23,17 @@ interface DataExplorerProps { onRowClick: (item: T) => void; onRowDoubleClick: (item: T) => void; onColumnToggle: (column: DataColumn) => void; - onContextAction: (action: ContextMenuAction, item: T) => void; + onContextMenu: (event: React.MouseEvent, item: T) => void; onSortToggle: (column: DataColumn) => void; onFiltersChange: (filters: DataTableFilterItem[], column: DataColumn) => void; onChangePage: (page: number) => void; onChangeRowsPerPage: (rowsPerPage: number) => void; } -interface DataExplorerState { - contextMenu: { - anchorEl?: HTMLElement; - item?: T; - }; -} - -class DataExplorer extends React.Component & WithStyles, DataExplorerState> { - state: DataExplorerState = { - contextMenu: {} - }; +class DataExplorer extends React.Component & WithStyles> { render() { return -
@@ -68,8 +50,8 @@ class DataExplorer extends React.Component this.props.onRowClick(item)} + onContextMenu={this.props.onContextMenu} onRowDoubleClick={(_, item: T) => this.props.onRowDoubleClick(item)} - onRowContextMenu={this.openContextMenu} onFiltersChange={this.props.onFiltersChange} onSortToggle={this.props.onSortToggle} /> @@ -89,29 +71,6 @@ class DataExplorer extends React.Component; } - openContextMenu = (event: React.MouseEvent, item: T) => { - event.preventDefault(); - event.stopPropagation(); - this.setState({ - contextMenu: { - anchorEl: mockAnchorFromMouseEvent(event), - item - } - }); - } - - closeContextMenu = () => { - this.setState({ contextMenu: {} }); - } - - callAction = (action: ContextMenuAction) => { - const { item } = this.state.contextMenu; - this.closeContextMenu(); - if (item) { - this.props.onContextAction(action, item); - } - } - changePage = (event: React.MouseEvent | null, page: number) => { this.props.onChangePage(page); } @@ -122,21 +81,11 @@ class DataExplorer extends React.Component - this.openContextMenuTrigger(event, item)}> + this.props.onContextMenu(event, item)}> - openContextMenuTrigger = (event: React.MouseEvent, item: T) => { - event.preventDefault(); - this.setState({ - contextMenu: { - anchorEl: event.currentTarget, - item - } - }); - } - contextMenuColumn = { name: "Actions", selected: true,