1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-26 13:48:33 +02:00

feat: enforce change request settings in create project dialog (#9637)

This commit is contained in:
Mateusz Kwasniewski 2025-03-27 16:15:09 +01:00 committed by GitHub
parent e53e2ca0c7
commit f97924eb36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 2 deletions

View File

@ -37,8 +37,9 @@ type TableProps = {
environments: {
name: string;
type: string;
requiredApprovals: number;
changeRequestEnabled: boolean;
requiredApprovals: number;
configurable: boolean;
}[];
enableEnvironment: (name: string, requiredApprovals: number) => void;
disableEnvironment: (name: string) => void;
@ -111,6 +112,7 @@ export const ChangeRequestTable = (props: TableProps) => {
approvals,
);
}}
disabled={!original.configurable}
IconComponent={
KeyboardArrowDownOutlined
}
@ -143,6 +145,7 @@ export const ChangeRequestTable = (props: TableProps) => {
original.environment
}`,
}}
disabled={!original.configurable}
onClick={onToggleEnvironment(
original.environment,
original.changeRequestEnabled,
@ -171,6 +174,7 @@ export const ChangeRequestTable = (props: TableProps) => {
type: env.type,
changeRequestEnabled: env.changeRequestEnabled,
requiredApprovals: env.requiredApprovals ?? 1,
configurable: env.configurable,
};
}),

View File

@ -26,6 +26,7 @@ type ChangeRequestTableConfigButtonProps = Pick<
activeEnvironments: {
name: string;
type: string;
configurable: boolean;
}[];
projectChangeRequestConfiguration: Record<
string,
@ -56,9 +57,10 @@ export const ChangeRequestTableConfigButton: FC<
const tableEnvs = useMemo(
() =>
activeEnvironments.map(({ name, type }) => ({
activeEnvironments.map(({ name, type, configurable }) => ({
name,
type,
configurable,
...(configured[name] ?? { changeRequestEnabled: false }),
})),
[configured, activeEnvironments],

View File

@ -234,6 +234,9 @@ export const CreateProjectDialog = ({
name,
type,
requiredApprovals,
configurable: globalChangeRequestConfigEnabled
? !Number.isInteger(requiredApprovals)
: true,
}));
useEffect(() => {