Skip to content

Commit

Permalink
fix build eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
zivglikr committed Jun 9, 2024
1 parent 4f34a39 commit 71a5082
Show file tree
Hide file tree
Showing 33 changed files with 1,607 additions and 1,789 deletions.
2,870 changes: 1,305 additions & 1,565 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions src/Routes/SidebarRight/AddPipeline/Steps/Nodes/Algorithms.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext, useContext } from 'react';
import React, { createContext, useContext, useMemo } from 'react';
import PropTypes from 'prop-types';
import { InputNumber, Switch, Radio, AutoComplete } from 'antd';
import { Form as CommonForm } from 'components/common';
Expand All @@ -21,9 +21,12 @@ const Field = props => {
const AlgorithmNode = ({ id }) => {
const { isStreamingPipeline, valuesState } = useWizardContext();
const { algorithms: sortedAlgorithms } = useGetLists();
const rootId = ['nodes', id];
const rootId = useMemo(() => ['nodes', id], [id]);

const contextValue = useMemo(() => ({ rootId }), [rootId]);

return (
<ctx.Provider value={{ rootId }}>
<ctx.Provider value={contextValue}>
<Field name={['algorithmName']} title="Algorithm">
<AutoComplete
disabled={sortedAlgorithms?.length === 0}
Expand Down Expand Up @@ -110,7 +113,7 @@ const AlgorithmNode = ({ id }) => {

{!isStreamingPipeline && (
<Field
overrides={{ ...{ valuePropName: 'checked' } }}
overrides={{ valuePropName: 'checked' }}
title="Include In Pipeline Results"
name={['includeInResult']}
skipValidation>
Expand All @@ -120,7 +123,7 @@ const AlgorithmNode = ({ id }) => {

{!isStreamingPipeline && (
<Field
overrides={{ ...{ valuePropName: 'checked' } }}
overrides={{ valuePropName: 'checked' }}
title="Create A Tensorboard"
name={['metrics', 'tensorboard']}
skipValidation>
Expand All @@ -135,4 +138,5 @@ const AlgorithmNode = ({ id }) => {
AlgorithmNode.propTypes = {
id: PropTypes.node.isRequired,
};

export default AlgorithmNode;
38 changes: 23 additions & 15 deletions src/Routes/SidebarRight/AddPipeline/Steps/Nodes/DataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,40 @@ const DataSourceNode = ({ id }) => {
initialState?.nodes[id]?.spec?.snapshot
? MODES.SNAPSHOT
: initialState?.nodes[id]?.spec?.id
? MODES.VERSION
: MODES.LATEST
? MODES.VERSION
: MODES.LATEST
);

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

// eslint-disable-next-line react-hooks/exhaustive-deps
const handleChangeMode = useCallback(e => {
setTimeout(() => {
setForm();
}, 500);
const handleChangeMode = useCallback(
e => {
setTimeout(() => {
setForm();
}, 500);

return setMode(e.target.value);
});
const disableSnapshot = useMemo(() => snapshots?.length === 0, [
snapshots?.length,
]);
return setMode(e.target.value);
},
[setForm]
);

const disableSnapshot = useMemo(
() => snapshots?.length === 0,
[snapshots?.length]
);

const disableVersions = useMemo(
() => versionsCollection?.length === 0,
[versionsCollection?.length]
);

const disableVersions = useMemo(() => versionsCollection?.length === 0, [
versionsCollection?.length,
]);
const contextValue = useMemo(() => ({ rootId: ['nodes', id, 'spec'] }), [id]);

return (
<ctx.Provider value={{ rootId: ['nodes', id, 'spec'] }}>
<ctx.Provider value={contextValue}>
<Field name={['name']} title="DataSource Name">
<Select disabled={collection && collection.length === 0}>
{collection.map(({ name }) => (
Expand Down
9 changes: 7 additions & 2 deletions src/Routes/SidebarRight/AddPipeline/Steps/Nodes/Gateway.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect } from 'react';
import React, { useContext, useEffect, useMemo } from 'react';
import PropTypes from 'prop-types';
import { Select, Input, InputNumber } from 'antd';

Expand Down Expand Up @@ -28,9 +28,14 @@ const GatewayNode = ({ id }) => {
form.setFieldsValue(nodes);
}, [form, id]);

const providerValue = useMemo(
() => ({ rootId: ['nodes', id, 'spec'] }),
[id]
);

return (
<>
<ctx.Provider value={{ rootId: ['nodes', id, 'spec'] }}>
<ctx.Provider value={providerValue}>
<Field name={['name']} title="Name">
<Input placeholder="Name Gateway" />
</Field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react';
import React, { useContext, useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import {
Form,
Expand Down Expand Up @@ -88,8 +88,10 @@ const HyperParamsNode = ({ id }) => {
}
};

const contextValue = useMemo(() => ({ rootId }), [rootId]);

return (
<ctx.Provider value={{ rootId }}>
<ctx.Provider value={contextValue}>
<Field name={['objectivePipeline']} title="Objective Pipeline">
<AutoComplete
disabled={pipelinesCollection?.length === 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const useInputField = (antFields, onRemove, inputRef, selectWidth) => {

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

setValue(srcValue);

Expand Down
9 changes: 7 additions & 2 deletions src/Routes/SidebarRight/AddPipeline/Steps/Nodes/Output.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from 'react';
import React, { useContext, useMemo } from 'react';
import PropTypes from 'prop-types';
import { Select, Input, Divider } from 'antd';
import Controller from './InputParseJson';
Expand All @@ -18,8 +18,11 @@ const Field = props => {
const OutputNode = ({ id }) => {
const { initialState } = useWizardContext();
const rootId = ['nodes', id, 'spec'];

const contextValue = useMemo(() => ({ rootId }), [rootId]);

return (
<ctx.Provider value={{ rootId }}>
<ctx.Provider value={contextValue}>
<Field name={['description']} title="Description" skipValidation>
<Input placeholder="Description" />
</Field>
Expand All @@ -44,7 +47,9 @@ const OutputNode = ({ id }) => {
</ctx.Provider>
);
};

OutputNode.propTypes = {
id: PropTypes.node.isRequired,
};

export default OutputNode;
6 changes: 4 additions & 2 deletions src/Routes/SidebarRight/Drawer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react';
import React, { useCallback, useMemo } from 'react';
import Drawer from 'components/Drawer';
import { TabDrawerText, TabDrawer } from 'styles';
import { RIGHT_SIDEBAR_NAMES } from 'const';
Expand Down Expand Up @@ -67,13 +67,15 @@ const DashboardDrawer = () => {
const width = CONTENT_CONFIG[panelType]?.width ?? 0;
const titleDrawer = titleSelector[panelType];

const contextValue = useMemo(() => ({ closeDrawer: setOff }), [setOff]);

if (root === undefined) {
navigate('/jobs');
}

// eslint-disable-next-line consistent-return
return (
<ctx.Provider value={{ closeDrawer: setOff }}>
<ctx.Provider value={contextValue}>
<Drawer
width={width}
isOpened={isOn}
Expand Down
4 changes: 2 additions & 2 deletions src/Routes/SidebarRight/ErrorLogs/ErrorLogQueryTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FiltersForms } from 'styles';
import qs from 'qs';

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

const ErrorLogQueryTable = ({ onSubmit, ErrorLogList }) => {
Expand Down Expand Up @@ -92,7 +92,7 @@ const ErrorLogQueryTable = ({ onSubmit, ErrorLogList }) => {
format={DateFormat}
onOpenChange={() => {
// eslint-disable-next-line no-unused-vars
localValueTimeChanged = Date.now();
// localValueTimeChanged = Date.now();
}}
onChange={SubmitForm}
/>
Expand Down
28 changes: 17 additions & 11 deletions src/Routes/SidebarRight/NodeStatistics.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@ const Container = styled.div`
}
`;

// https://nivo.rocks/bar/ customization
// Define the custom formatter component outside of NodeStatistics
const CustomAxisLeftTick = ({ value }) =>
value.length > 15 ? (
<tspan>
{`${value.substring(0, 15)}...`}
<title>{value}</title>
</tspan>
) : (
value
);

CustomAxisLeftTick.propTypes = {
value: PropTypes.string.isRequired,
};

// NodeStatistics component
const NodeStatistics = ({ metric }) => {
const { data, legend } = useMetric(metric);

Expand Down Expand Up @@ -44,7 +59,6 @@ const NodeStatistics = ({ metric }) => {
legend: {
text: {
fontSize: 19,

fill: whiteColor,
},
},
Expand Down Expand Up @@ -104,15 +118,7 @@ const NodeStatistics = ({ metric }) => {
legendOffset: 50,
}}
axisLeft={{
format: v =>
v.length > 15 ? (
<tspan>
{`${v.substring(0, 15)}...`}
<title>{v}</title>
</tspan>
) : (
v
),
format: CustomAxisLeftTick, // Use the custom formatter component
tickSize: 5,
tickPadding: 5,
tickRotation: 20,
Expand Down
6 changes: 4 additions & 2 deletions src/Routes/Tables/Algorithms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ const AlgorithmsTable = () => {
}

return (
(queryVal.data?.algorithms?.list &&
[...queryVal.data?.algorithms?.list].sort((x, y) =>
(queryVal.data &&
queryVal.data.algorithms &&
queryVal.data.algorithms.list &&
[...queryVal.data.algorithms.list].sort((x, y) =>
x.modified < y.modified ? 1 : -1
)) ||
[]
Expand Down
8 changes: 7 additions & 1 deletion src/Routes/Tables/Drivers/DriversTableColumns.react.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import React from 'react';
import PropTypes from 'prop-types';
import Ellipsis from 'components/common/Ellipsis.react';
import { StatusTag as CountTag } from 'components/StatusTag';
import { sorter } from 'utils/stringHelper';

const Jobs = ({ jobs }) => <CountTag count={jobs?.length | 0} />;
Jobs.propTypes = {
jobs: PropTypes.array.isRequired,
};
export default Jobs;

const DriverId = driverId => <Ellipsis text={driverId} />;
const PodName = podName => <Ellipsis copyable text={podName} />;
const Status = status => <Ellipsis text={status} />;
const Jobs = jobs => <CountTag count={jobs.length} />;
const Max = count => <CountTag count={count} />;
const Capacity = count => <CountTag count={count} />;
const Active = active => <Ellipsis text={active ? 'active' : 'inActive'} />;
Expand Down
18 changes: 16 additions & 2 deletions src/Routes/Tables/Jobs/GraphTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import React, {
useRef,
} from 'react';
import PropTypes from 'prop-types';
import { Empty, Slider, Button, Switch, Popconfirm } from 'antd';
import styled from 'styled-components';
import { Empty, Slider, Button, Switch, Popconfirm, Spin } from 'antd';
import { useDebounceCallback } from '@react-hook/debounce';
import { Fallback, FallbackComponent } from 'components/common';
import { Fallback } from 'components/common';
import { useNodeInfo, useLocalStorageGraphMode } from 'hooks';
import {
AimOutlined,
Expand All @@ -31,11 +32,24 @@ import { generateStyles, formatEdge, formatNode } from '../graphUtils';
import Details from './Details';
import DropDownNodes from './NodeInputOutput/DropdownNodes';

const CenterImage = styled.div`
display: flex;
justify-content: center;
align-items: center;
min-height: 100px;
height: 50%;
`;
const GRAPH_DIRECTION = {
LeftToRight: 'LR',
UpToDown: 'UD',
};

const FallbackComponent = () => (
<CenterImage>
<Spin size="large" />
</CenterImage>
);

const calculatePercentage = (value, minValue, maxValue) => {
if (value < minValue) {
return 0; // Handle values less than the minimum
Expand Down
18 changes: 16 additions & 2 deletions src/Routes/Tables/Jobs/GridView/Graph.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import React, { lazy, useEffect, useMemo, useReducer } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { Empty } from 'antd';
import { Fallback, FallbackComponent } from 'components/common';
import { Empty, Spin } from 'antd';
import { Fallback } from 'components/common';
import { useNodeInfo, useSettings } from 'hooks';
import { generateStyles, formatEdge, formatNode } from '../graphUtils';

const CenterImage = styled.div`
display: flex;
justify-content: center;
align-items: center;
min-height: 100px;
height: 50%;
`;

const FallbackComponent = () => (
<CenterImage>
<Spin size="large" />
</CenterImage>
);

const Graph = lazy(() => import(`react-graph-vis`));

const GraphContainer = styled.div`
Expand Down
5 changes: 3 additions & 2 deletions src/Routes/Tables/Jobs/GridView/GraphPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ZoomInOutlined,
ZoomOutOutlined,
} from '@ant-design/icons';
/* eslint-disable import/no-cycle */
import { useLocalStorageGraphMode } from 'hooks';
import { generateStyles, formatEdge, formatNode } from '../graphUtils';

Expand Down Expand Up @@ -91,8 +92,8 @@ const GraphPreview = ({
keyIndex && pipeline?.streaming?.flows
? Object.keys(pipeline?.streaming?.flows)[keyIndex]
: valuesState?.streaming?.defaultFlow
? valuesState?.streaming?.defaultFlow
: null;
? valuesState?.streaming?.defaultFlow
: null;

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

0 comments on commit 71a5082

Please sign in to comment.