X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/77af50a44c54ef12a1d7abb59a0e4cba4284e77e..c178bb7bacbb174f6b645e410323dbecd59e1a2c:/src/views/project-panel/project-panel.tsx diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index 6bfa61e032..2c895ee369 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -7,18 +7,21 @@ import { ProjectPanelItem } from './project-panel-item'; import { Grid, Typography, Button, Toolbar, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core'; import { formatDate, formatFileSize } from '../../common/formatters'; import DataExplorer from "../../views-components/data-explorer/data-explorer"; -import { DataColumn, toggleSortDirection } from '../../components/data-table/data-column'; -import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters'; import { ContextMenuAction } from '../../components/context-menu/context-menu'; import { DispatchProp, connect } from 'react-redux'; -import actions from "../../store/data-explorer/data-explorer-action"; import { DataColumns } from '../../components/data-table/data-table'; -import { ResourceKind } from "../../models/resource"; import { RouteComponentProps } from 'react-router'; import { RootState } from '../../store/store'; +import { ResourceKind } from '../../models/kinds'; +import { DataTableFilterItem } from '../../components/data-table-filters/data-table-filters'; +import { ContainerRequestState } from '../../models/container-request'; export const PROJECT_PANEL_ID = "projectPanel"; +export interface ProjectPanelFilter extends DataTableFilterItem { + type: ResourceKind | ContainerRequestState; +} + type ProjectPanelProps = { currentItemId: string, onItemClick: (item: ProjectPanelItem) => void, @@ -44,55 +47,21 @@ class ProjectPanel extends React.Component { ; + onContextAction={this.executeAction} />; ; } - componentDidMount() { - this.props.dispatch(actions.SET_COLUMNS({ id: PROJECT_PANEL_ID, columns })); - } - componentWillReceiveProps({ match, currentItemId }: ProjectPanelProps) { if (match.params.id !== currentItemId) { this.props.onItemRouteChange(match.params.id); } } - toggleColumn = (toggledColumn: DataColumn) => { - this.props.dispatch(actions.TOGGLE_COLUMN({ id: PROJECT_PANEL_ID, columnName: toggledColumn.name })); - } - - toggleSort = (column: DataColumn) => { - this.props.dispatch(actions.TOGGLE_SORT({ id: PROJECT_PANEL_ID, columnName: column.name })); - } - - changeFilters = (filters: DataTableFilterItem[], column: DataColumn) => { - this.props.dispatch(actions.SET_FILTERS({ id: PROJECT_PANEL_ID, columnName: column.name, filters })); - } - executeAction = (action: ContextMenuAction, item: ProjectPanelItem) => { alert(`Executing ${action.name} on ${item.name}`); } - search = (searchValue: string) => { - this.props.dispatch(actions.SET_SEARCH_VALUE({ id: PROJECT_PANEL_ID, searchValue })); - } - - changePage = (page: number) => { - this.props.dispatch(actions.SET_PAGE({ id: PROJECT_PANEL_ID, page })); - } - - changeRowsPerPage = (rowsPerPage: number) => { - this.props.dispatch(actions.SET_ROWS_PER_PAGE({ id: PROJECT_PANEL_ID, rowsPerPage })); - } - } type CssRules = "toolbar" | "button"; @@ -126,10 +95,13 @@ const renderName = (item: ProjectPanelItem) => const renderIcon = (item: ProjectPanelItem) => { switch (item.kind) { - case ResourceKind.PROJECT: + case ResourceKind.Project: return ; - case ResourceKind.COLLECTION: - return ; + case ResourceKind.Collection: + return ; + case ResourceKind.Process: + case ResourceKind.Workflow: + return ; default: return ; } @@ -150,17 +122,35 @@ const renderOwner = (owner: string) => {owner} ; -const renderType = (type: string) => - - {type} + + +const typeToLabel = (type: string) => { + switch (type) { + case ResourceKind.Collection: + return "Data collection"; + case ResourceKind.Project: + return "Project"; + case ResourceKind.Process: + return "Process"; + default: + return "Unknown"; + } +}; + +const renderType = (type: string) => { + return + {typeToLabel(type)} ; +}; const renderStatus = (item: ProjectPanelItem) => {item.status || "-"} ; -const columns: DataColumns = [{ + + +export const columns: DataColumns = [{ name: "Name", selected: true, sortDirection: "desc", @@ -169,17 +159,36 @@ const columns: DataColumns = [{ }, { name: "Status", selected: true, + filters: [{ + name: ContainerRequestState.Committed, + selected: true, + type: ContainerRequestState.Committed + }, { + name: ContainerRequestState.Final, + selected: true, + type: ContainerRequestState.Final + }, { + name: ContainerRequestState.Uncommitted, + selected: true, + type: ContainerRequestState.Uncommitted + }], render: renderStatus, width: "75px" }, { name: "Type", selected: true, filters: [{ - name: "Collection", - selected: true + name: typeToLabel(ResourceKind.Collection), + selected: true, + type: ResourceKind.Collection + }, { + name: typeToLabel(ResourceKind.Process), + selected: true, + type: ResourceKind.Process }, { - name: "Project", - selected: true + name: typeToLabel(ResourceKind.Project), + selected: true, + type: ResourceKind.Project }], render: item => renderType(item.kind), width: "125px"