mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-09 01:17:06 +02:00
feat: preselect change request settings in create project (#9625)
This commit is contained in:
parent
cc0348beba
commit
6b793677b9
@ -11,7 +11,7 @@ import useProjectForm, {
|
|||||||
DEFAULT_PROJECT_STICKINESS,
|
DEFAULT_PROJECT_STICKINESS,
|
||||||
} from '../../hooks/useProjectForm';
|
} from '../../hooks/useProjectForm';
|
||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
import { type ReactNode, useState, type FormEvent } from 'react';
|
import { type ReactNode, useState, type FormEvent, useEffect } from 'react';
|
||||||
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
|
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
@ -27,6 +27,7 @@ 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;
|
||||||
@ -209,6 +210,21 @@ 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',
|
||||||
|
);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!globalChangeRequestConfigEnabled) return;
|
||||||
|
activeEnvironments.forEach((environment) => {
|
||||||
|
if (Number.isInteger(environment.requiredApprovals)) {
|
||||||
|
updateProjectChangeRequestConfig.enableChangeRequests(
|
||||||
|
environment.name,
|
||||||
|
Number(environment.requiredApprovals),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [JSON.stringify(activeEnvironments)]);
|
||||||
|
|
||||||
const numberOfConfiguredChangeRequestEnvironments = Object.keys(
|
const numberOfConfiguredChangeRequestEnvironments = Object.keys(
|
||||||
projectChangeRequestConfiguration,
|
projectChangeRequestConfiguration,
|
||||||
).length;
|
).length;
|
||||||
|
Loading…
Reference in New Issue
Block a user