From 2fb8993008752063fa13f253784e9e92552e339d Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Fri, 16 Oct 2020 11:13:21 +0200 Subject: Refactor js files --- frontend/src/components/filters/AdvancedFilters.js | 4 ++-- .../components/filters/BooleanConnectionsFilter.js | 6 +++--- frontend/src/components/filters/ExitSearchFilter.js | 4 ++-- .../src/components/filters/RulesConnectionsFilter.js | 6 +++--- .../components/filters/StringConnectionsFilter.js | 20 +++++--------------- 5 files changed, 15 insertions(+), 25 deletions(-) (limited to 'frontend/src/components/filters') diff --git a/frontend/src/components/filters/AdvancedFilters.js b/frontend/src/components/filters/AdvancedFilters.js index f5ba825..2b479ed 100644 --- a/frontend/src/components/filters/AdvancedFilters.js +++ b/frontend/src/components/filters/AdvancedFilters.js @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; +import React, {Component} from "react"; import {withRouter} from "react-router-dom"; import dispatcher from "../../dispatcher"; -import ButtonField from "../fields/ButtonField"; import {updateParams} from "../../utils"; +import ButtonField from "../fields/ButtonField"; class AdvancedFilters extends Component { diff --git a/frontend/src/components/filters/BooleanConnectionsFilter.js b/frontend/src/components/filters/BooleanConnectionsFilter.js index 9558323..0355167 100644 --- a/frontend/src/components/filters/BooleanConnectionsFilter.js +++ b/frontend/src/components/filters/BooleanConnectionsFilter.js @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; +import React, {Component} from "react"; import {withRouter} from "react-router-dom"; -import CheckField from "../fields/CheckField"; import dispatcher from "../../dispatcher"; +import CheckField from "../fields/CheckField"; class BooleanConnectionsFilter extends Component { @@ -30,7 +30,7 @@ class BooleanConnectionsFilter extends Component { let params = new URLSearchParams(this.props.location.search); this.setState({filterActive: this.toBoolean(params.get(this.props.filterName)).toString()}); - this.connectionsFiltersCallback = payload => { + this.connectionsFiltersCallback = (payload) => { const name = this.props.filterName; if (name in payload && this.state.filterActive !== payload[name]) { this.setState({filterActive: payload[name]}); diff --git a/frontend/src/components/filters/ExitSearchFilter.js b/frontend/src/components/filters/ExitSearchFilter.js index 68ca686..72cfb0c 100644 --- a/frontend/src/components/filters/ExitSearchFilter.js +++ b/frontend/src/components/filters/ExitSearchFilter.js @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; +import React, {Component} from "react"; import {withRouter} from "react-router-dom"; -import CheckField from "../fields/CheckField"; import dispatcher from "../../dispatcher"; +import CheckField from "../fields/CheckField"; class ExitSearchFilter extends Component { diff --git a/frontend/src/components/filters/RulesConnectionsFilter.js b/frontend/src/components/filters/RulesConnectionsFilter.js index 8e40d30..86eae7e 100644 --- a/frontend/src/components/filters/RulesConnectionsFilter.js +++ b/frontend/src/components/filters/RulesConnectionsFilter.js @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; +import React, {Component} from "react"; import {withRouter} from "react-router-dom"; import backend from "../../backend"; import dispatcher from "../../dispatcher"; import TagField from "../fields/TagField"; -const classNames = require('classnames'); -const _ = require('lodash'); +const classNames = require("classnames"); +const _ = require("lodash"); class RulesConnectionsFilter extends Component { diff --git a/frontend/src/components/filters/StringConnectionsFilter.js b/frontend/src/components/filters/StringConnectionsFilter.js index 18b3784..c3c5925 100644 --- a/frontend/src/components/filters/StringConnectionsFilter.js +++ b/frontend/src/components/filters/StringConnectionsFilter.js @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -import React, {Component} from 'react'; +import React, {Component} from "react"; import {withRouter} from "react-router-dom"; -import InputField from "../fields/InputField"; import dispatcher from "../../dispatcher"; +import InputField from "../fields/InputField"; class StringConnectionsFilter extends Component { @@ -56,15 +56,9 @@ class StringConnectionsFilter extends Component { fieldValue = this.props.replaceFunc(fieldValue); } if (this.isValueValid(fieldValue)) { - this.setState({ - fieldValue: fieldValue, - filterValue: filterValue - }); + this.setState({fieldValue, filterValue: filterValue}); } else { - this.setState({ - fieldValue: fieldValue, - invalidValue: true - }); + this.setState({fieldValue, invalidValue: true}); } } else { this.setState({fieldValue: "", filterValue: null}); @@ -97,7 +91,6 @@ class StringConnectionsFilter extends Component { } - if (this.isValueValid(fieldValue)) { let filterValue = fieldValue; if (filterValue !== "" && typeof this.props.encodeFunc === "function") { @@ -113,10 +106,7 @@ class StringConnectionsFilter extends Component { invalidValue: false }); } else { - this.setState({ - fieldValue: fieldValue, - invalidValue: true - }); + this.setState({fieldValue, invalidValue: true}); } }; -- cgit v1.2.3-70-g09d2