Skip to content

Commit 71a5082

Browse files
committed
fix build eslint
1 parent 4f34a39 commit 71a5082

33 files changed

+1607
-1789
lines changed

package-lock.json

Lines changed: 1305 additions & 1565 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Routes/SidebarRight/AddPipeline/Steps/Nodes/Algorithms.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { createContext, useContext } from 'react';
1+
import React, { createContext, useContext, useMemo } from 'react';
22
import PropTypes from 'prop-types';
33
import { InputNumber, Switch, Radio, AutoComplete } from 'antd';
44
import { Form as CommonForm } from 'components/common';
@@ -21,9 +21,12 @@ const Field = props => {
2121
const AlgorithmNode = ({ id }) => {
2222
const { isStreamingPipeline, valuesState } = useWizardContext();
2323
const { algorithms: sortedAlgorithms } = useGetLists();
24-
const rootId = ['nodes', id];
24+
const rootId = useMemo(() => ['nodes', id], [id]);
25+
26+
const contextValue = useMemo(() => ({ rootId }), [rootId]);
27+
2528
return (
26-
<ctx.Provider value={{ rootId }}>
29+
<ctx.Provider value={contextValue}>
2730
<Field name={['algorithmName']} title="Algorithm">
2831
<AutoComplete
2932
disabled={sortedAlgorithms?.length === 0}
@@ -110,7 +113,7 @@ const AlgorithmNode = ({ id }) => {
110113

111114
{!isStreamingPipeline && (
112115
<Field
113-
overrides={{ ...{ valuePropName: 'checked' } }}
116+
overrides={{ valuePropName: 'checked' }}
114117
title="Include In Pipeline Results"
115118
name={['includeInResult']}
116119
skipValidation>
@@ -120,7 +123,7 @@ const AlgorithmNode = ({ id }) => {
120123

121124
{!isStreamingPipeline && (
122125
<Field
123-
overrides={{ ...{ valuePropName: 'checked' } }}
126+
overrides={{ valuePropName: 'checked' }}
124127
title="Create A Tensorboard"
125128
name={['metrics', 'tensorboard']}
126129
skipValidation>
@@ -135,4 +138,5 @@ const AlgorithmNode = ({ id }) => {
135138
AlgorithmNode.propTypes = {
136139
id: PropTypes.node.isRequired,
137140
};
141+
138142
export default AlgorithmNode;

src/Routes/SidebarRight/AddPipeline/Steps/Nodes/DataSource.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,40 @@ const DataSourceNode = ({ id }) => {
3636
initialState?.nodes[id]?.spec?.snapshot
3737
? MODES.SNAPSHOT
3838
: initialState?.nodes[id]?.spec?.id
39-
? MODES.VERSION
40-
: MODES.LATEST
39+
? MODES.VERSION
40+
: MODES.LATEST
4141
);
4242

4343
const activeName = form.getFieldValue(['nodes', id, 'spec', 'name']);
4444
const { versionsCollection } = useVersions({ name: activeName });
4545
const { snapshots } = useSnapshots({ dataSourceName: activeName });
4646

4747
// eslint-disable-next-line react-hooks/exhaustive-deps
48-
const handleChangeMode = useCallback(e => {
49-
setTimeout(() => {
50-
setForm();
51-
}, 500);
48+
const handleChangeMode = useCallback(
49+
e => {
50+
setTimeout(() => {
51+
setForm();
52+
}, 500);
5253

53-
return setMode(e.target.value);
54-
});
55-
const disableSnapshot = useMemo(() => snapshots?.length === 0, [
56-
snapshots?.length,
57-
]);
54+
return setMode(e.target.value);
55+
},
56+
[setForm]
57+
);
58+
59+
const disableSnapshot = useMemo(
60+
() => snapshots?.length === 0,
61+
[snapshots?.length]
62+
);
63+
64+
const disableVersions = useMemo(
65+
() => versionsCollection?.length === 0,
66+
[versionsCollection?.length]
67+
);
5868

59-
const disableVersions = useMemo(() => versionsCollection?.length === 0, [
60-
versionsCollection?.length,
61-
]);
69+
const contextValue = useMemo(() => ({ rootId: ['nodes', id, 'spec'] }), [id]);
6270

6371
return (
64-
<ctx.Provider value={{ rootId: ['nodes', id, 'spec'] }}>
72+
<ctx.Provider value={contextValue}>
6573
<Field name={['name']} title="DataSource Name">
6674
<Select disabled={collection && collection.length === 0}>
6775
{collection.map(({ name }) => (

src/Routes/SidebarRight/AddPipeline/Steps/Nodes/Gateway.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect } from 'react';
1+
import React, { useContext, useEffect, useMemo } from 'react';
22
import PropTypes from 'prop-types';
33
import { Select, Input, InputNumber } from 'antd';
44

@@ -28,9 +28,14 @@ const GatewayNode = ({ id }) => {
2828
form.setFieldsValue(nodes);
2929
}, [form, id]);
3030

31+
const providerValue = useMemo(
32+
() => ({ rootId: ['nodes', id, 'spec'] }),
33+
[id]
34+
);
35+
3136
return (
3237
<>
33-
<ctx.Provider value={{ rootId: ['nodes', id, 'spec'] }}>
38+
<ctx.Provider value={providerValue}>
3439
<Field name={['name']} title="Name">
3540
<Input placeholder="Name Gateway" />
3641
</Field>

src/Routes/SidebarRight/AddPipeline/Steps/Nodes/HyperParams.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useState } from 'react';
1+
import React, { useContext, useMemo, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import {
44
Form,
@@ -88,8 +88,10 @@ const HyperParamsNode = ({ id }) => {
8888
}
8989
};
9090

91+
const contextValue = useMemo(() => ({ rootId }), [rootId]);
92+
9193
return (
92-
<ctx.Provider value={{ rootId }}>
94+
<ctx.Provider value={contextValue}>
9395
<Field name={['objectivePipeline']} title="Objective Pipeline">
9496
<AutoComplete
9597
disabled={pipelinesCollection?.length === 0}

src/Routes/SidebarRight/AddPipeline/Steps/Nodes/InputParseJson/useInputField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const useInputField = (antFields, onRemove, inputRef, selectWidth) => {
126126

127127
const { rules, label } = antFields?.addonBefore.filter(
128128
x => x.value === selectBefore
129-
)[0];
129+
)[0] || { rules: [], label: '' };
130130

131131
setValue(srcValue);
132132

src/Routes/SidebarRight/AddPipeline/Steps/Nodes/Output.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext } from 'react';
1+
import React, { useContext, useMemo } from 'react';
22
import PropTypes from 'prop-types';
33
import { Select, Input, Divider } from 'antd';
44
import Controller from './InputParseJson';
@@ -18,8 +18,11 @@ const Field = props => {
1818
const OutputNode = ({ id }) => {
1919
const { initialState } = useWizardContext();
2020
const rootId = ['nodes', id, 'spec'];
21+
22+
const contextValue = useMemo(() => ({ rootId }), [rootId]);
23+
2124
return (
22-
<ctx.Provider value={{ rootId }}>
25+
<ctx.Provider value={contextValue}>
2326
<Field name={['description']} title="Description" skipValidation>
2427
<Input placeholder="Description" />
2528
</Field>
@@ -44,7 +47,9 @@ const OutputNode = ({ id }) => {
4447
</ctx.Provider>
4548
);
4649
};
50+
4751
OutputNode.propTypes = {
4852
id: PropTypes.node.isRequired,
4953
};
54+
5055
export default OutputNode;

src/Routes/SidebarRight/Drawer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from 'react';
1+
import React, { useCallback, useMemo } from 'react';
22
import Drawer from 'components/Drawer';
33
import { TabDrawerText, TabDrawer } from 'styles';
44
import { RIGHT_SIDEBAR_NAMES } from 'const';
@@ -67,13 +67,15 @@ const DashboardDrawer = () => {
6767
const width = CONTENT_CONFIG[panelType]?.width ?? 0;
6868
const titleDrawer = titleSelector[panelType];
6969

70+
const contextValue = useMemo(() => ({ closeDrawer: setOff }), [setOff]);
71+
7072
if (root === undefined) {
7173
navigate('/jobs');
7274
}
7375

7476
// eslint-disable-next-line consistent-return
7577
return (
76-
<ctx.Provider value={{ closeDrawer: setOff }}>
78+
<ctx.Provider value={contextValue}>
7779
<Drawer
7880
width={width}
7981
isOpened={isOn}

src/Routes/SidebarRight/ErrorLogs/ErrorLogQueryTable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { FiltersForms } from 'styles';
88
import qs from 'qs';
99

1010
const { RangePicker } = DatePicker;
11-
let localValueTimeChanged = 1;
11+
// let localValueTimeChanged = 1;
1212
const DateFormat = 'YYYY-MM-DD HH:mm';
1313

1414
const ErrorLogQueryTable = ({ onSubmit, ErrorLogList }) => {
@@ -92,7 +92,7 @@ const ErrorLogQueryTable = ({ onSubmit, ErrorLogList }) => {
9292
format={DateFormat}
9393
onOpenChange={() => {
9494
// eslint-disable-next-line no-unused-vars
95-
localValueTimeChanged = Date.now();
95+
// localValueTimeChanged = Date.now();
9696
}}
9797
onChange={SubmitForm}
9898
/>

src/Routes/SidebarRight/NodeStatistics.react.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,22 @@ const Container = styled.div`
1515
}
1616
`;
1717

18-
// https://nivo.rocks/bar/ customization
18+
// Define the custom formatter component outside of NodeStatistics
19+
const CustomAxisLeftTick = ({ value }) =>
20+
value.length > 15 ? (
21+
<tspan>
22+
{`${value.substring(0, 15)}...`}
23+
<title>{value}</title>
24+
</tspan>
25+
) : (
26+
value
27+
);
28+
29+
CustomAxisLeftTick.propTypes = {
30+
value: PropTypes.string.isRequired,
31+
};
32+
33+
// NodeStatistics component
1934
const NodeStatistics = ({ metric }) => {
2035
const { data, legend } = useMetric(metric);
2136

@@ -44,7 +59,6 @@ const NodeStatistics = ({ metric }) => {
4459
legend: {
4560
text: {
4661
fontSize: 19,
47-
4862
fill: whiteColor,
4963
},
5064
},
@@ -104,15 +118,7 @@ const NodeStatistics = ({ metric }) => {
104118
legendOffset: 50,
105119
}}
106120
axisLeft={{
107-
format: v =>
108-
v.length > 15 ? (
109-
<tspan>
110-
{`${v.substring(0, 15)}...`}
111-
<title>{v}</title>
112-
</tspan>
113-
) : (
114-
v
115-
),
121+
format: CustomAxisLeftTick, // Use the custom formatter component
116122
tickSize: 5,
117123
tickPadding: 5,
118124
tickRotation: 20,

src/Routes/Tables/Algorithms/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ const AlgorithmsTable = () => {
6969
}
7070

7171
return (
72-
(queryVal.data?.algorithms?.list &&
73-
[...queryVal.data?.algorithms?.list].sort((x, y) =>
72+
(queryVal.data &&
73+
queryVal.data.algorithms &&
74+
queryVal.data.algorithms.list &&
75+
[...queryVal.data.algorithms.list].sort((x, y) =>
7476
x.modified < y.modified ? 1 : -1
7577
)) ||
7678
[]

src/Routes/Tables/Drivers/DriversTableColumns.react.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import Ellipsis from 'components/common/Ellipsis.react';
34
import { StatusTag as CountTag } from 'components/StatusTag';
45
import { sorter } from 'utils/stringHelper';
56

7+
const Jobs = ({ jobs }) => <CountTag count={jobs?.length | 0} />;
8+
Jobs.propTypes = {
9+
jobs: PropTypes.array.isRequired,
10+
};
11+
export default Jobs;
12+
613
const DriverId = driverId => <Ellipsis text={driverId} />;
714
const PodName = podName => <Ellipsis copyable text={podName} />;
815
const Status = status => <Ellipsis text={status} />;
9-
const Jobs = jobs => <CountTag count={jobs.length} />;
1016
const Max = count => <CountTag count={count} />;
1117
const Capacity = count => <CountTag count={count} />;
1218
const Active = active => <Ellipsis text={active ? 'active' : 'inActive'} />;

src/Routes/Tables/Jobs/GraphTab/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import React, {
77
useRef,
88
} from 'react';
99
import PropTypes from 'prop-types';
10-
import { Empty, Slider, Button, Switch, Popconfirm } from 'antd';
10+
import styled from 'styled-components';
11+
import { Empty, Slider, Button, Switch, Popconfirm, Spin } from 'antd';
1112
import { useDebounceCallback } from '@react-hook/debounce';
12-
import { Fallback, FallbackComponent } from 'components/common';
13+
import { Fallback } from 'components/common';
1314
import { useNodeInfo, useLocalStorageGraphMode } from 'hooks';
1415
import {
1516
AimOutlined,
@@ -31,11 +32,24 @@ import { generateStyles, formatEdge, formatNode } from '../graphUtils';
3132
import Details from './Details';
3233
import DropDownNodes from './NodeInputOutput/DropdownNodes';
3334

35+
const CenterImage = styled.div`
36+
display: flex;
37+
justify-content: center;
38+
align-items: center;
39+
min-height: 100px;
40+
height: 50%;
41+
`;
3442
const GRAPH_DIRECTION = {
3543
LeftToRight: 'LR',
3644
UpToDown: 'UD',
3745
};
3846

47+
const FallbackComponent = () => (
48+
<CenterImage>
49+
<Spin size="large" />
50+
</CenterImage>
51+
);
52+
3953
const calculatePercentage = (value, minValue, maxValue) => {
4054
if (value < minValue) {
4155
return 0; // Handle values less than the minimum

src/Routes/Tables/Jobs/GridView/Graph.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
import React, { lazy, useEffect, useMemo, useReducer } from 'react';
22
import PropTypes from 'prop-types';
33
import styled from 'styled-components';
4-
import { Empty } from 'antd';
5-
import { Fallback, FallbackComponent } from 'components/common';
4+
import { Empty, Spin } from 'antd';
5+
import { Fallback } from 'components/common';
66
import { useNodeInfo, useSettings } from 'hooks';
77
import { generateStyles, formatEdge, formatNode } from '../graphUtils';
88

9+
const CenterImage = styled.div`
10+
display: flex;
11+
justify-content: center;
12+
align-items: center;
13+
min-height: 100px;
14+
height: 50%;
15+
`;
16+
17+
const FallbackComponent = () => (
18+
<CenterImage>
19+
<Spin size="large" />
20+
</CenterImage>
21+
);
22+
923
const Graph = lazy(() => import(`react-graph-vis`));
1024

1125
const GraphContainer = styled.div`

src/Routes/Tables/Jobs/GridView/GraphPreview.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ZoomInOutlined,
2121
ZoomOutOutlined,
2222
} from '@ant-design/icons';
23+
/* eslint-disable import/no-cycle */
2324
import { useLocalStorageGraphMode } from 'hooks';
2425
import { generateStyles, formatEdge, formatNode } from '../graphUtils';
2526

@@ -91,8 +92,8 @@ const GraphPreview = ({
9192
keyIndex && pipeline?.streaming?.flows
9293
? Object.keys(pipeline?.streaming?.flows)[keyIndex]
9394
: valuesState?.streaming?.defaultFlow
94-
? valuesState?.streaming?.defaultFlow
95-
: null;
95+
? valuesState?.streaming?.defaultFlow
96+
: null;
9697

9798
const { backendApiUrl } = useSelector(selectors.config);
9899
const [graphPreview, setGraphPreview] = useState({ nodes: [], edges: [] });

0 commit comments

Comments
 (0)