1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-10 17:53:36 +02:00

stale action relevant to data

This commit is contained in:
Tymoteusz Czech 2023-03-14 11:15:26 +01:00
parent 0906ba736b
commit b4fc65e1e6
No known key found for this signature in database
GPG Key ID: 133555230D88D75F
3 changed files with 61 additions and 44 deletions

View File

@ -87,7 +87,7 @@ export const ActionsCell: VFC<IActionsCellProps> = ({
disableScrollLock={true} disableScrollLock={true}
PaperProps={{ PaperProps={{
sx: theme => ({ sx: theme => ({
borderRadius: theme.shape.borderRadius, borderRadius: `${theme.shape.borderRadius}px`,
padding: theme.spacing(1, 1.5), padding: theme.spacing(1, 1.5),
}), }),
}} }}

View File

@ -12,14 +12,17 @@ import {
import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC'; import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC';
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions'; import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions';
import { MoreVert, WatchLater } from '@mui/icons-material'; import { MoreVert, WatchLater } from '@mui/icons-material';
import type { FeatureSchema } from 'openapi';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
interface IMoreActionsProps { interface IMoreActionsProps {
projectId: string; projectId: string;
data: FeatureSchema[];
} }
const menuId = 'selection-actions-menu'; const menuId = 'selection-actions-menu';
export const MoreActions: VFC<IMoreActionsProps> = ({ projectId }) => { export const MoreActions: VFC<IMoreActionsProps> = ({ projectId, data }) => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
@ -29,6 +32,21 @@ export const MoreActions: VFC<IMoreActionsProps> = ({ projectId }) => {
setAnchorEl(null); setAnchorEl(null);
}; };
const hasStale = data.some(({ stale }) => stale === true);
const hasUnstale = data.some(({ stale }) => stale === false);
const onMarkAsStale = () => {
console.log('Mark as stale');
// TODO: Implement
handleClose();
};
const onUnmarkAsStale = () => {
console.log('Un-mark as stale');
// TODO: Implement
handleClose();
};
return ( return (
<> <>
<Tooltip title="Feature toggle actions" arrow describeChild> <Tooltip title="Feature toggle actions" arrow describeChild>
@ -53,7 +71,7 @@ export const MoreActions: VFC<IMoreActionsProps> = ({ projectId }) => {
disableScrollLock={true} disableScrollLock={true}
PaperProps={{ PaperProps={{
sx: theme => ({ sx: theme => ({
borderRadius: theme.shape.borderRadius, borderRadius: `${theme.shape.borderRadius}px`,
padding: theme.spacing(1, 1.5), padding: theme.spacing(1, 1.5),
}), }),
}} }}
@ -65,16 +83,14 @@ export const MoreActions: VFC<IMoreActionsProps> = ({ projectId }) => {
> >
{({ hasAccess }) => ( {({ hasAccess }) => (
<> <>
<ConditionallyRender
condition={hasUnstale}
show={() => (
<MenuItem <MenuItem
// sx={defaultBorderRadius} onClick={onMarkAsStale}
// onClick={() => {
// handleClose();
// onOpenStaleDialog({
// featureId,
// stale: stale === true,
// });
// }}
disabled={!hasAccess} disabled={!hasAccess}
sx={{ borderRadius: theme => `${theme.shape.borderRadius}px` }}
> >
<ListItemIcon> <ListItemIcon>
<WatchLater /> <WatchLater />
@ -85,16 +101,15 @@ export const MoreActions: VFC<IMoreActionsProps> = ({ projectId }) => {
</Typography> </Typography>
</ListItemText> </ListItemText>
</MenuItem> </MenuItem>
)}
/>
<ConditionallyRender
condition={hasStale}
show={() => (
<MenuItem <MenuItem
// sx={defaultBorderRadius} onClick={onUnmarkAsStale}
// onClick={() => {
// handleClose();
// onOpenStaleDialog({
// featureId,
// stale: stale === true,
// });
// }}
disabled={!hasAccess} disabled={!hasAccess}
sx={{ borderRadius: theme => `${theme.shape.borderRadius}px` }}
> >
<ListItemIcon> <ListItemIcon>
<WatchLater /> <WatchLater />
@ -105,6 +120,8 @@ export const MoreActions: VFC<IMoreActionsProps> = ({ projectId }) => {
</Typography> </Typography>
</ListItemText> </ListItemText>
</MenuItem> </MenuItem>
)}
/>
</> </>
)} )}
</PermissionHOC> </PermissionHOC>

View File

@ -92,7 +92,7 @@ export const SelectionActionsBar: VFC<ISelectionActionsBarProps> = ({
> >
Tags Tags
</Button> </Button>
<MoreActions projectId={projectId} /> <MoreActions projectId={projectId} data={selectedData} />
</StyledBar> </StyledBar>
<ConditionallyRender <ConditionallyRender
condition={Boolean(uiConfig?.flags?.featuresExportImport)} condition={Boolean(uiConfig?.flags?.featuresExportImport)}