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:
parent
0906ba736b
commit
b4fc65e1e6
@ -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),
|
||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
|
@ -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,46 +83,45 @@ export const MoreActions: VFC<IMoreActionsProps> = ({ projectId }) => {
|
|||||||
>
|
>
|
||||||
{({ hasAccess }) => (
|
{({ hasAccess }) => (
|
||||||
<>
|
<>
|
||||||
<MenuItem
|
<ConditionallyRender
|
||||||
// sx={defaultBorderRadius}
|
condition={hasUnstale}
|
||||||
// onClick={() => {
|
show={() => (
|
||||||
// handleClose();
|
<MenuItem
|
||||||
// onOpenStaleDialog({
|
onClick={onMarkAsStale}
|
||||||
// featureId,
|
disabled={!hasAccess}
|
||||||
// stale: stale === true,
|
sx={{ borderRadius: theme => `${theme.shape.borderRadius}px` }}
|
||||||
// });
|
|
||||||
// }}
|
>
|
||||||
disabled={!hasAccess}
|
<ListItemIcon>
|
||||||
>
|
<WatchLater />
|
||||||
<ListItemIcon>
|
</ListItemIcon>
|
||||||
<WatchLater />
|
<ListItemText>
|
||||||
</ListItemIcon>
|
<Typography variant="body2">
|
||||||
<ListItemText>
|
Mark as stale
|
||||||
<Typography variant="body2">
|
</Typography>
|
||||||
Mark as stale
|
</ListItemText>
|
||||||
</Typography>
|
</MenuItem>
|
||||||
</ListItemText>
|
)}
|
||||||
</MenuItem>
|
/>
|
||||||
<MenuItem
|
<ConditionallyRender
|
||||||
// sx={defaultBorderRadius}
|
condition={hasStale}
|
||||||
// onClick={() => {
|
show={() => (
|
||||||
// handleClose();
|
<MenuItem
|
||||||
// onOpenStaleDialog({
|
onClick={onUnmarkAsStale}
|
||||||
// featureId,
|
disabled={!hasAccess}
|
||||||
// stale: stale === true,
|
sx={{ borderRadius: theme => `${theme.shape.borderRadius}px` }}
|
||||||
// });
|
>
|
||||||
// }}
|
<ListItemIcon>
|
||||||
disabled={!hasAccess}
|
<WatchLater />
|
||||||
>
|
</ListItemIcon>
|
||||||
<ListItemIcon>
|
<ListItemText>
|
||||||
<WatchLater />
|
<Typography variant="body2">
|
||||||
</ListItemIcon>
|
Un-mark as stale
|
||||||
<ListItemText>
|
</Typography>
|
||||||
<Typography variant="body2">
|
</ListItemText>
|
||||||
Un-mark as stale
|
</MenuItem>
|
||||||
</Typography>
|
)}
|
||||||
</ListItemText>
|
/>
|
||||||
</MenuItem>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</PermissionHOC>
|
</PermissionHOC>
|
||||||
|
@ -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)}
|
||||||
|
Loading…
Reference in New Issue
Block a user