From b8c3833ae465a3a3ebdcc9464f8580c96d6703a5 Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:00:48 +0200 Subject: [PATCH] Suggest changes - initial frontend (#2213) * feat: add initial controller * feat: add fe * feat: return status codes * remove backend experiment * refactor standalone route for project banner * update suggest changeset type * refactor changeset mock * suggest changes banner feature flag * fix: update routes snapshot Co-authored-by: Fredrik Oseberg --- frontend/src/component/App.styles.ts | 4 +- frontend/src/component/App.tsx | 55 ++++--- .../FlexibleStrategy/FlexibleStrategy.tsx | 1 - .../layout/LayoutPicker/LayoutPicker.tsx | 42 ++--- .../layout/MainLayout/MainLayout.tsx | 93 ++++++----- .../__snapshots__/routes.test.tsx.snap | 2 + frontend/src/component/menu/routes.ts | 6 + .../src/component/project/Project/Project.tsx | 22 ++- .../ChangesHeader/ChangesHeader.tsx | 37 +++++ .../ChangesetDiff/ChangesetDiff.tsx | 77 +++++++++ .../DraftBanner/DraftBanner.tsx | 63 ++++++++ .../SuggestedChanges/SuggestedChanges.tsx | 149 ++++++++++++++++++ .../useChangeRequest/useChangeRequest.ts | 50 ++++++ frontend/src/interfaces/route.ts | 1 + frontend/src/interfaces/suggestChangeset.ts | 52 ++++++ frontend/src/interfaces/uiConfig.ts | 1 + frontend/src/utils/formatDate.ts | 2 + src/server-dev.ts | 1 + 18 files changed, 557 insertions(+), 101 deletions(-) create mode 100644 frontend/src/component/project/Project/SuggestedChanges/ChangesHeader/ChangesHeader.tsx create mode 100644 frontend/src/component/project/Project/SuggestedChanges/ChangesetDiff/ChangesetDiff.tsx create mode 100644 frontend/src/component/project/Project/SuggestedChanges/DraftBanner/DraftBanner.tsx create mode 100644 frontend/src/component/project/Project/SuggestedChanges/SuggestedChanges.tsx create mode 100644 frontend/src/hooks/api/getters/useChangeRequest/useChangeRequest.ts create mode 100644 frontend/src/interfaces/suggestChangeset.ts diff --git a/frontend/src/component/App.styles.ts b/frontend/src/component/App.styles.ts index c6b04a0447..f0bb1ed7b3 100644 --- a/frontend/src/component/App.styles.ts +++ b/frontend/src/component/App.styles.ts @@ -18,10 +18,12 @@ export const useStyles = makeStyles()(theme => ({ flex: 1, width: '100%', backgroundColor: theme.palette.contentWrapper, + position: 'relative', }, content: { width: '1250px', - margin: '16px auto', + marginLeft: 'auto', + marginRight: 'auto', [theme.breakpoints.down('lg')]: { width: '1024px', }, diff --git a/frontend/src/component/App.tsx b/frontend/src/component/App.tsx index 8c7776bc10..9ff43b3e8f 100644 --- a/frontend/src/component/App.tsx +++ b/frontend/src/component/App.tsx @@ -40,36 +40,41 @@ export const App = () => { elseShow={
- - - {availableRoutes.map(route => ( - + {availableRoutes.map(route => ( + - } - /> - ))} - + } /> - } - /> - - - - + ))} + + } + /> + } + /> + + +
} /> diff --git a/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx b/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx index 9f10c53c8e..c2f3904e0d 100644 --- a/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx +++ b/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx @@ -2,7 +2,6 @@ import { Typography } from '@mui/material'; import { IFeatureStrategyParameters } from 'interfaces/strategy'; import RolloutSlider from '../RolloutSlider/RolloutSlider'; import Select from 'component/common/select'; -import React from 'react'; import Input from 'component/common/Input/Input'; import { FLEXIBLE_STRATEGY_GROUP_ID, diff --git a/frontend/src/component/layout/LayoutPicker/LayoutPicker.tsx b/frontend/src/component/layout/LayoutPicker/LayoutPicker.tsx index 01704a1970..359b8ec249 100644 --- a/frontend/src/component/layout/LayoutPicker/LayoutPicker.tsx +++ b/frontend/src/component/layout/LayoutPicker/LayoutPicker.tsx @@ -1,37 +1,19 @@ +import { FC, ReactNode } from 'react'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { matchPath } from 'react-router'; -import { useLocation } from 'react-router-dom'; import { MainLayout } from '../MainLayout/MainLayout'; -import { ReactNode } from 'react'; interface ILayoutPickerProps { children: ReactNode; + isStandalone?: boolean; } -export const LayoutPicker = ({ children }: ILayoutPickerProps) => { - const { pathname } = useLocation(); - - return ( - {children}} - /> - ); -}; - -const isStandalonePage = (pathname: string): boolean => { - return standalonePagePatterns.some(pattern => { - return matchPath(pattern, pathname); - }); -}; - -const standalonePagePatterns = [ - '/login', - '/new-user', - '/reset-password', - '/reset-password-success', - '/forgotten-password', - '/splash/:splashId', - '/404', -]; +export const LayoutPicker: FC = ({ + isStandalone, + children, +}) => ( + {children}} + /> +); diff --git a/frontend/src/component/layout/MainLayout/MainLayout.tsx b/frontend/src/component/layout/MainLayout/MainLayout.tsx index abf6149ad6..d5cb503b92 100644 --- a/frontend/src/component/layout/MainLayout/MainLayout.tsx +++ b/frontend/src/component/layout/MainLayout/MainLayout.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from 'react'; +import React, { forwardRef, ReactNode } from 'react'; import classnames from 'classnames'; import { makeStyles } from 'tss-react/mui'; import { Grid } from '@mui/material'; @@ -30,47 +30,58 @@ const useStyles = makeStyles()(theme => ({ interface IMainLayoutProps { children: ReactNode; + subheader?: ReactNode; } -export const MainLayout = ({ children }: IMainLayoutProps) => { - const { classes } = useStyles(); - const { classes: styles } = useAppStyles(); - const { uiConfig } = useUiConfig(); +export const MainLayout = forwardRef( + ({ children, subheader }, ref) => { + const { classes } = useStyles(); + const { classes: styles } = useAppStyles(); + const { uiConfig } = useUiConfig(); - return ( - <> - -
- - -
- -
+ +
+ + +
+ {subheader} + - - - {children} -
-
- -
-