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