mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-31 01:16:01 +02:00
feat: disable bulk toggles flag (#3827)
This commit is contained in:
parent
40185e9066
commit
e34c9bc0bf
@ -8,6 +8,8 @@ import { ManageTags } from './ManageTags';
|
||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||
import { BulkDisableDialog } from 'component/feature/FeatureToggleList/BulkDisableDialog';
|
||||
import { BulkEnableDialog } from 'component/feature/FeatureToggleList/BulkEnableDialog';
|
||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||
|
||||
interface IProjectFeaturesBatchActionsProps {
|
||||
selectedIds: string[];
|
||||
@ -18,6 +20,7 @@ interface IProjectFeaturesBatchActionsProps {
|
||||
export const ProjectFeaturesBatchActions: FC<
|
||||
IProjectFeaturesBatchActionsProps
|
||||
> = ({ selectedIds, data, projectId }) => {
|
||||
const { uiConfig } = useUiConfig();
|
||||
const [showExportDialog, setShowExportDialog] = useState(false);
|
||||
const [showBulkEnableDialog, setShowBulkEnableDialog] = useState(false);
|
||||
const [showBulkDisableDialog, setShowBulkDisableDialog] = useState(false);
|
||||
@ -59,20 +62,32 @@ export const ProjectFeaturesBatchActions: FC<
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="small"
|
||||
onClick={() => setShowBulkEnableDialog(true)}
|
||||
>
|
||||
Enable
|
||||
</Button>
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="small"
|
||||
onClick={() => setShowBulkDisableDialog(true)}
|
||||
>
|
||||
Disable
|
||||
</Button>
|
||||
<ConditionallyRender
|
||||
condition={Boolean(uiConfig?.flags?.disableBulkToggle)}
|
||||
show={null}
|
||||
elseShow={
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="small"
|
||||
onClick={() => setShowBulkEnableDialog(true)}
|
||||
>
|
||||
Enable
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<ConditionallyRender
|
||||
condition={Boolean(uiConfig?.flags?.disableBulkToggle)}
|
||||
show={null}
|
||||
elseShow={
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="small"
|
||||
onClick={() => setShowBulkDisableDialog(true)}
|
||||
>
|
||||
Disable
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<ArchiveButton projectId={projectId} features={selectedIds} />
|
||||
<Button
|
||||
variant="outlined"
|
||||
|
@ -50,6 +50,7 @@ export interface IFlags {
|
||||
googleAuthEnabled?: boolean;
|
||||
variantMetrics?: boolean;
|
||||
strategyImprovements?: boolean;
|
||||
disableBulkToggle?: boolean;
|
||||
}
|
||||
|
||||
export interface IVersionInfo {
|
||||
|
@ -186,7 +186,7 @@ export default class ProjectFeaturesController extends Controller {
|
||||
permission: UPDATE_FEATURE_ENVIRONMENT,
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Unstable'],
|
||||
tags: ['Features'],
|
||||
description:
|
||||
'This endpoint enables multiple feature toggles.',
|
||||
summary: 'Bulk enable a list of features.',
|
||||
@ -206,7 +206,7 @@ export default class ProjectFeaturesController extends Controller {
|
||||
permission: UPDATE_FEATURE_ENVIRONMENT,
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Unstable'],
|
||||
tags: ['Features'],
|
||||
description:
|
||||
'This endpoint disables multiple feature toggles.',
|
||||
summary: 'Bulk disabled a list of features.',
|
||||
@ -748,6 +748,11 @@ export default class ProjectFeaturesController extends Controller {
|
||||
const { shouldActivateDisabledStrategies } = req.query;
|
||||
const { features } = req.body;
|
||||
|
||||
if (this.flagResolver.isEnabled('disableBulkToggle')) {
|
||||
res.status(409).end();
|
||||
return;
|
||||
}
|
||||
|
||||
await this.startTransaction(async (tx) =>
|
||||
this.transactionalFeatureToggleService(tx).bulkUpdateEnabled(
|
||||
projectId,
|
||||
@ -775,6 +780,11 @@ export default class ProjectFeaturesController extends Controller {
|
||||
const { shouldActivateDisabledStrategies } = req.query;
|
||||
const { features } = req.body;
|
||||
|
||||
if (this.flagResolver.isEnabled('disableBulkToggle')) {
|
||||
res.status(409).end();
|
||||
return;
|
||||
}
|
||||
|
||||
await this.startTransaction(async (tx) =>
|
||||
this.transactionalFeatureToggleService(tx).bulkUpdateEnabled(
|
||||
projectId,
|
||||
|
@ -20,7 +20,8 @@ export type IFlagKey =
|
||||
| 'demo'
|
||||
| 'strategyImprovements'
|
||||
| 'googleAuthEnabled'
|
||||
| 'variantMetrics';
|
||||
| 'variantMetrics'
|
||||
| 'disableBulkToggle';
|
||||
|
||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||
|
||||
|
@ -9678,7 +9678,7 @@ If the provided project does not exist, the list of events will be empty.",
|
||||
},
|
||||
"summary": "Bulk disabled a list of features.",
|
||||
"tags": [
|
||||
"Unstable",
|
||||
"Features",
|
||||
],
|
||||
},
|
||||
},
|
||||
@ -9722,7 +9722,7 @@ If the provided project does not exist, the list of events will be empty.",
|
||||
},
|
||||
"summary": "Bulk enable a list of features.",
|
||||
"tags": [
|
||||
"Unstable",
|
||||
"Features",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user