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 { ContextMenuResource, openContextMenu } from "~/store/context-menu/context-menu-actions";
+import { openContextMenu } from "~/store/context-menu/context-menu-actions";
import { getResource, ResourcesState } from "~/store/resources/resources";
import {
ResourceDeleteDate,
} 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 { toggleCollectionTrashed, toggleProjectTrashed, toggleTrashed } from "~/store/trash/trash-actions";
import { ContextMenuKind } from "~/views-components/context-menu/context-menu";
import { Dispatch } from "redux";
+import { DefaultView } from '~/components/default-view/default-view';
type CssRules = "toolbar" | "button";
})((props: { resource?: TrashableResource, dispatch?: Dispatch<any> }) =>
<IconButton onClick={() => {
if (props.resource && props.dispatch) {
- const res = props.resource;
-
- if (props.resource.kind === ResourceKind.PROJECT) {
- props.dispatch(toggleProjectTrashed(res.uuid, res.ownerUuid, res.isTrashed));
- } else if (props.resource.kind === ResourceKind.COLLECTION) {
- props.dispatch(toggleCollectionTrashed(res.uuid, res.isTrashed));
- }
+ props.dispatch(toggleTrashed(
+ props.resource.kind,
+ props.resource.uuid,
+ props.resource.ownerUuid,
+ props.resource.isTrashed
+ ));
}
}}>
- <RestoreFromTrashIcon/>
+ <RestoreFromTrashIcon />
</IconButton>
);
configurable: true,
sortDirection: SortDirection.ASC,
filters: [],
- render: uuid => <ResourceName uuid={uuid}/>,
+ render: uuid => <ResourceName uuid={uuid} />,
width: "450px"
},
{
type: ResourceKind.PROJECT
}
],
- render: uuid => <ResourceType uuid={uuid}/>,
+ render: uuid => <ResourceType uuid={uuid} />,
width: "125px"
},
{
configurable: false,
sortDirection: SortDirection.NONE,
filters: [],
- render: uuid => <ResourceRestore uuid={uuid}/>,
+ render: uuid => <ResourceRestore uuid={uuid} />,
width: "50px"
}
];
}))(
class extends React.Component<TrashPanelProps> {
render() {
- return <DataExplorer
- id={TRASH_PANEL_ID}
- onRowClick={this.handleRowClick}
- onRowDoubleClick={this.handleRowDoubleClick}
- onContextMenu={this.handleContextMenu}
- defaultIcon={TrashIcon}
- defaultMessages={['Your trash list is empty.']}
- contextMenuColumn={false}/>
- ;
+ return this.hasAnyTrashedResources()
+ ? <DataExplorer
+ id={TRASH_PANEL_ID}
+ onRowClick={this.handleRowClick}
+ onRowDoubleClick={this.handleRowDoubleClick}
+ onContextMenu={this.handleContextMenu}
+ contextMenuColumn={false} />
+ : <DefaultView
+ 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;
}
handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {