Skip to content

Commit

Permalink
[202] Update the way change proposals are displayed
Browse files Browse the repository at this point in the history
Bug: #202
Signed-off-by: Stéphane Bégaudeau <[email protected]>
  • Loading branch information
sbegaudeau committed Sep 8, 2023
1 parent 539d530 commit d9a596e
Show file tree
Hide file tree
Showing 35 changed files with 807 additions and 779 deletions.
2 changes: 0 additions & 2 deletions frontend/svalyn-studio-app/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { Route, Routes } from 'react-router-dom';
import { AdminRouter } from '../admin/AdminRouter';
import { ChangeProposalsRouter } from '../changeproposals/ChangeProposalsRouter';
import { DomainsRouter } from '../domains/DomainsRouter';
import { ErrorsRouter } from '../errors/ErrorsRouter';
import { HelpRouter } from '../help/HelpRouter';
Expand Down Expand Up @@ -47,7 +46,6 @@ export const App = () => {
<Route path="/orgs/:organizationIdentifier/*" element={<OrganizationRouter />} />
<Route path="/projects/:projectIdentifier/*" element={<ProjectRouter />} />
<Route path="/projects/:projectIdentifier/changes/:changeId" element={<WorkspaceView />} />
<Route path="/changeproposals/*" element={<ChangeProposalsRouter />} />
<Route path="/domains/*" element={<DomainsRouter />} />
<Route path="/search/*" element={<SearchRouter />} />
<Route path="/profiles/*" element={<ProfilesRouter />} />
Expand Down
118 changes: 0 additions & 118 deletions frontend/svalyn-studio-app/src/changeproposals/ChangeProposalView.tsx

This file was deleted.

This file was deleted.

5 changes: 5 additions & 0 deletions frontend/svalyn-studio-app/src/forms/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export function useForm<FormDataType extends Object>({
isFormValid: false,
});

const reset = () => {
setState((prevState) => ({ ...prevState, data: initialValue, validationState: {}, isFormValid: false }));
};

const getTextFieldProps = (name: keyof FormDataType, helperText?: string): TextFieldProps => {
let error = false;
let computedHelperText: string | undefined = helperText;
Expand Down Expand Up @@ -73,6 +77,7 @@ export function useForm<FormDataType extends Object>({
return {
data: state.data,
isFormValid: state.isFormValid,
reset,
getTextFieldProps,
};
}
Expand Down
1 change: 1 addition & 0 deletions frontend/svalyn-studio-app/src/forms/useForm.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface UseFormProps<FormDataType extends Object> {
export interface UseFormValue<FormDataType extends Object> {
data: FormDataType;
isFormValid: boolean;
reset: () => void;
getTextFieldProps: (name: keyof FormDataType, helperText?: string) => TextFieldProps;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const patterns = [
'/projects/:projectIdentifier',
'/projects/:projectIdentifier/activity',
'/projects/:projectIdentifier/changeproposals',
'/projects/:projectIdentifier/changeproposals/:changeProposalIdentifier',
'/projects/:projectIdentifier/changeproposals/:changeProposalIdentifier/files',
'/projects/:projectIdentifier/new/changeproposal',
'/projects/:projectIdentifier/tags',
'/projects/:projectIdentifier/settings',
Expand Down Expand Up @@ -116,7 +118,7 @@ const AdditionalBreadcrumbEntry = () => {
label: 'Activity',
icon: <TimelineIcon fontSize="inherit" />,
};
} else if (currentTab === '/projects/:projectIdentifier/changeproposals') {
} else if (currentTab?.startsWith('/projects/:projectIdentifier/changeproposals')) {
tabBreadcrumbEntry = {
label: 'Change Proposals',
icon: <DifferenceIcon fontSize="inherit" />,
Expand Down
1 change: 0 additions & 1 deletion frontend/svalyn-studio-app/src/projects/ProjectDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { useRouteMatch } from '../hooks/useRouteMatch';
import { useProject } from './useProject';

const CompactDrawer = styled('div')(({ theme }) => ({
width: '64px',
backgroundColor: theme.palette.background.paper,
borderRight: `1px solid ${theme.palette.divider}`,
}));
Expand Down
2 changes: 2 additions & 0 deletions frontend/svalyn-studio-app/src/projects/ProjectRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { Route, Routes } from 'react-router-dom';
import { ProjectShell } from './ProjectShell';
import { ProjectActivityView } from './activity/ProjectActivityView';
import { ChangeProposalRouter } from './changeproposal/ChangeProposalRouter';
import { ProjectChangeProposalsView } from './changeproposals/ProjectChangeProposalsView';
import { ProjectHomeView } from './home/ProjectHomeView';
import { NewChangeProposalView } from './new-changeproposal/NewChangeProposalView';
Expand All @@ -34,6 +35,7 @@ export const ProjectRouter = () => {
<Route index element={<ProjectHomeView />} />
<Route path="activity" element={<ProjectActivityView />} />
<Route path="changeproposals" element={<ProjectChangeProposalsView />} />
<Route path="changeproposals/:changeProposalIdentifier/*" element={<ChangeProposalRouter />} />
<Route path="tags" element={<ProjectTagsView />} />
<Route path="settings" element={<ProjectSettingsView />} />
<Route path="new/changeproposal" element={<NewChangeProposalView />} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/svalyn-studio-app/src/projects/ProjectShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const ProjectShell = ({ children }: ProjectShellProps) => {
sx={{
display: 'grid',
gridTemplateRows: '1fr',
gridTemplateColumns: 'min-content 1fr',
gridTemplateColumns: '64px calc(100vw - 64px)',
flexGrow: '1',
}}
>
Expand Down
38 changes: 38 additions & 0 deletions frontend/svalyn-studio-app/src/projects/ProjectViewHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 Stéphane Bégaudeau.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import { ProjectViewHeaderProps } from './ProjectViewHeader.types';

export const ProjectViewHeader = ({ children }: ProjectViewHeaderProps) => {
return (
<Toolbar
variant="dense"
sx={{
backgroundColor: 'white',
borderBottom: (theme) => `1px solid ${theme.palette.divider}`,
}}
>
<Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: (theme) => theme.spacing(2) }}>
{children}
</Box>
</Toolbar>
);
};
Loading

0 comments on commit d9a596e

Please sign in to comment.