Merge branch 'master' into 14529-moving-renaming-processes-in-final-state
[arvados-workbench2.git] / src / views-components / context-menu / actions / trash-action.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
7 import { RestoreFromTrashIcon, TrashIcon } from "~/components/icon/icon";
8 import { connect } from "react-redux";
9 import { RootState } from "~/store/store";
10
11 const mapStateToProps = (state: RootState, props: { onClick: () => {} }) => ({
12     isTrashed: state.contextMenu.resource && state.contextMenu.resource.isTrashed,
13     onClick: props.onClick
14 });
15
16 export const ToggleTrashAction = connect(mapStateToProps)((props: { isTrashed?: boolean, onClick: () => void }) =>
17     <ListItem button
18         onClick={props.onClick}>
19         <ListItemIcon>
20             {props.isTrashed
21                 ? <RestoreFromTrashIcon/>
22                 : <TrashIcon/>}
23         </ListItemIcon>
24         <ListItemText style={{ textDecoration: 'none' }}>
25             {props.isTrashed ? "Restore" : "Move to trash"}
26         </ListItemText>
27     </ListItem >);