Skip to content

Commit aa20cf3

Browse files
Merge pull request #1759 from ral-facilities/unify-styling-across-all-dialog-components-#1484
Unify styling across all dialog components #1484
2 parents 9eb15fe + 8841f16 commit aa20cf3

22 files changed

+2287
-2022
lines changed

src/catalogue/category/catalogueCategoryDialog.component.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ import {
3939
AddCatalogueCategoryWithPlacementIds,
4040
AllowedValues as AllowedValuesPlaceholder,
4141
} from '../../app.types';
42+
import {
43+
FLEX_CONTAINER_PROPS,
44+
FORM_DIALOG_PROPS,
45+
TABLE_DIALOG_PROPS,
46+
} from '../../common/consts';
4247
import { CatalogueCategorySchema, RequestType } from '../../form.schemas';
4348
import handleIMS_APIError from '../../handleIMS_APIError';
44-
import CatalogueItemsPropertiesTable from './property/catalogueItemPropertiesTable.component';
4549
import handleTransferState from '../../handleTransferState';
50+
import CatalogueItemsPropertiesTable from './property/catalogueItemPropertiesTable.component';
4651

4752
// Function to convert a list of strings to a list of numbers
4853
export const convertListToNumbers = (values: string[]): number[] => {
@@ -304,17 +309,22 @@ const CatalogueCategoryDialog = (props: CatalogueCategoryDialogProps) => {
304309
};
305310

306311
return (
307-
<Dialog open={open} maxWidth="lg" fullWidth>
312+
<Dialog
313+
open={open}
314+
{...(isLeaf === 'true' ? TABLE_DIALOG_PROPS : FORM_DIALOG_PROPS)}
315+
>
308316
<DialogTitle>
309317
{requestType === 'patch'
310318
? 'Edit Catalogue Category'
311319
: 'Add Catalogue Category'}
312320
</DialogTitle>
313-
<DialogContent>
321+
<DialogContent sx={{ height: '100%' }}>
314322
<Stack
315323
spacing={1}
316324
sx={{
317325
width: '100%',
326+
height: 'inherit',
327+
overflow: 'auto',
318328
}}
319329
>
320330
<Grid
@@ -326,7 +336,7 @@ const CatalogueCategoryDialog = (props: CatalogueCategoryDialogProps) => {
326336
id="catalogue-category-name-input"
327337
label="Name"
328338
required
329-
sx={{ marginLeft: '4px', marginTop: '8px' }}
339+
sx={{ marginTop: 1, paddingRight: 1 }}
330340
{...register('name')}
331341
error={!!errors.name}
332342
helperText={errors.name?.message}
@@ -407,11 +417,18 @@ const CatalogueCategoryDialog = (props: CatalogueCategoryDialogProps) => {
407417
{isLeaf === 'true' && (
408418
<>
409419
<Divider sx={{ minWidth: '700px' }} />
410-
<Box sx={{ paddingLeft: 1 }}>
420+
<Box
421+
sx={{
422+
paddingLeft: 1,
423+
...FLEX_CONTAINER_PROPS,
424+
minHeight: '500px',
425+
}}
426+
>
411427
<Typography variant="h6">Catalogue Item Properties</Typography>
412428
<Box
413429
sx={{
414430
mt: 1,
431+
...FLEX_CONTAINER_PROPS,
415432
}}
416433
>
417434
<FormProvider {...formMethods}>

src/catalogue/category/catalogueCategoryDirectoryDialog.component.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
useGetCatalogueCategory,
1919
useMoveToCatalogueCategory,
2020
} from '../../api/catalogueCategories';
21+
import { FLEX_CONTAINER_PROPS, TABLE_DIALOG_PROPS } from '../../common/consts';
2122
import handleTransferState from '../../handleTransferState';
2223
import Breadcrumbs from '../../view/breadcrumbs.component';
2324
import CatalogueCategoryTableView from './catalogueCategoryTableView.component';
@@ -133,13 +134,8 @@ const CatalogueCategoryDirectoryDialog = (
133134
useGetCatalogueBreadcrumbs(parentCategoryId);
134135

135136
return (
136-
<Dialog
137-
open={open}
138-
maxWidth="lg"
139-
slotProps={{ paper: { sx: { height: 'xl' } } }}
140-
fullWidth
141-
>
142-
<DialogTitle sx={{ marginLeft: 2 }}>
137+
<Dialog open={open} {...TABLE_DIALOG_PROPS}>
138+
<DialogTitle sx={{ marginLeft: 2, paddingBottom: 0 }}>
143139
<Grid container spacing={2}>
144140
<Grid>
145141
<Box
@@ -183,7 +179,7 @@ const CatalogueCategoryDirectoryDialog = (
183179
</Grid>
184180
</Grid>
185181
</DialogTitle>
186-
<DialogContent>
182+
<DialogContent sx={{ ...FLEX_CONTAINER_PROPS, minHeight: '500px' }}>
187183
<CatalogueCategoryTableView
188184
selectedCategories={selectedCategories}
189185
catalogueCategoryParentId={parentCategoryId ?? undefined}

src/catalogue/category/catalogueCategoryTableView.component.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { CatalogueCategory } from '../../api/api.types';
2020
import { APISettingsContext } from '../../apiConfigProvider.component';
2121
import {
2222
DEFAULT_ROWS_PER_PAGE_VALUE,
23+
FLEX_CONTAINER_PROPS,
24+
FLEX_TABLE_CONTAINER_PROP,
2325
ROWS_PER_PAGE_OPTIONS,
2426
} from '../../common/consts';
2527
import CriticalityTooltipIcon from '../../common/criticalityTooltipIcon.component';
@@ -31,6 +33,7 @@ import {
3133
COLUMN_FILTER_MODE_OPTIONS,
3234
COLUMN_FILTER_VARIANTS,
3335
criticalityRowStyle,
36+
displayTableRowCountText,
3437
formatDateTimeStrings,
3538
generateUniqueName,
3639
mrtTheme,
@@ -99,7 +102,7 @@ const CatalogueCategoryTableView = (props: CatalogueCategoryTableViewProps) => {
99102
id: 'is_flagged',
100103
filterVariant: COLUMN_FILTER_VARIANTS.boolean,
101104
enableColumnFilterModes: false,
102-
size: 180,
105+
size: 200,
103106
filterSelectOptions: COLUMN_FILTER_BOOLEAN_OPTIONS,
104107
Cell: ({ row }: { row: MRT_Row<CatalogueCategory> }) => {
105108
const showFlagged = row.original.is_flagged;
@@ -120,7 +123,7 @@ const CatalogueCategoryTableView = (props: CatalogueCategoryTableViewProps) => {
120123
filterVariant: COLUMN_FILTER_VARIANTS.string,
121124
filterFn: COLUMN_FILTER_FUNCTIONS.string,
122125
columnFilterModeOptions: COLUMN_FILTER_MODE_OPTIONS.string,
123-
size: 567.5,
126+
size: isCriticalMode ? 680 : 780,
124127
},
125128
{
126129
header: 'Last modified',
@@ -129,13 +132,13 @@ const CatalogueCategoryTableView = (props: CatalogueCategoryTableViewProps) => {
129132
filterVariant: COLUMN_FILTER_VARIANTS.datetime,
130133
filterFn: COLUMN_FILTER_FUNCTIONS.datetime,
131134
columnFilterModeOptions: COLUMN_FILTER_MODE_OPTIONS.datetime,
132-
size: 400,
135+
size: isCriticalMode ? 570 : 670,
133136
enableGrouping: false,
134137
Cell: ({ row }) =>
135138
formatDateTimeStrings(row.original.modified_time, true),
136139
},
137140
];
138-
}, [isSparesDefinitionDefined]);
141+
}, [isCriticalMode, isSparesDefinitionDefined]);
139142

140143
const table = useMaterialReactTable({
141144
// Data
@@ -226,7 +229,8 @@ const CatalogueCategoryTableView = (props: CatalogueCategoryTableViewProps) => {
226229
);
227230
},
228231
},
229-
muiTableContainerProps: { sx: { height: '360.4px' } },
232+
muiTablePaperProps: { sx: FLEX_CONTAINER_PROPS },
233+
muiTableContainerProps: { sx: FLEX_TABLE_CONTAINER_PROP },
230234
muiSearchTextFieldProps: {
231235
size: 'small',
232236
variant: 'outlined',
@@ -278,6 +282,15 @@ const CatalogueCategoryTableView = (props: CatalogueCategoryTableViewProps) => {
278282
</Button>
279283
</Box>
280284
),
285+
renderBottomToolbarCustomActions: ({ table }) =>
286+
displayTableRowCountText(
287+
table,
288+
catalogueCategoryData,
289+
'Catalogue Categories',
290+
{
291+
paddingLeft: '8px',
292+
}
293+
),
281294
});
282295

283296
React.useEffect(() => {
@@ -292,7 +305,11 @@ const CatalogueCategoryTableView = (props: CatalogueCategoryTableViewProps) => {
292305
});
293306
}, [isCriticalMode, table]);
294307

295-
return <MaterialReactTable table={table} />;
308+
return (
309+
<Box sx={{ p: 1, ...FLEX_CONTAINER_PROPS }}>
310+
<MaterialReactTable table={table} />
311+
</Box>
312+
);
296313
};
297314

298315
export default CatalogueCategoryTableView;

src/catalogue/category/property/__snapshots__/catalogueItemPropertiesTable.component.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
exports[`CatalogueItemPropertiesTable > renders table correctly (not editing properties) 1`] = `
44
<DocumentFragment>
55
<div
6-
style="width: 100%;"
6+
class="MuiBox-root css-1wyqftk"
77
>
88
<div
9-
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation2 css-1hoqul-MuiPaper-root"
9+
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation2 css-th9pv0-MuiPaper-root"
1010
style="--Paper-shadow: 0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12);"
1111
>
1212
<div
@@ -209,12 +209,12 @@ exports[`CatalogueItemPropertiesTable > renders table correctly (not editing pro
209209
</div>
210210
</div>
211211
<div
212-
class="MuiTableContainer-root css-1jqhb4h-MuiTableContainer-root"
212+
class="MuiTableContainer-root css-1qjrzjp-MuiTableContainer-root"
213213
data-testid="properties-table-container"
214214
>
215215
<table
216216
class="MuiTable-root MuiTable-stickyHeader css-1gcyac0-MuiTable-root"
217-
style="--header-mrt_row_actions-size: 70; --col-mrt_row_actions-size: 70; --header-name-size: 220; --col-name-size: 220; --header-type-size: 250; --col-type-size: 250; --header-allowed_values-size: 300; --col-allowed_values-size: 300; --header-unit-size: 250; --col-unit-size: 250; --header-property_mandatory-size: 200; --col-property_mandatory-size: 200; --header-mrt_row_spacer-size: 40; --col-mrt_row_spacer-size: 40;"
217+
style="--header-mrt_row_actions-size: 70; --col-mrt_row_actions-size: 70; --header-name-size: 345; --col-name-size: 345; --header-type-size: 250; --col-type-size: 250; --header-allowed_values-size: 345; --col-allowed_values-size: 345; --header-unit-size: 250; --col-unit-size: 250; --header-property_mandatory-size: 200; --col-property_mandatory-size: 200; --header-mrt_row_spacer-size: 40; --col-mrt_row_spacer-size: 40;"
218218
>
219219
<thead
220220
class="MuiTableHead-root css-7psuou-MuiTableHead-root"

src/catalogue/category/property/catalogueItemPropertiesTable.component.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ import {
4040
mrtTheme,
4141
} from '../../../utils';
4242

43+
import {
44+
FLEX_CONTAINER_PROPS,
45+
FLEX_TABLE_CONTAINER_PROP,
46+
} from '../../../common/consts';
47+
4348
import AddIcon from '@mui/icons-material/Add';
4449
import ClearIcon from '@mui/icons-material/Clear';
4550
import EditIcon from '@mui/icons-material/Edit';
@@ -50,10 +55,10 @@ import {
5055
ROWS_PER_PAGE_OPTIONS,
5156
} from '../../../common/consts';
5257
import { RequestType } from '../../../form.schemas';
53-
import PropertyDialog from './propertyDialog.component';
54-
import DeletePropertyDialog from './deletePropertyDialog.component';
5558
import { useAppSelector } from '../../../state/hook';
5659
import { selectAuthorisation } from '../../../state/slices/authorisationSlice';
60+
import DeletePropertyDialog from './deletePropertyDialog.component';
61+
import PropertyDialog from './propertyDialog.component';
5762

5863
export interface PropertiesTableProps {
5964
requestType: RequestType;
@@ -106,7 +111,7 @@ export function CatalogueItemsPropertiesTable(props: PropertiesTableProps) {
106111
Header: TableHeaderOverflowTip,
107112
accessorFn: (row) => row.name,
108113
id: 'name',
109-
size: 220,
114+
size: 345,
110115
filterVariant: COLUMN_FILTER_VARIANTS.string,
111116
filterFn: COLUMN_FILTER_FUNCTIONS.string,
112117
columnFilterModeOptions: COLUMN_FILTER_MODE_OPTIONS.string,
@@ -151,7 +156,7 @@ export function CatalogueItemsPropertiesTable(props: PropertiesTableProps) {
151156
.map((value) => value['value'])
152157
.join(', '),
153158
id: 'allowed_values',
154-
size: 300,
159+
size: 345,
155160
filterVariant: 'multi-select',
156161
filterFn: 'arrIncludesSome',
157162
columnFilterModeOptions: [
@@ -291,8 +296,9 @@ export function CatalogueItemsPropertiesTable(props: PropertiesTableProps) {
291296
//MRT
292297
mrtTheme,
293298
// MUI
299+
muiTablePaperProps: { sx: FLEX_CONTAINER_PROPS },
294300
muiTableContainerProps: {
295-
sx: { height: '350px', width: '1152px' },
301+
sx: FLEX_TABLE_CONTAINER_PROP,
296302
// @ts-expect-error: MRT Table Container props does not have data-testid
297303
'data-testid': 'properties-table-container',
298304
},
@@ -483,7 +489,7 @@ export function CatalogueItemsPropertiesTable(props: PropertiesTableProps) {
483489
}),
484490
});
485491
return (
486-
<div style={{ width: '100%' }}>
492+
<Box sx={{ width: '100%', p: 1, ...FLEX_CONTAINER_PROPS }}>
487493
<MaterialReactTable table={table} />
488494
<DeletePropertyDialog
489495
open={deletePropertyDialogOpen}
@@ -497,7 +503,7 @@ export function CatalogueItemsPropertiesTable(props: PropertiesTableProps) {
497503
selectedProperty={selectedProperty}
498504
catalogueCategory={catalogueCategory}
499505
/>
500-
</div>
506+
</Box>
501507
);
502508
}
503509

src/catalogue/items/__snapshots__/catalogueItemsDialog.component.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports[`Catalogue Items Dialog > renders details step correctly 1`] = `
2929
<div
3030
aria-labelledby=":r0:"
3131
aria-modal="true"
32-
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthLg MuiDialog-paperFullWidth css-1k6wpiw-MuiPaper-root-MuiDialog-paper"
32+
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXl MuiDialog-paperFullWidth css-v3yqi3-MuiPaper-root-MuiDialog-paper"
3333
role="dialog"
3434
style="--Paper-shadow: 0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12);"
3535
>
@@ -731,7 +731,7 @@ exports[`Catalogue Items Dialog > renders properties step correctly 1`] = `
731731
<div
732732
aria-labelledby=":rj:"
733733
aria-modal="true"
734-
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthLg MuiDialog-paperFullWidth css-1k6wpiw-MuiPaper-root-MuiDialog-paper"
734+
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthXl MuiDialog-paperFullWidth css-v3yqi3-MuiPaper-root-MuiDialog-paper"
735735
role="dialog"
736736
style="--Paper-shadow: 0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12);"
737737
>

src/catalogue/items/__snapshots__/catalogueItemsPage.component.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
exports[`CatalogueItemsPage > renders a catalogue items page correctly 1`] = `
44
<DocumentFragment>
55
<div
6-
style="width: 100%;"
6+
class="MuiBox-root css-123hto"
77
>
88
<div
9-
class="MuiStack-root css-17doft4-MuiStack-root"
9+
class="MuiStack-root css-7u13gi-MuiStack-root"
1010
>
1111
<div
12-
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation2 css-1hoqul-MuiPaper-root"
12+
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation2 css-th9pv0-MuiPaper-root"
1313
style="--Paper-shadow: 0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12);"
1414
>
1515
<div
@@ -212,7 +212,7 @@ exports[`CatalogueItemsPage > renders a catalogue items page correctly 1`] = `
212212
</div>
213213
</div>
214214
<div
215-
class="MuiTableContainer-root css-1h4z99x-MuiTableContainer-root"
215+
class="MuiTableContainer-root css-1qjrzjp-MuiTableContainer-root"
216216
data-testid="catalogue-items-table-container"
217217
>
218218
<table

0 commit comments

Comments
 (0)