Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to archive multiple feature toggles from project overview
- Loading branch information
Showing
6 changed files
with
182 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...project/Project/ProjectFeatureToggles/SelectionActionsBar/ArchiveButton/ArchiveButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { useState, VFC } from 'react'; | ||
import { Button } from '@mui/material'; | ||
import { Archive } from '@mui/icons-material'; | ||
import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC'; | ||
import { DELETE_FEATURE } from 'component/providers/AccessProvider/permissions'; | ||
import useProject from 'hooks/api/getters/useProject/useProject'; | ||
import { FeatureArchiveDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveDialog'; | ||
|
||
interface IArchiveButtonProps { | ||
projectId: string; | ||
features: string[]; | ||
} | ||
|
||
export const ArchiveButton: VFC<IArchiveButtonProps> = ({ | ||
projectId, | ||
features, | ||
}) => { | ||
const { refetch } = useProject(projectId); | ||
const [isDialogOpen, setIsDialogOpen] = useState(false); | ||
|
||
const onConfirm = async () => { | ||
setIsDialogOpen(false); | ||
await refetch(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<PermissionHOC projectId={projectId} permission={DELETE_FEATURE}> | ||
{({ hasAccess }) => ( | ||
<Button | ||
disabled={!hasAccess || isDialogOpen} | ||
startIcon={<Archive />} | ||
variant="outlined" | ||
size="small" | ||
onClick={() => setIsDialogOpen(true)} | ||
> | ||
Archive | ||
</Button> | ||
)} | ||
</PermissionHOC> | ||
<FeatureArchiveDialog | ||
projectId={projectId} | ||
featureIds={features} | ||
onConfirm={onConfirm} | ||
isOpen={isDialogOpen} | ||
onClose={() => setIsDialogOpen(false)} | ||
/> | ||
</> | ||
); | ||
}; |
54 changes: 54 additions & 0 deletions
54
...oject/ProjectFeatureToggles/SelectionActionsBar/MarkAsStaleButtons/MarkAsStaleButtons.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { VFC } from 'react'; | ||
import { Button } from '@mui/material'; | ||
import { WatchLater } from '@mui/icons-material'; | ||
import type { FeatureSchema } from 'openapi'; | ||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; | ||
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions'; | ||
import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC'; | ||
|
||
interface IMarkAsStaleButtonsProps { | ||
projectId: string; | ||
data: FeatureSchema[]; | ||
} | ||
|
||
export const MarkAsStaleButtons: VFC<IMarkAsStaleButtonsProps> = ({ | ||
projectId, | ||
data, | ||
}) => { | ||
const hasStale = data.some(d => d.stale); | ||
const hasUnstale = data.some(d => !d.stale); | ||
|
||
return ( | ||
<PermissionHOC projectId={projectId} permission={UPDATE_FEATURE}> | ||
{({ hasAccess }) => ( | ||
<> | ||
<ConditionallyRender | ||
condition={hasUnstale || !hasAccess} | ||
show={ | ||
<Button | ||
startIcon={<WatchLater />} | ||
variant="outlined" | ||
size="small" | ||
disabled={!hasAccess} | ||
> | ||
Mark as stale | ||
</Button> | ||
} | ||
/> | ||
<ConditionallyRender | ||
condition={Boolean(hasAccess && hasStale)} | ||
show={ | ||
<Button | ||
startIcon={<WatchLater />} | ||
variant="outlined" | ||
size="small" | ||
> | ||
Un-mark as stale | ||
</Button> | ||
} | ||
/> | ||
</> | ||
)} | ||
</PermissionHOC> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters