1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
7 import { PublicFavoriteIcon } from "components/icon/icon";
8 import { connect } from "react-redux";
9 import { RootState } from "store/store";
11 const mapStateToProps = (state: RootState, props: { onClick: () => {} }) => ({
12 isPublicFavorite: state.contextMenu.resource !== undefined && state.publicFavorites[state.contextMenu.resource.uuid] === true,
13 onClick: props.onClick
16 export const TogglePublicFavoriteAction = connect(mapStateToProps)((props: { isPublicFavorite: boolean, onClick: () => void }) =>
19 onClick={props.onClick}>
21 {props.isPublicFavorite
22 ? <PublicFavoriteIcon />
23 : <PublicFavoriteIcon />}
25 <ListItemText style={{ textDecoration: 'none' }}>
26 {props.isPublicFavorite
27 ? <>Remove from public favorites</>
28 : <>Add to public favorites</>}