Skip to content

Commit

Permalink
Fixed filters displaying when tab changed
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rv4x committed Mar 11, 2019
1 parent 2f676cc commit de03196
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion app/src/common/search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import { Box, MaskedInput, Keyboard } from 'grommet'
import { Close } from 'grommet-icons'



class Search extends React.Component {
constructor(props) {
super(props);

this.state = {
currentEnteredValue: "",
currentValue: [],
currentValue: this.propsFiltersToCurrentValue(),
lastHighlighted: false
}

this.propsFiltersToCurrentValue = this.propsFiltersToCurrentValue.bind(this);
this.handleOnChange = this.handleOnChange.bind(this);
this.addOption = this.addOption.bind(this);
this.popOption = this.popOption.bind(this);
Expand All @@ -26,6 +28,20 @@ class Search extends React.Component {
return (!_.isEqual(nextProps, this.props) || !_.isEqual(nextState, this.state));
}

propsFiltersToCurrentValue() {
const { filters } = this.props;

let gatheredValue = [];

for (let key of Object.keys(filters)) {
for (let value of filters[key]) {
gatheredValue.push(key + ": " + value);
}
}

return gatheredValue;
}

handleOnChange(value) {
this.setState({ currentValue: value });
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/hosts_list/components/HostsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class HostsTable extends React.Component {

return (
<div>
<Search applyFilters={applyFilters} />
<Search filters={hosts.filters} applyFilters={applyFilters} />
<br />
{hosts.data.length === 0 && hosts.loaded &&
<Heading level="2">No data found.</Heading>
Expand Down
2 changes: 1 addition & 1 deletion app/src/ips_list/components/IPTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class IPTable extends React.Component {

return (
<div>
<Search applyFilters={applyFilters} />
<Search filters={ips.filters} applyFilters={applyFilters} />
<br />
{ipsList.length === 0 && ips.loaded &&
<Heading level="2">No data found.</Heading>
Expand Down

0 comments on commit de03196

Please sign in to comment.