diff --git a/frontend/src/component/changeRequest/ChangeRequestSidebar/EnvironmentChangeRequest/EnvironmentChangeRequest.tsx b/frontend/src/component/changeRequest/ChangeRequestSidebar/EnvironmentChangeRequest/EnvironmentChangeRequest.tsx
index f664c2825a..c13d3e50b5 100644
--- a/frontend/src/component/changeRequest/ChangeRequestSidebar/EnvironmentChangeRequest/EnvironmentChangeRequest.tsx
+++ b/frontend/src/component/changeRequest/ChangeRequestSidebar/EnvironmentChangeRequest/EnvironmentChangeRequest.tsx
@@ -46,7 +46,7 @@ const ChangeRequestHeader = styled(Box)(({ theme }) => ({
const ChangeRequestContent = styled(Box)(({ theme }) => ({
padding: theme.spacing(3, 3, 3, 3),
border: '2px solid',
- mb: 5,
+ marginBottom: theme.spacing(5),
borderColor: theme.palette.divider,
borderRadius: `0 0 ${theme.shape.borderRadiusLarge}px ${theme.shape.borderRadiusLarge}px`,
borderTop: 'none',
diff --git a/frontend/src/component/layout/MainLayout/DraftBanner/DraftBanner.tsx b/frontend/src/component/layout/MainLayout/DraftBanner/DraftBanner.tsx
index dbefa5f066..68d1c03071 100644
--- a/frontend/src/component/layout/MainLayout/DraftBanner/DraftBanner.tsx
+++ b/frontend/src/component/layout/MainLayout/DraftBanner/DraftBanner.tsx
@@ -1,4 +1,4 @@
-import { FC, useState, VFC } from 'react';
+import { FC, Fragment, useMemo, useState, VFC } from 'react';
import { Box, Button, styled, Typography } from '@mui/material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { ChangeRequestSidebar } from 'component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar';
@@ -37,43 +37,61 @@ const StyledBox = styled(Box)(({ theme }) => ({
}));
const DraftBannerContent: FC<{
- changeRequest: IChangeRequest;
+ changeRequests: IChangeRequest[];
onClick: () => void;
-}> = ({ changeRequest, onClick }) => {
+}> = ({ changeRequests, onClick }) => {
+ const environments = changeRequests.map(({ environment }) => environment);
+ const allChangesCount = changeRequests.reduce(
+ (acc, curr) => acc + changesCount(curr),
+ 0
+ );
+ const showOneLongExplanation =
+ changeRequests.length === 1 &&
+ ['Draft', 'In review', 'Approved'].includes(changeRequests[0].state);
+ const explanation = showOneLongExplanation
+ ? {
+ Draft: ' that need to be reviewed',
+ 'In review': ' that are in review',
+ Approved:
+ ' that are approved. Adding more changes will clear the approvals and require a new review',
+ }[changeRequests[0].state as 'Draft' | 'In review' | 'Approved']
+ : '';
+
return (
Change request mode – You have changes{' '}
- in {changeRequest.environment}
+ in{' '}
+ {environments.map((env, i) =>
+ i === 0 ? (
+
+ {env}
+
+ ) : (
+
+ {i === environments.length - 1
+ ? ' and '
+ : ', '}
+ {env}
+
+ )
+ )}
>
}
/>
-
-
-
+ {explanation}.
@@ -94,30 +112,33 @@ export const DraftBanner: VFC = ({ project }) => {
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const { data, loading } = usePendingChangeRequests(project);
+ const unfinishedChangeRequests = useMemo(
+ () =>
+ data?.filter(changeRequest =>
+ ['Draft', 'In review', 'Approved'].includes(changeRequest.state)
+ ),
+ [data]
+ );
+
if ((!loading && !data) || data?.length === 0) {
return null;
}
return (
- {data?.length
- ? data
- .filter(changeRequest =>
- ['Draft', 'In review', 'Approved'].includes(
- changeRequest.state
- )
- )
- .map(changeRequest => (
- {
- setIsSidebarOpen(true);
- }}
- />
- ))
- : null}
-
+ {
+ setIsSidebarOpen(true);
+ }}
+ />
+ }
+ />