1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +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}
PaperProps={{
sx: theme => ({
borderRadius: theme.shape.borderRadius,
borderRadius: `${theme.shape.borderRadius}px`,
padding: theme.spacing(1, 1.5),
}),
}}

View File

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

View File

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