1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: can review CR with skip change request (#3998)

This commit is contained in:
Mateusz Kwasniewski 2023-06-16 13:36:23 +02:00 committed by GitHub
parent dcac61e4d9
commit ce6ff2578a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -83,13 +83,14 @@ export const ChangeRequestOverview: FC = () => {
const { refetch: refetchChangeRequestOpen } =
usePendingChangeRequests(projectId);
const { setToastData, setToastApiError } = useToast();
const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId);
const { isChangeRequestConfiguredForReview } =
useChangeRequestsEnabled(projectId);
if (!changeRequest) {
return null;
}
const allowChangeRequestActions = isChangeRequestConfigured(
const allowChangeRequestActions = isChangeRequestConfiguredForReview(
changeRequest.environment
);

View File

@ -25,6 +25,18 @@ export const useChangeRequestsEnabled = (projectId: string) => {
[JSON.stringify(data)]
);
const isChangeRequestConfiguredForReview = React.useCallback(
(environment: string): boolean => {
return data.some(draft => {
return (
draft.environment === environment &&
draft.changeRequestEnabled
);
});
},
[JSON.stringify(data)]
);
const isChangeRequestConfiguredInAnyEnv = React.useCallback((): boolean => {
return data.some(draft => draft.changeRequestEnabled);
}, [JSON.stringify(data)]);
@ -32,5 +44,6 @@ export const useChangeRequestsEnabled = (projectId: string) => {
return {
isChangeRequestConfigured,
isChangeRequestConfiguredInAnyEnv,
isChangeRequestConfiguredForReview,
};
};