aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/panels
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-10-15 07:54:25 +0000
committerEmiliano Ciavatta2020-10-15 07:54:25 +0000
commit97b0ee38fcf1e78e66dfe2a2816c95c3c3b10705 (patch)
treeed36b83d39163d872e55d297caada23092b7fcd4 /frontend/src/components/panels
parent08456e7f2e1c1af6fc8fdbf580c0178a25b93f8b (diff)
Update filters
Diffstat (limited to 'frontend/src/components/panels')
-rw-r--r--frontend/src/components/panels/ConnectionsPane.js22
1 files changed, 5 insertions, 17 deletions
diff --git a/frontend/src/components/panels/ConnectionsPane.js b/frontend/src/components/panels/ConnectionsPane.js
index 33dd7c1..89859e6 100644
--- a/frontend/src/components/panels/ConnectionsPane.js
+++ b/frontend/src/components/panels/ConnectionsPane.js
@@ -26,6 +26,7 @@ import log from "../../log";
import ButtonField from "../fields/ButtonField";
import dispatcher from "../../dispatcher";
import {Redirect} from "react-router";
+import {updateParams} from "../../utils";
const classNames = require('classnames');
@@ -67,29 +68,16 @@ class ConnectionsPane extends Component {
this.loadConnections(additionalParams, urlParams, true).then(() => log.debug("Connections loaded"));
this.connectionsFiltersCallback = payload => {
- const params = this.state.urlParams;
- const initialParams = params.toString();
-
- Object.entries(payload).forEach(([key, value]) => {
- if (value == null) {
- params.delete(key);
- } else if (Array.isArray(value)) {
- params.delete(key);
- value.forEach(v => params.append(key, v));
- } else {
- params.set(key, value);
- }
- });
-
- if (initialParams === params.toString()) {
+ const newParams = updateParams(this.state.urlParams, payload);
+ if (this.state.urlParams.toString() === newParams.toString()) {
return;
}
log.debug("Update following url params:", payload);
this.queryStringRedirect = true;
- this.setState({urlParams});
+ this.setState({urlParams: newParams});
- this.loadConnections({limit: this.queryLimit}, urlParams)
+ this.loadConnections({limit: this.queryLimit}, newParams)
.then(() => log.info("ConnectionsPane reloaded after query string update"));
};
dispatcher.register("connections_filters", this.connectionsFiltersCallback);