From: Daniel Kos Date: Mon, 3 Sep 2018 15:17:26 +0000 (+0200) Subject: Add restore icon in trash panel X-Git-Tag: 1.3.0~121^2~2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/ec00e13345fd6731287124ee776e0e4892c1cf13 Add restore icon in trash panel Feature #13828 Arvados-DCO-1.1-Signed-off-by: Daniel Kos --- diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx index af14db9c..ea400b10 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -48,6 +48,7 @@ interface DataExplorerDataProps { page: number; defaultIcon: IconType; defaultMessages: string[]; + contextMenuColumn: boolean; } interface DataExplorerActionProps { @@ -95,7 +96,7 @@ export const DataExplorer = withStyles(styles)( onRowClick(item)} onContextMenu={onContextMenu} @@ -142,7 +143,7 @@ export const DataExplorer = withStyles(styles)( - contextMenuColumn = { + contextMenuColumn: DataColumn = { name: "Actions", selected: true, configurable: false, diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx index 86a1a68c..2af70d84 100644 --- a/src/components/icon/icon.tsx +++ b/src/components/icon/icon.tsx @@ -32,7 +32,7 @@ import Person from '@material-ui/icons/Person'; import PersonAdd from '@material-ui/icons/PersonAdd'; import PlayArrow from '@material-ui/icons/PlayArrow'; import RateReview from '@material-ui/icons/RateReview'; -import RestoreFromTrash from '@material-ui/icons/RestoreFromTrash'; +import RestoreFromTrash from '@material-ui/icons/History'; import Search from '@material-ui/icons/Search'; import SettingsApplications from '@material-ui/icons/SettingsApplications'; import Star from '@material-ui/icons/Star'; diff --git a/src/views/favorite-panel/favorite-panel.tsx b/src/views/favorite-panel/favorite-panel.tsx index b915f980..003a319b 100644 --- a/src/views/favorite-panel/favorite-panel.tsx +++ b/src/views/favorite-panel/favorite-panel.tsx @@ -176,7 +176,8 @@ export const FavoritePanel = withStyles(styles)( onRowDoubleClick={this.props.onItemDoubleClick} onContextMenu={this.props.onContextMenu} defaultIcon={FavoriteIcon} - defaultMessages={['Your favorites list is empty.']} />; + defaultMessages={['Your favorites list is empty.']} + contextMenuColumn={true}/>; } } ) diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index d3b0474b..cfdeec99 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -183,7 +183,8 @@ export const ProjectPanel = withStyles(styles)( onRowDoubleClick={this.handleRowDoubleClick} onContextMenu={this.handleContextMenu} defaultIcon={ProjectIcon} - defaultMessages={['Your project is empty.', 'Please create a project or create a collection and upload a data.']} /> + defaultMessages={['Your project is empty.', 'Please create a project or create a collection and upload a data.']} + contextMenuColumn={true}/> ; } diff --git a/src/views/trash-panel/trash-panel.tsx b/src/views/trash-panel/trash-panel.tsx index 49226560..56724eab 100644 --- a/src/views/trash-panel/trash-panel.tsx +++ b/src/views/trash-panel/trash-panel.tsx @@ -3,7 +3,7 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core'; +import { IconButton, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core'; import { DataExplorer } from "~/views-components/data-explorer/data-explorer"; import { DispatchProp, connect } from 'react-redux'; import { DataColumns } from '~/components/data-table/data-table'; @@ -13,13 +13,14 @@ import { SortDirection } from '~/components/data-table/data-column'; import { ResourceKind, TrashableResource } from '~/models/resource'; import { resourceLabel } from '~/common/labels'; import { ArvadosTheme } from '~/common/custom-theme'; -import { TrashIcon } from '~/components/icon/icon'; +import { RestoreFromTrashIcon, TrashIcon } from '~/components/icon/icon'; import { TRASH_PANEL_ID } from "~/store/trash-panel/trash-panel-action"; import { getProperty } from "~/store/properties/properties"; import { PROJECT_PANEL_CURRENT_UUID } from "~/store/project-panel/project-panel-action"; import { openContextMenu, resourceKindToContextMenuKind } from "~/store/context-menu/context-menu-actions"; import { getResource, ResourcesState } from "~/store/resources/resources"; import { + renderDate, ResourceDeleteDate, ResourceFileSize, ResourceName, @@ -28,6 +29,8 @@ import { } from "~/views-components/data-explorer/renderers"; import { navigateTo } from "~/store/navigation/navigation-action"; import { loadDetailsPanel } from "~/store/details-panel/details-panel-action"; +import { toggleCollectionTrashed, toggleProjectTrashed } from "~/store/trash/trash-actions"; +import { Dispatch } from "redux"; type CssRules = "toolbar" | "button"; @@ -53,6 +56,31 @@ export interface TrashPanelFilter extends DataTableFilterItem { type: ResourceKind; } +export const ResourceRestore = + connect((state: RootState, props: { uuid: string, dispatch?: Dispatch }) => { + const resource = getResource(props.uuid)(state.resources); + return { resource, dispatch: props.dispatch }; + })((props: { resource?: TrashableResource, dispatch?: Dispatch }) => + { + if (props.resource && props.dispatch) { + const ctxRes = { + name: '', + uuid: props.resource.uuid, + isTrashed: props.resource.isTrashed, + ownerUuid: props.resource.ownerUuid + }; + + if (props.resource.kind === ResourceKind.PROJECT) { + props.dispatch(toggleProjectTrashed(ctxRes)); + } else if (props.resource.kind === ResourceKind.COLLECTION) { + props.dispatch(toggleCollectionTrashed(ctxRes)); + } + } + }}> + + + ); + export const trashPanelColumns: DataColumns = [ { name: TrashPanelColumnNames.NAME, @@ -115,6 +143,15 @@ export const trashPanelColumns: DataColumns = [ render: uuid => , width: "50px" }, + { + name: '', + selected: true, + configurable: false, + sortDirection: SortDirection.NONE, + filters: [], + render: uuid => , + width: "50px" + } ]; interface TrashPanelDataProps { @@ -137,7 +174,8 @@ export const TrashPanel = withStyles(styles)( onRowDoubleClick={this.handleRowDoubleClick} onContextMenu={this.handleContextMenu} defaultIcon={TrashIcon} - defaultMessages={['Your trash list is empty.']}/> + defaultMessages={['Your trash list is empty.']} + contextMenuColumn={false}/> ; }