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

src/dag-scheduler/components/task-dependency.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { Box } from '@mui/system';
1111

1212
import { Edge } from 'reactflow';
1313
import { useWorkflowStore } from '../hooks';
14-
import { CustomSelect } from './forms/select-box';
1514
import { Close } from '@mui/icons-material';
1615
// TODO: tree-shake
1716
import { uniqBy } from 'lodash';
17+
import { CustomSelect } from './styled';
1818

1919
const getDiff = (previous: string[], current: string[]) => {
2020
const added = current

src/dag-scheduler/components/task-status.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { FC } from 'react';
22
import { TaskStatus } from '../model';
33
import { ErrorOutlineRounded, WarningAmberOutlined } from '@mui/icons-material';
4-
import { CircularProgress, Tooltip } from '@mui/material';
4+
import { CircularProgress } from '@mui/material';
55

66
type Props = {
77
status?: TaskStatus;
@@ -14,17 +14,9 @@ const TaskStatusComponent: FC<Props> = ({
1414
}) => {
1515
switch (status) {
1616
case TaskStatus.FAILED_TO_UPDATE:
17-
return (
18-
<Tooltip title={message}>
19-
<WarningAmberOutlined color="warning" />
20-
</Tooltip>
21-
);
17+
return <WarningAmberOutlined color="warning" />;
2218
case TaskStatus.FAILED_TO_CREATE:
23-
return (
24-
<Tooltip title={message}>
25-
<ErrorOutlineRounded color="error" />
26-
</Tooltip>
27-
);
19+
return <ErrorOutlineRounded color="error" />;
2820
case TaskStatus.CREATING:
2921
return <CircularProgress size={16} />;
3022
default:

src/dag-scheduler/components/workflow-editor/connection-line.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ import { useWorkflowStore } from '../../hooks';
99
import { TaskStatus } from '../../model';
1010

1111
export const ConnectionLine: FC<ConnectionLineComponentProps> = props => {
12-
const {
13-
toX,
14-
toY,
15-
connectionStatus,
16-
fromX,
17-
fromY,
18-
fromPosition,
19-
toPosition
20-
} = props;
12+
const { toX, toY, connectionStatus, fromX, fromY, fromPosition, toPosition } =
13+
props;
2114

2215
const { getState } = useStoreApi();
2316
const useStore = useWorkflowStore();

src/dag-scheduler/contants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ export enum WorkflowsViewType {
5656
Tasks = 'Tasks'
5757
}
5858

59-
export const notificationTypes = Object.entries(
60-
NotificationEvents
61-
).map(([label, value]) => ({ value, label }));
59+
export const notificationTypes = Object.entries(NotificationEvents).map(
60+
([label, value]) => ({ value, label })
61+
);
6262

63-
export const outputFormatTypes = Object.entries(
64-
OutputFormats
65-
).map(([label, value]) => ({ value, label }));
63+
export const outputFormatTypes = Object.entries(OutputFormats).map(
64+
([label, value]) => ({ value, label })
65+
);
6666

6767
export const triggerRuleTypes = Object.entries(TriggerRules).map(
6868
([label, value]) => ({

src/dag-scheduler/mainviews/create-workflow-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useTranslator, useWorkflows } from '../hooks';
88
import { Scheduler } from '../handler';
99
import { CreateWorkflow } from './create-workflow';
1010
import { emptyCreateJobDefinitionModel } from '../model';
11-
import { StyledAlert, StyledDrawer } from '../components/styled/drawer';
11+
import { StyledAlert, StyledDrawer } from '../components/styled';
1212

1313
export const CreateWorkflowView: FC = () => {
1414
const navigate = useNavigate();

src/dag-scheduler/mainviews/create-workflow.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ import {
3636
Step,
3737
StepLabel,
3838
Stepper,
39-
TextField,
40-
TextFieldProps,
4139
Tooltip,
42-
Typography,
43-
styled
40+
Typography
4441
} from '@mui/material';
4542

4643
import { Box, Stack } from '@mui/system';
@@ -74,6 +71,7 @@ import { useLocation } from 'react-router-dom';
7471
import { AsyncButton } from '../components/async-button';
7572
import moment from 'moment';
7673
import { Dropzone } from '../components/drop-zone';
74+
import { CustomTextField } from '../components/styled';
7775

7876
export interface ICreateWorkflowProps {
7977
model: Scheduler.IJobDefinition;
@@ -105,17 +103,6 @@ type FormData = {
105103
workflowNotificationEmails: Contact[];
106104
};
107105

108-
const CustomTextField = styled(TextField)<TextFieldProps>(({ theme }) => ({
109-
'& fieldset': { top: 0 },
110-
'& legend': {
111-
display: 'none',
112-
color: theme.palette.grey,
113-
marginBottom: theme.spacing(2)
114-
},
115-
'& .MuiInputLabel-shrink': { opacity: 0 },
116-
'& .MuiInputLabel-root': { color: 'var(--jp-border-color0)' }
117-
}));
118-
119106
export function CreateWorkflow(props: ICreateWorkflowProps): JSX.Element {
120107
const trans = useTranslator('jupyterlab');
121108
const { api, namespaces, kernelSpecs } = useWorkflows();

0 commit comments

Comments
 (0)