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