X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/98eba2bbc83b8d4bbce837f75924dbaed2664519..07bfbbb8c513acfd77f7b6db89d223dbb464f5b0:/src/views/trash-panel/trash-panel.tsx

diff --git a/src/views/trash-panel/trash-panel.tsx b/src/views/trash-panel/trash-panel.tsx
index e627f4f2..3173876b 100644
--- a/src/views/trash-panel/trash-panel.tsx
+++ b/src/views/trash-panel/trash-panel.tsx
@@ -11,7 +11,6 @@ import { RootState } from '~/store/store';
 import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
 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 { RestoreFromTrashIcon, TrashIcon } from '~/components/icon/icon';
 import { TRASH_PANEL_ID } from "~/store/trash-panel/trash-panel-action";
@@ -31,8 +30,11 @@ import { loadDetailsPanel } from "~/store/details-panel/details-panel-action";
 import { toggleTrashed } from "~/store/trash/trash-actions";
 import { ContextMenuKind } from "~/views-components/context-menu/context-menu";
 import { Dispatch } from "redux";
-import { PanelDefaultView } from '~/components/panel-default-view/panel-default-view';
 import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
+import { createTree } from '~/models/tree';
+import {
+    getTrashPanelTypeFilters
+} from '~/store/resource-type-filters/resource-type-filters';
 
 type CssRules = "toolbar" | "button";
 
@@ -64,7 +66,7 @@ export const ResourceRestore =
         return { resource, dispatch: props.dispatch };
     })((props: { resource?: TrashableResource, dispatch?: Dispatch<any> }) =>
         <Tooltip title="Restore">
-            <IconButton onClick={() => {
+            <IconButton style={{ padding: '0' }} onClick={() => {
                 if (props.resource && props.dispatch) {
                     props.dispatch(toggleTrashed(
                         props.resource.kind,
@@ -72,20 +74,20 @@ export const ResourceRestore =
                         props.resource.ownerUuid,
                         props.resource.isTrashed
                     ));
-                }
-            }}>
+                }}}
+            >
                 <RestoreFromTrashIcon />
             </IconButton>
         </Tooltip>
     );
 
-export const trashPanelColumns: DataColumns<string, TrashPanelFilter> = [
+export const trashPanelColumns: DataColumns<string> = [
     {
         name: TrashPanelColumnNames.NAME,
         selected: true,
         configurable: true,
-        sortDirection: SortDirection.ASC,
-        filters: [],
+        sortDirection: SortDirection.NONE,
+        filters: createTree(),
         render: uuid => <ResourceName uuid={uuid} />
     },
     {
@@ -93,18 +95,7 @@ export const trashPanelColumns: DataColumns<string, TrashPanelFilter> = [
         selected: true,
         configurable: true,
         sortDirection: SortDirection.NONE,
-        filters: [
-            {
-                name: resourceLabel(ResourceKind.COLLECTION),
-                selected: true,
-                type: ResourceKind.COLLECTION
-            },
-            {
-                name: resourceLabel(ResourceKind.PROJECT),
-                selected: true,
-                type: ResourceKind.PROJECT
-            }
-        ],
+        filters: getTrashPanelTypeFilters(),
         render: uuid => <ResourceType uuid={uuid} />,
     },
     {
@@ -112,15 +103,15 @@ export const trashPanelColumns: DataColumns<string, TrashPanelFilter> = [
         selected: true,
         configurable: true,
         sortDirection: SortDirection.NONE,
-        filters: [],
+        filters: createTree(),
         render: uuid => <ResourceFileSize uuid={uuid} />
     },
     {
         name: TrashPanelColumnNames.TRASHED_DATE,
         selected: true,
         configurable: true,
-        sortDirection: SortDirection.NONE,
-        filters: [],
+        sortDirection: SortDirection.DESC,
+        filters: createTree(),
         render: uuid => <ResourceTrashDate uuid={uuid} />
     },
     {
@@ -128,7 +119,7 @@ export const trashPanelColumns: DataColumns<string, TrashPanelFilter> = [
         selected: true,
         configurable: true,
         sortDirection: SortDirection.NONE,
-        filters: [],
+        filters: createTree(),
         render: uuid => <ResourceDeleteDate uuid={uuid} />
     },
     {
@@ -136,7 +127,7 @@ export const trashPanelColumns: DataColumns<string, TrashPanelFilter> = [
         selected: true,
         configurable: false,
         sortDirection: SortDirection.NONE,
-        filters: [],
+        filters: createTree(),
         render: uuid => <ResourceRestore uuid={uuid} />
     }
 ];
@@ -155,23 +146,17 @@ export const TrashPanel = withStyles(styles)(
     }))(
         class extends React.Component<TrashPanelProps> {
             render() {
-                return this.hasAnyTrashedResources()
-                    ? <DataExplorer
-                        id={TRASH_PANEL_ID}
-                        onRowClick={this.handleRowClick}
-                        onRowDoubleClick={this.handleRowDoubleClick}
-                        onContextMenu={this.handleContextMenu}
-                        contextMenuColumn={false}
-                        dataTableDefaultView={<DataTableDefaultView icon={TrashIcon} />} />
-                    : <PanelDefaultView
-                        icon={TrashIcon}
-                        messages={['Your trash list is empty.']} />;
-            }
-
-            hasAnyTrashedResources = () => {
-                // TODO: implement check if there is anything in the trash,
-                //       without taking pagination into the account
-                return true;
+                return <DataExplorer
+                    id={TRASH_PANEL_ID}
+                    onRowClick={this.handleRowClick}
+                    onRowDoubleClick={this.handleRowDoubleClick}
+                    onContextMenu={this.handleContextMenu}
+                    contextMenuColumn={false}
+                    dataTableDefaultView={
+                        <DataTableDefaultView
+                            icon={TrashIcon}
+                            messages={['Your trash list is empty.']}/>
+                    } />;
             }
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
@@ -186,6 +171,7 @@ export const TrashPanel = withStyles(styles)(
                         menuKind: ContextMenuKind.TRASH
                     }));
                 }
+                this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
             }
 
             handleRowDoubleClick = (uuid: string) => {
@@ -193,7 +179,7 @@ export const TrashPanel = withStyles(styles)(
             }
 
             handleRowClick = (uuid: string) => {
-                this.props.dispatch(loadDetailsPanel(uuid));
+                this.props.dispatch<any>(loadDetailsPanel(uuid));
             }
         }
     )
