Skip to content

Commit

Permalink
fix(ui): unneeded chain call (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucapette authored and tchiotludo committed Apr 4, 2023
1 parent 779ffaa commit 531d21f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
39 changes: 20 additions & 19 deletions client/src/containers/Connect/ConnectCreate/ConnectCreate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Header from '../../Header/Header';
import constants from '../../../utils/constants';
import Select from '../../../components/Form/Select';
import AceEditor from 'react-ace';
import chain from 'lodash/chain';
import filter from 'lodash/filter';
import 'ace-builds/webpack-resolver';
import 'ace-builds/src-noconflict/mode-json';
import 'ace-builds/src-noconflict/theme-merbivore_soft';
Expand Down Expand Up @@ -218,23 +218,23 @@ class ConnectCreate extends Root {
let actualGroup = '';
let sameGroup = [];
let allOfIt = [];
chain(plugin.definitions)
.filter(plugin => plugin.name !== 'name' && plugin.name !== 'connector.class')
.value()
.forEach(definition => {
if (definition.group !== actualGroup) {
if (actualGroup === '') {
actualGroup = definition.group;
sameGroup = [definition];
} else {
allOfIt.push(this.handleGroup(sameGroup));
sameGroup = [definition];
actualGroup = definition.group;
}
filter(
plugin.definitions,
plugin => plugin.name !== 'name' && plugin.name !== 'connector.class'
).forEach(definition => {
if (definition.group !== actualGroup) {
if (actualGroup === '') {
actualGroup = definition.group;
sameGroup = [definition];
} else {
sameGroup.push(definition);
allOfIt.push(this.handleGroup(sameGroup));
sameGroup = [definition];
actualGroup = definition.group;
}
});
} else {
sameGroup.push(definition);
}
});
allOfIt.push(this.handleGroup(sameGroup));
this.setState({ display: allOfIt });
return allOfIt;
Expand Down Expand Up @@ -321,9 +321,10 @@ class ConnectCreate extends Root {
if (plugin.definitions) {
this.setState({ plugin }, () => {
this.handleSchema(
chain(plugin.definitions)
.filter(plugin => plugin.name !== 'name' && plugin.name !== 'connector.class')
.value()
filter(
plugin.definitions,
plugin => plugin.name !== 'name' && plugin.name !== 'connector.class'
)
);
this.handleData();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import constants from '../../../../utils/constants';
import Form from '../../../../components/Form/Form';
import AceEditor from 'react-ace';
import chain from 'lodash/chain';
import filter from 'lodash/filter';
import 'ace-builds/webpack-resolver';
import 'ace-builds/src-noconflict/mode-json';
import 'ace-builds/src-noconflict/theme-merbivore_soft';
Expand Down Expand Up @@ -234,23 +234,23 @@ class ConnectConfigs extends Form {
let actualGroup = '';
let sameGroup = [];
let allOfIt = [];
chain(plugin.definitions)
.filter(plugin => plugin.name !== 'name' && plugin.name !== 'connector.class')
.value()
.forEach(definition => {
if (definition.group !== actualGroup) {
if (actualGroup === '') {
actualGroup = definition.group;
sameGroup = [definition];
} else {
allOfIt.push(this.handleGroup(sameGroup));
sameGroup = [definition];
actualGroup = definition.group;
}
filter(
plugin.definitions,
plugin => plugin.name !== 'name' && plugin.name !== 'connector.class'
).forEach(definition => {
if (definition.group !== actualGroup) {
if (actualGroup === '') {
actualGroup = definition.group;
sameGroup = [definition];
} else {
sameGroup.push(definition);
allOfIt.push(this.handleGroup(sameGroup));
sameGroup = [definition];
actualGroup = definition.group;
}
});
} else {
sameGroup.push(definition);
}
});
allOfIt.push(this.handleGroup(sameGroup));
this.setState({ display: allOfIt });
};
Expand Down
7 changes: 2 additions & 5 deletions client/src/containers/SideBar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Link, withRouter } from 'react-router-dom';
import { matchPath } from 'react-router';
import constants from '../../utils/constants';
import chain from 'lodash/chain';
import sortBy from 'lodash/sortBy';
import './styles.scss';
import SideNav, { NavIcon, NavItem, NavText } from '@trendmicro/react-sidenav';
import '@trendmicro/react-sidenav/dist/react-sidenav.css';
Expand Down Expand Up @@ -58,10 +58,7 @@ class Sidebar extends Component {
});

const clusterId = match ? match.params.clusterId || '' : '';
let allClusters =
chain(clusters)
.sortBy(cluster => cluster.id)
.value() || [];
const allClusters = sortBy(clusters || [], cluster => cluster.id);
const cluster = allClusters.find(cluster => cluster.id === clusterId);
this.setState(
{
Expand Down

0 comments on commit 531d21f

Please sign in to comment.