diff --git a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx
index c9c3383b57..709fb77df7 100644
--- a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx
+++ b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx
@@ -100,6 +100,9 @@ export const ChangeRequestOverview: FC = () => {
changeRequest.state === 'In review' &&
!isAdmin;
+ const hasApprovedAlready = changeRequest.approvals.some(
+ approval => approval.createdBy.id === user?.id
+ );
return (
<>
@@ -154,10 +157,14 @@ export const ChangeRequestOverview: FC = () => {
/>
}
/>
{
+ const { data } = useChangeRequestConfig(projectId);
+
+ const getChangeRequestRequiredApprovals = React.useCallback(
+ (environment: string): number => {
+ const config = data.find(draft => {
+ return (
+ draft.environment === environment &&
+ draft.changeRequestEnabled
+ );
+ });
+
+ return config?.requiredApprovals || 1;
+ },
+ [data]
+ );
+
+ return {
+ getChangeRequestRequiredApprovals,
+ };
+};
+
const resolveBorder = (state: ChangeRequestState, theme: Theme) => {
if (state === 'Approved') {
return `2px solid ${theme.palette.success.main}`;
@@ -51,9 +76,8 @@ const resolveIconColors = (state: ChangeRequestState, theme: Theme) => {
export const ChangeRequestReviewStatus: FC<
ISuggestChangeReviewsStatusProps
-> = ({ state }) => {
+> = ({ state, environment }) => {
const theme = useTheme();
-
return (
@@ -64,7 +88,7 @@ export const ChangeRequestReviewStatus: FC<
/>
-
+
);
@@ -72,9 +96,10 @@ export const ChangeRequestReviewStatus: FC<
interface IResolveComponentProps {
state: ChangeRequestState;
+ environment: string;
}
-const ResolveComponent = ({ state }: IResolveComponentProps) => {
+const ResolveComponent = ({ state, environment }: IResolveComponentProps) => {
if (!state) {
return null;
}
@@ -91,7 +116,7 @@ const ResolveComponent = ({ state }: IResolveComponentProps) => {
return ;
}
- return ;
+ return ;
};
const Approved = () => {
@@ -125,8 +150,16 @@ const Approved = () => {
);
};
-const ReviewRequired = () => {
+interface IReviewRequiredProps {
+ environment: string;
+}
+
+const ReviewRequired = ({ environment }: IReviewRequiredProps) => {
const theme = useTheme();
+ const projectId = useRequiredPathParam('projectId');
+ const { getChangeRequestRequiredApprovals } =
+ useChangeRequestRequiredApprovals(projectId);
+ const approvals = getChangeRequestRequiredApprovals(environment);
return (
<>
@@ -137,7 +170,7 @@ const ReviewRequired = () => {
Review required
- At least 1 approving review must be submitted before
+ At least {approvals} approvals must be submitted before
changes can be applied
diff --git a/frontend/src/component/changeRequest/changeRequest.types.ts b/frontend/src/component/changeRequest/changeRequest.types.ts
index 64460c7361..3eb076a88c 100644
--- a/frontend/src/component/changeRequest/changeRequest.types.ts
+++ b/frontend/src/component/changeRequest/changeRequest.types.ts
@@ -18,6 +18,7 @@ export interface IChangeRequestEnvironmentConfig {
environment: string;
type: string;
changeRequestEnabled: boolean;
+ requiredApprovals: number;
}
export interface IChangeRequestFeature {
diff --git a/frontend/src/component/common/GeneralSelect/GeneralSelect.tsx b/frontend/src/component/common/GeneralSelect/GeneralSelect.tsx
index 55457ad96a..f4c3851f03 100644
--- a/frontend/src/component/common/GeneralSelect/GeneralSelect.tsx
+++ b/frontend/src/component/common/GeneralSelect/GeneralSelect.tsx
@@ -9,12 +9,15 @@ import {
} from '@mui/material';
import { SELECT_ITEM_ID } from 'utils/testIds';
import { KeyboardArrowDownOutlined } from '@mui/icons-material';
+import { SxProps } from '@mui/system';
+import { Theme } from '@mui/material/styles';
export interface ISelectOption {
key: string;
title?: string;
label?: string;
disabled?: boolean;
+ sx?: SxProps;
}
export interface IGeneralSelectProps extends Omit {
@@ -68,6 +71,7 @@ const GeneralSelect: React.FC = ({
>
{options.map(option => (