Skip to content

Commit 39e850b

Browse files
author
Sathish Kumar Thangaraj
committed
Fix minor UI issues and refactor duplicate styled components
1 parent 15e1660 commit 39e850b

26 files changed

+1387
-1344
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dist
33
coverage
44
**/*.d.ts
55
tests
6+
lib
67

78
**/__tests__
89
ui-tests

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@
100100
"@types/jest": "^29",
101101
"@types/lodash": "4.14.192",
102102
"@types/react-show-more-text": "^1.4.5",
103-
"@typescript-eslint/eslint-plugin": "^4.8.1",
104-
"@typescript-eslint/parser": "^4.8.1",
105-
"eslint": "^7.14.0",
103+
"@typescript-eslint/eslint-plugin": "^7.12.0",
104+
"@typescript-eslint/parser": "^7.12.0",
105+
"eslint": "^8.57.0",
106106
"eslint-config-prettier": "^6.15.0",
107107
"eslint-plugin-prettier": "^3.1.4",
108108
"jest": "^29",

src/dag-scheduler/components/advanced-table/advanced-table.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export function AdvancedTable<
267267
...(loading ? { pointerEvents: 'none', opacity: 0.5 } : {})
268268
}}
269269
>
270-
<Table stickyHeader>
270+
<Table stickyHeader style={{ position: 'relative' }}>
271271
<AdvancedTableHeader
272272
columns={props.columns}
273273
query={props.query}
@@ -276,7 +276,13 @@ export function AdvancedTable<
276276
<TableBody role="presentation">
277277
<TableRow>
278278
<TableCell
279-
sx={{ p: 0, height: 5, border: 'none' }}
279+
sx={{
280+
p: 0,
281+
height: 5,
282+
width: '100%',
283+
border: 'none',
284+
position: 'absolute'
285+
}}
280286
colSpan={props.columns.length}
281287
>
282288
{loading ? <LinearProgress /> : null}

src/dag-scheduler/components/external-links.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ export const ExternalLinks: FC<ExternalLinksProps> = ({ options }) => {
4444
<ArrowOutward fontSize="small" />
4545
</IconButton>
4646
<Popper
47-
sx={{
48-
zIndex: 1
49-
}}
5047
open={open}
51-
anchorEl={anchorRef.current}
52-
role={undefined}
5348
transition
5449
disablePortal
50+
role={undefined}
51+
sx={{ zIndex: 1 }}
52+
anchorEl={anchorRef.current}
5553
>
5654
{({ TransitionProps, placement }) => (
5755
<Grow

src/dag-scheduler/components/forms/select-box.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ import React, { FC } from 'react';
33
import {
44
FormControl,
55
MenuItem,
6-
Select,
76
ListSubheader,
87
SelectChangeEvent,
98
FormHelperText,
10-
styled,
119
SelectProps,
1210
FormLabel,
1311
Typography,
1412
InputLabel
1513
} from '@mui/material';
1614
import { Controller, UseControllerProps } from 'react-hook-form';
15+
import { CustomSelect } from '../styled';
1716

1817
type Option = {
1918
value: string;
@@ -43,11 +42,6 @@ export type GroupSelectBoxProps = Props & {
4342
}[];
4443
};
4544

46-
export const CustomSelect = styled(Select as any)<SelectProps<string>>(() => ({
47-
'& fieldset': { top: 0 },
48-
'& legend': { display: 'none' }
49-
}));
50-
5145
const SelectComponent: FC<SelectBoxProps | GroupSelectBoxProps> = props => {
5246
const labelId = `${props.id}-label`;
5347
const isRequired = props.rules?.required || props.rules?.validate;

src/dag-scheduler/components/forms/text-field.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import React, { FC } from 'react';
22
import { Controller, UseControllerProps } from 'react-hook-form';
3-
import TextField, { TextFieldProps } from '@mui/material/TextField';
4-
import { FormControl, FormLabel, Typography, styled } from '@mui/material';
3+
import { TextFieldProps } from '@mui/material/TextField';
4+
import { FormControl, FormLabel, Typography } from '@mui/material';
5+
import { CustomTextField } from '../styled';
56

67
type FormInputProps = TextFieldProps & UseControllerProps;
78

8-
const CustomTextField = styled(TextField)<TextFieldProps>(({ theme }) => ({
9-
'& fieldset': { top: 0 },
10-
'& legend': {
11-
display: 'none',
12-
color: theme.palette.grey,
13-
marginBottom: theme.spacing(2)
14-
}
15-
}));
16-
179
// TODO: Split the props into 2 groups (one for hook-form and one for mui)
1810
export const FormInputText: FC<FormInputProps> = ({
1911
name,

src/dag-scheduler/components/job-row.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function Timestamp(props: { job: Scheduler.IDescribeJob }): JSX.Element | null {
1919

2020
export function buildJobRow(
2121
model: Scheduler.IDescribeJob,
22-
translateStatus: (status: Scheduler.Status) => string,
2322
showDetailView: (jobId: string) => void
2423
): JSX.Element {
2524
const trans = useTranslator('jupyterlab');

src/dag-scheduler/components/styled/drawer.tsx renamed to src/dag-scheduler/components/styled/index.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Alert, Drawer, IconButton, styled } from '@mui/material';
1+
import {
2+
Alert,
3+
Drawer,
4+
IconButton,
5+
Select,
6+
SelectProps,
7+
TextField,
8+
TextFieldProps,
9+
styled
10+
} from '@mui/material';
211
import { Stack } from '@mui/system';
312

413
export const StyledDrawer = styled(Drawer)({
@@ -39,3 +48,21 @@ export const StyledAlert = styled(Alert)({
3948
position: 'relative',
4049
boxSizing: 'border-box'
4150
});
51+
52+
export const CustomSelect = styled(Select as any)<SelectProps<string>>(() => ({
53+
'& fieldset': { top: 0 },
54+
'& legend': { display: 'none' }
55+
}));
56+
57+
export const CustomTextField = styled(TextField)<TextFieldProps>(
58+
({ theme }) => ({
59+
'& fieldset': { top: 0 },
60+
'& legend': {
61+
display: 'none',
62+
color: theme.palette.grey,
63+
marginBottom: theme.spacing(2)
64+
},
65+
'& .MuiInputLabel-shrink': { opacity: 0 },
66+
'& .MuiInputLabel-root': { color: 'var(--jp-border-color0)' }
67+
})
68+
);

src/dag-scheduler/components/styled/page-header.tsx

Whitespace-only changes.

src/dag-scheduler/components/table-filter.tsx

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,32 +150,32 @@ function FilterForm({ value, columns, onSave, onClose }: FilterFormProps) {
150150
value.length ? [...value] : [{ ...DEFAULT_ITEM }]
151151
);
152152

153-
const handleInputChange = (index: number) => (
154-
fieldName: keyof FilterItem,
155-
fieldValue: string
156-
) => {
157-
const nextState = filters.length ? filters.slice() : [{ ...DEFAULT_ITEM }];
153+
const handleInputChange =
154+
(index: number) => (fieldName: keyof FilterItem, fieldValue: string) => {
155+
const nextState = filters.length
156+
? filters.slice()
157+
: [{ ...DEFAULT_ITEM }];
158158

159-
nextState[index][fieldName] = fieldValue;
159+
nextState[index][fieldName] = fieldValue;
160160

161-
// Reset the filter value, if column is changed and retain the condition if possible
162-
if (fieldName === 'field') {
163-
const currentColumn = columns.find(c => c.field === fieldValue);
164-
const { type } = currentColumn || ({} as AdvancedTableColumn);
161+
// Reset the filter value, if column is changed and retain the condition if possible
162+
if (fieldName === 'field') {
163+
const currentColumn = columns.find(c => c.field === fieldValue);
164+
const { type } = currentColumn || ({} as AdvancedTableColumn);
165165

166-
const current = nextState[index]['condition'];
167-
const { options } = operators[type || 'string'];
168-
const isConditionValid = options.find(o => o === current);
166+
const current = nextState[index]['condition'];
167+
const { options } = operators[type || 'string'];
168+
const isConditionValid = options.find(o => o === current);
169169

170-
const defaultOp =
171-
(isConditionValid ? current : null) || (fieldValue ? options[0] : '');
170+
const defaultOp =
171+
(isConditionValid ? current : null) || (fieldValue ? options[0] : '');
172172

173-
nextState[index]['value'] = '';
174-
nextState[index]['condition'] = defaultOp;
175-
}
173+
nextState[index]['value'] = '';
174+
nextState[index]['condition'] = defaultOp;
175+
}
176176

177-
setFilters(nextState);
178-
};
177+
setFilters(nextState);
178+
};
179179

180180
const handleAddFilter = () => {
181181
setFilters([...filters, { ...DEFAULT_ITEM }]);
@@ -265,9 +265,8 @@ function FilterRow({
265265
dataType || 'string'
266266
);
267267

268-
const { options, Component, ComponentProps } = operators[
269-
columnType || 'string'
270-
];
268+
const { options, Component, ComponentProps } =
269+
operators[columnType || 'string'];
271270

272271
const isDateType = columnType === 'date';
273272

0 commit comments

Comments
 (0)