Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
307 additions
and
175 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
54 changes: 54 additions & 0 deletions
54
frontend/src/component/archive/ArchiveTable/ArchiveBatchActions.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 { FC } from 'react'; | ||
import { Button } from '@mui/material'; | ||
import { Undo } from '@mui/icons-material'; | ||
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions'; | ||
import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC'; | ||
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi'; | ||
import { formatUnknownError } from 'utils/formatUnknownError'; | ||
import { useFeaturesArchive } from 'hooks/api/getters/useFeaturesArchive/useFeaturesArchive'; | ||
import useToast from 'hooks/useToast'; | ||
|
||
interface IArchiveBatchActionsProps { | ||
selectedIds: string[]; | ||
projectId: string; | ||
} | ||
|
||
export const ArchiveBatchActions: FC<IArchiveBatchActionsProps> = ({ | ||
selectedIds, | ||
projectId, | ||
}) => { | ||
const { reviveFeatures } = useProjectApi(); | ||
const { setToastData, setToastApiError } = useToast(); | ||
const { refetchArchived } = useFeaturesArchive(projectId); | ||
|
||
const onRevive = async () => { | ||
try { | ||
await reviveFeatures(projectId, selectedIds); | ||
await refetchArchived(); | ||
setToastData({ | ||
type: 'success', | ||
title: "And we're back!", | ||
text: 'The feature toggles have been revived.', | ||
}); | ||
} catch (error: unknown) { | ||
setToastApiError(formatUnknownError(error)); | ||
} | ||
}; | ||
return ( | ||
<> | ||
<PermissionHOC projectId={projectId} permission={UPDATE_FEATURE}> | ||
{({ hasAccess }) => ( | ||
<Button | ||
disabled={!hasAccess} | ||
startIcon={<Undo />} | ||
variant="outlined" | ||
size="small" | ||
onClick={onRevive} | ||
> | ||
Revive | ||
</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
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
61 changes: 61 additions & 0 deletions
61
frontend/src/component/common/BatchSelectionActionsBar/BatchSelectionActionsBar.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,61 @@ | ||
import { FC } from 'react'; | ||
import { Box, Paper, styled, Typography } from '@mui/material'; | ||
|
||
interface IBatchSelectionActionsBarProps { | ||
selectedIds: string[]; | ||
} | ||
|
||
const StyledContainer = styled(Box)(() => ({ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
width: '100%', | ||
flexWrap: 'wrap', | ||
})); | ||
|
||
const StyledBar = styled(Paper)(({ theme }) => ({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'flex-end', | ||
marginTop: theme.spacing(2), | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
padding: theme.spacing(2, 3), | ||
backgroundColor: theme.palette.background.paper, | ||
border: `1px solid ${theme.palette.secondary.main}`, | ||
borderRadius: theme.shape.borderRadiusLarge, | ||
gap: theme.spacing(1), | ||
flexWrap: 'wrap', | ||
})); | ||
|
||
const StyledCount = styled('span')(({ theme }) => ({ | ||
background: theme.palette.secondary.main, | ||
color: theme.palette.background.paper, | ||
padding: theme.spacing(0.5, 1), | ||
borderRadius: theme.shape.borderRadius, | ||
})); | ||
|
||
const StyledText = styled(Typography)(({ theme }) => ({ | ||
paddingRight: theme.spacing(2), | ||
marginRight: 'auto', | ||
})); | ||
|
||
export const BatchSelectionActionsBar: FC<IBatchSelectionActionsBarProps> = ({ | ||
selectedIds, | ||
children, | ||
}) => { | ||
if (selectedIds.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<StyledContainer> | ||
<StyledBar elevation={4}> | ||
<StyledText> | ||
<StyledCount>{selectedIds.length}</StyledCount> | ||
 selected | ||
</StyledText> | ||
{children} | ||
</StyledBar> | ||
</StyledContainer> | ||
); | ||
}; |
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
2 changes: 1 addition & 1 deletion
2
frontend/src/component/common/EnvironmentStrategiesDialog/EnvironmentStrategyDialog.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
4 changes: 2 additions & 2 deletions
4
frontend/src/component/common/ResponsiveButton/ResponsiveButton.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
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
68 changes: 68 additions & 0 deletions
68
...project/Project/ProjectFeatureToggles/SelectionActionsBar/ProjectFeaturesBatchActions.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,68 @@ | ||
import { FC, useMemo, useState } from 'react'; | ||
import { Button } from '@mui/material'; | ||
import { FileDownload, Label } from '@mui/icons-material'; | ||
import type { FeatureSchema } from 'openapi'; | ||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; | ||
import { ExportDialog } from 'component/feature/FeatureToggleList/ExportDialog'; | ||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; | ||
import { ArchiveButton } from './ArchiveButton/ArchiveButton'; | ||
import { MoreActions } from './MoreActions/MoreActions'; | ||
|
||
interface IProjectFeaturesBatchActionsProps { | ||
selectedIds: string[]; | ||
data: FeatureSchema[]; | ||
projectId: string; | ||
} | ||
|
||
export const ProjectFeaturesBatchActions: FC< | ||
IProjectFeaturesBatchActionsProps | ||
> = ({ selectedIds, data, projectId }) => { | ||
const { uiConfig } = useUiConfig(); | ||
const [showExportDialog, setShowExportDialog] = useState(false); | ||
const selectedData = useMemo( | ||
() => data.filter(d => selectedIds.includes(d.name)), | ||
[data, selectedIds] | ||
); | ||
|
||
const environments = useMemo(() => { | ||
const envs = selectedData | ||
.flatMap(d => d.environments) | ||
.map(env => env?.name) | ||
.filter(env => env !== undefined) as string[]; | ||
return Array.from(new Set(envs)); | ||
}, [selectedData]); | ||
|
||
return ( | ||
<> | ||
<ArchiveButton projectId={projectId} features={selectedIds} /> | ||
<Button | ||
startIcon={<FileDownload />} | ||
variant="outlined" | ||
size="small" | ||
onClick={() => setShowExportDialog(true)} | ||
> | ||
Export | ||
</Button> | ||
<Button | ||
disabled | ||
startIcon={<Label />} | ||
variant="outlined" | ||
size="small" | ||
> | ||
Tags | ||
</Button> | ||
<MoreActions projectId={projectId} data={selectedData} /> | ||
<ConditionallyRender | ||
condition={Boolean(uiConfig?.flags?.featuresExportImport)} | ||
show={ | ||
<ExportDialog | ||
showExportDialog={showExportDialog} | ||
data={selectedData} | ||
onClose={() => setShowExportDialog(false)} | ||
environments={environments} | ||
/> | ||
} | ||
/> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.