mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
chore: remove flag for global change request config (#9840)
This commit is contained in:
parent
44082b24a1
commit
bd78a75177
@ -12,7 +12,6 @@ import useEnvironmentForm from '../hooks/useEnvironmentForm';
|
|||||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
||||||
import { GO_BACK } from 'constants/navigate';
|
import { GO_BACK } from 'constants/navigate';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
|
||||||
|
|
||||||
const EditEnvironment = () => {
|
const EditEnvironment = () => {
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
@ -37,15 +36,12 @@ const EditEnvironment = () => {
|
|||||||
environment.requiredApprovals,
|
environment.requiredApprovals,
|
||||||
);
|
);
|
||||||
const { refetch } = usePermissions();
|
const { refetch } = usePermissions();
|
||||||
const globalChangeRequestConfigEnabled = useUiFlag(
|
|
||||||
'globalChangeRequestConfig',
|
|
||||||
);
|
|
||||||
|
|
||||||
const editPayload = () => {
|
const editPayload = () => {
|
||||||
return {
|
return {
|
||||||
type,
|
type,
|
||||||
sortOrder: environment.sortOrder,
|
sortOrder: environment.sortOrder,
|
||||||
...(globalChangeRequestConfigEnabled ? { requiredApprovals } : {}),
|
requiredApprovals,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import Input from 'component/common/Input/Input';
|
|||||||
import { EnvironmentTypeSelector } from './EnvironmentTypeSelector';
|
import { EnvironmentTypeSelector } from './EnvironmentTypeSelector';
|
||||||
import { ChangeRequestSelector } from './ChangeRequestSelector';
|
import { ChangeRequestSelector } from './ChangeRequestSelector';
|
||||||
import { trim } from 'component/common/util';
|
import { trim } from 'component/common/util';
|
||||||
import { useUiFlag } from '../../../hooks/useUiFlag';
|
|
||||||
|
|
||||||
interface IEnvironmentForm {
|
interface IEnvironmentForm {
|
||||||
name: string;
|
name: string;
|
||||||
@ -82,9 +81,6 @@ const EnvironmentForm: React.FC<IEnvironmentForm> = ({
|
|||||||
clearErrors,
|
clearErrors,
|
||||||
Limit,
|
Limit,
|
||||||
}) => {
|
}) => {
|
||||||
const globalChangeRequestConfigEnabled = useUiFlag(
|
|
||||||
'globalChangeRequestConfig',
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<StyledForm onSubmit={handleSubmit}>
|
<StyledForm onSubmit={handleSubmit}>
|
||||||
<StyledFormHeader>Environment information</StyledFormHeader>
|
<StyledFormHeader>Environment information</StyledFormHeader>
|
||||||
@ -113,7 +109,6 @@ const EnvironmentForm: React.FC<IEnvironmentForm> = ({
|
|||||||
value={type}
|
value={type}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{globalChangeRequestConfigEnabled ? (
|
|
||||||
<>
|
<>
|
||||||
<StyledInputDescription sx={{ mt: 2 }}>
|
<StyledInputDescription sx={{ mt: 2 }}>
|
||||||
Would you like to predefine change requests for this
|
Would you like to predefine change requests for this
|
||||||
@ -124,7 +119,6 @@ const EnvironmentForm: React.FC<IEnvironmentForm> = ({
|
|||||||
value={requiredApprovals}
|
value={requiredApprovals}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : null}
|
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
|
|
||||||
<LimitContainer>{Limit}</LimitContainer>
|
<LimitContainer>{Limit}</LimitContainer>
|
||||||
|
@ -39,9 +39,6 @@ export const EnvironmentTable = () => {
|
|||||||
const { setToastApiError } = useToast();
|
const { setToastApiError } = useToast();
|
||||||
const { environments, mutateEnvironments } = useEnvironments();
|
const { environments, mutateEnvironments } = useEnvironments();
|
||||||
const isFeatureEnabled = useUiFlag('EEA');
|
const isFeatureEnabled = useUiFlag('EEA');
|
||||||
const globalChangeRequestConfigEnabled = useUiFlag(
|
|
||||||
'globalChangeRequestConfig',
|
|
||||||
);
|
|
||||||
const { isEnterprise } = useUiConfig();
|
const { isEnterprise } = useUiConfig();
|
||||||
|
|
||||||
const onMoveItem: OnMoveItem = useCallback(
|
const onMoveItem: OnMoveItem = useCallback(
|
||||||
@ -86,7 +83,7 @@ export const EnvironmentTable = () => {
|
|||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
];
|
];
|
||||||
if (globalChangeRequestConfigEnabled && isEnterprise()) {
|
if (isEnterprise()) {
|
||||||
baseColumns.splice(2, 0, {
|
baseColumns.splice(2, 0, {
|
||||||
Header: 'Change request',
|
Header: 'Change request',
|
||||||
accessor: (row: IEnvironment) =>
|
accessor: (row: IEnvironment) =>
|
||||||
@ -96,7 +93,7 @@ export const EnvironmentTable = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return baseColumns;
|
return baseColumns;
|
||||||
}, [isFeatureEnabled, globalChangeRequestConfigEnabled]);
|
}, [isFeatureEnabled]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getTableProps,
|
getTableProps,
|
||||||
|
@ -27,7 +27,6 @@ import { useStickinessOptions } from 'hooks/useStickinessOptions';
|
|||||||
import { ChangeRequestTableConfigButton } from './ConfigButtons/ChangeRequestTableConfigButton';
|
import { ChangeRequestTableConfigButton } from './ConfigButtons/ChangeRequestTableConfigButton';
|
||||||
import { StyledDefinitionList } from './CreateProjectDialog.styles';
|
import { StyledDefinitionList } from './CreateProjectDialog.styles';
|
||||||
import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon';
|
import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
|
||||||
|
|
||||||
interface ICreateProjectDialogProps {
|
interface ICreateProjectDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -210,10 +209,6 @@ export const CreateProjectDialog = ({
|
|||||||
const activeEnvironments = allEnvironments.filter((env) => env.enabled);
|
const activeEnvironments = allEnvironments.filter((env) => env.enabled);
|
||||||
const stickinessOptions = useStickinessOptions(projectStickiness);
|
const stickinessOptions = useStickinessOptions(projectStickiness);
|
||||||
|
|
||||||
const globalChangeRequestConfigEnabled = useUiFlag(
|
|
||||||
'globalChangeRequestConfig',
|
|
||||||
);
|
|
||||||
|
|
||||||
const numberOfConfiguredChangeRequestEnvironments = Object.keys(
|
const numberOfConfiguredChangeRequestEnvironments = Object.keys(
|
||||||
projectChangeRequestConfiguration,
|
projectChangeRequestConfiguration,
|
||||||
).length;
|
).length;
|
||||||
@ -234,13 +229,10 @@ export const CreateProjectDialog = ({
|
|||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
requiredApprovals,
|
requiredApprovals,
|
||||||
configurable: globalChangeRequestConfigEnabled
|
configurable: !Number.isInteger(requiredApprovals),
|
||||||
? !Number.isInteger(requiredApprovals)
|
|
||||||
: true,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!globalChangeRequestConfigEnabled) return;
|
|
||||||
availableChangeRequestEnvironments.forEach((environment) => {
|
availableChangeRequestEnvironments.forEach((environment) => {
|
||||||
if (Number.isInteger(environment.requiredApprovals)) {
|
if (Number.isInteger(environment.requiredApprovals)) {
|
||||||
updateProjectChangeRequestConfig.enableChangeRequests(
|
updateProjectChangeRequestConfig.enableChangeRequests(
|
||||||
|
@ -92,7 +92,6 @@ export type UiFlags = {
|
|||||||
edgeObservability?: boolean;
|
edgeObservability?: boolean;
|
||||||
adminNavUI?: boolean;
|
adminNavUI?: boolean;
|
||||||
tagTypeColor?: boolean;
|
tagTypeColor?: boolean;
|
||||||
globalChangeRequestConfig?: boolean;
|
|
||||||
addEditStrategy?: boolean;
|
addEditStrategy?: boolean;
|
||||||
newStrategyDropdown?: boolean;
|
newStrategyDropdown?: boolean;
|
||||||
flagsReleaseManagementUI?: boolean;
|
flagsReleaseManagementUI?: boolean;
|
||||||
|
@ -3,7 +3,6 @@ import { createTestConfig } from '../../../test/config/test-config';
|
|||||||
import dbInit, { type ITestDb } from '../../../test/e2e/helpers/database-init';
|
import dbInit, { type ITestDb } from '../../../test/e2e/helpers/database-init';
|
||||||
import NotFoundError from '../../error/notfound-error';
|
import NotFoundError from '../../error/notfound-error';
|
||||||
import {
|
import {
|
||||||
type IExperimentalOptions,
|
|
||||||
type IUnleashStores,
|
type IUnleashStores,
|
||||||
SYSTEM_USER,
|
SYSTEM_USER,
|
||||||
SYSTEM_USER_AUDIT,
|
SYSTEM_USER_AUDIT,
|
||||||
@ -18,15 +17,9 @@ let service: EnvironmentService;
|
|||||||
let eventService: EventService;
|
let eventService: EventService;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const flags: Partial<IExperimentalOptions> = {
|
const config = createTestConfig();
|
||||||
flags: { globalChangeRequestConfig: true },
|
|
||||||
};
|
|
||||||
const config = createTestConfig({
|
|
||||||
experimental: flags,
|
|
||||||
});
|
|
||||||
db = await dbInit('environment_service_serial', config.getLogger, {
|
db = await dbInit('environment_service_serial', config.getLogger, {
|
||||||
dbInitMethod: 'legacy' as const,
|
dbInitMethod: 'legacy' as const,
|
||||||
experimental: flags,
|
|
||||||
});
|
});
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
eventService = createEventsService(db.rawDatabase, config);
|
eventService = createEventsService(db.rawDatabase, config);
|
||||||
|
@ -43,6 +43,7 @@ const COLUMNS = [
|
|||||||
'sort_order',
|
'sort_order',
|
||||||
'enabled',
|
'enabled',
|
||||||
'protected',
|
'protected',
|
||||||
|
'required_approvals',
|
||||||
];
|
];
|
||||||
|
|
||||||
function mapRow(row: IEnvironmentsTable): IEnvironment {
|
function mapRow(row: IEnvironmentsTable): IEnvironment {
|
||||||
@ -134,18 +135,12 @@ export default class EnvironmentStore implements IEnvironmentStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private allColumns() {
|
|
||||||
return this.flagResolver.isEnabled('globalChangeRequestConfig')
|
|
||||||
? [...COLUMNS, 'required_approvals']
|
|
||||||
: COLUMNS;
|
|
||||||
}
|
|
||||||
|
|
||||||
async importEnvironments(
|
async importEnvironments(
|
||||||
environments: IEnvironment[],
|
environments: IEnvironment[],
|
||||||
): Promise<IEnvironment[]> {
|
): Promise<IEnvironment[]> {
|
||||||
const rows = await this.db(TABLE)
|
const rows = await this.db(TABLE)
|
||||||
.insert(environments.map(fieldToRow))
|
.insert(environments.map(fieldToRow))
|
||||||
.returning(this.allColumns())
|
.returning(COLUMNS)
|
||||||
.onConflict('name')
|
.onConflict('name')
|
||||||
.ignore();
|
.ignore();
|
||||||
|
|
||||||
@ -355,7 +350,7 @@ export default class EnvironmentStore implements IEnvironmentStore {
|
|||||||
const updatedEnv = await this.db<IEnvironmentsTable>(TABLE)
|
const updatedEnv = await this.db<IEnvironmentsTable>(TABLE)
|
||||||
.update(snakeCaseKeys(env))
|
.update(snakeCaseKeys(env))
|
||||||
.where({ name, protected: false })
|
.where({ name, protected: false })
|
||||||
.returning<IEnvironmentsTable>(this.allColumns());
|
.returning<IEnvironmentsTable>(COLUMNS);
|
||||||
|
|
||||||
return mapRow(updatedEnv[0]);
|
return mapRow(updatedEnv[0]);
|
||||||
}
|
}
|
||||||
@ -363,7 +358,7 @@ export default class EnvironmentStore implements IEnvironmentStore {
|
|||||||
async create(env: IEnvironmentCreate): Promise<IEnvironment> {
|
async create(env: IEnvironmentCreate): Promise<IEnvironment> {
|
||||||
const row = await this.db<IEnvironmentsTable>(TABLE)
|
const row = await this.db<IEnvironmentsTable>(TABLE)
|
||||||
.insert(snakeCaseKeys(env))
|
.insert(snakeCaseKeys(env))
|
||||||
.returning<IEnvironmentsTable>(this.allColumns());
|
.returning<IEnvironmentsTable>(COLUMNS);
|
||||||
|
|
||||||
return mapRow(row[0]);
|
return mapRow(row[0]);
|
||||||
}
|
}
|
||||||
|
@ -429,9 +429,6 @@ export default class ProjectService {
|
|||||||
await this.validateEnvironmentsExist(
|
await this.validateEnvironmentsExist(
|
||||||
newProject.changeRequestEnvironments.map((env) => env.name),
|
newProject.changeRequestEnvironments.map((env) => env.name),
|
||||||
);
|
);
|
||||||
const globalChangeRequestConfigEnabled =
|
|
||||||
this.flagResolver.isEnabled('globalChangeRequestConfig');
|
|
||||||
if (globalChangeRequestConfigEnabled) {
|
|
||||||
const allChangeRequestEnvironments =
|
const allChangeRequestEnvironments =
|
||||||
await this.getAllChangeRequestEnvironments(newProject);
|
await this.getAllChangeRequestEnvironments(newProject);
|
||||||
const changeRequestEnvironments =
|
const changeRequestEnvironments =
|
||||||
@ -440,14 +437,6 @@ export default class ProjectService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
data.changeRequestEnvironments = changeRequestEnvironments;
|
data.changeRequestEnvironments = changeRequestEnvironments;
|
||||||
} else {
|
|
||||||
const changeRequestEnvironments =
|
|
||||||
await enableChangeRequestsForSpecifiedEnvironments(
|
|
||||||
newProject.changeRequestEnvironments,
|
|
||||||
);
|
|
||||||
|
|
||||||
data.changeRequestEnvironments = changeRequestEnvironments;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
data.changeRequestEnvironments = [];
|
data.changeRequestEnvironments = [];
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@ export type IFlagKey =
|
|||||||
| 'simplifyDisableFeature'
|
| 'simplifyDisableFeature'
|
||||||
| 'adminNavUI'
|
| 'adminNavUI'
|
||||||
| 'tagTypeColor'
|
| 'tagTypeColor'
|
||||||
| 'globalChangeRequestConfig'
|
|
||||||
| 'addEditStrategy'
|
| 'addEditStrategy'
|
||||||
| 'newStrategyDropdown'
|
| 'newStrategyDropdown'
|
||||||
| 'flagsOverviewSearch'
|
| 'flagsOverviewSearch'
|
||||||
@ -307,10 +306,6 @@ const flags: IFlags = {
|
|||||||
process.env.UNLEASH_EXPERIMENTAL_TAG_TYPE_COLOR,
|
process.env.UNLEASH_EXPERIMENTAL_TAG_TYPE_COLOR,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
globalChangeRequestConfig: parseEnvVarBoolean(
|
|
||||||
process.env.UNLEASH_EXPERIMENTAL_GLOBAL_CHANGE_REQUEST_CONFIG,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
addEditStrategy: parseEnvVarBoolean(
|
addEditStrategy: parseEnvVarBoolean(
|
||||||
process.env.UNLEASH_EXPERIMENTAL_ADD_EDIT_STRATEGY,
|
process.env.UNLEASH_EXPERIMENTAL_ADD_EDIT_STRATEGY,
|
||||||
false,
|
false,
|
||||||
|
Loading…
Reference in New Issue
Block a user