From 2747652dcadc476dfef6352622c817097f5c23a1 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Thu, 9 Aug 2018 11:10:15 +0200 Subject: [PATCH 1/7] Add RESET_FILTER to filter model --- gsa/src/gmp/models/filter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gsa/src/gmp/models/filter.js b/gsa/src/gmp/models/filter.js index db52821dd6..5342ad94f1 100644 --- a/gsa/src/gmp/models/filter.js +++ b/gsa/src/gmp/models/filter.js @@ -732,6 +732,8 @@ export const TAGS_FILTER_FILTER = Filter.fromString('type=tag'); export const USERS_FILTER_FILTER = Filter.fromString('type=user'); export const VULNS_FILTER_FILTER = Filter.fromString('type=vuln'); +export const RESET_FILTER = Filter.fromString('first=1'); + export default Filter; // vim: set ts=2 sw=2 tw=80: From b23c134f7396a819f1b49eb976dd653548007225 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Thu, 9 Aug 2018 11:11:20 +0200 Subject: [PATCH 2/7] Add handleFilterRemoved() method to EntitiesContainer --- gsa/src/web/entities/container.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gsa/src/web/entities/container.js b/gsa/src/web/entities/container.js index 7a37350712..65e70dfa70 100644 --- a/gsa/src/web/entities/container.js +++ b/gsa/src/web/entities/container.js @@ -36,7 +36,7 @@ import { pluralizeType, } from 'gmp/utils/entitytype'; -import Filter from 'gmp/models/filter'; +import Filter, {RESET_FILTER} from 'gmp/models/filter'; import {YES_VALUE} from 'gmp/parser'; @@ -97,6 +97,7 @@ class EntitiesContainer extends React.Component { this.handleTimer = this.handleTimer.bind(this); this.handleFilterCreated = this.handleFilterCreated.bind(this); this.handleFilterChanged = this.handleFilterChanged.bind(this); + this.handleFilterRemoved = this.handleFilterRemoved.bind(this); this.handleFilterReset = this.handleFilterReset.bind(this); this.handleAddMultiTag = this.handleAddMultiTag.bind(this); this.handleTagChange = this.handleTagChange.bind(this); @@ -339,6 +340,10 @@ class EntitiesContainer extends React.Component { this.load(filter); } + handleFilterRemoved() { + this.load(RESET_FILTER); + } + handleFilterReset() { const {history, location} = this.props; const query = {...location.query}; @@ -545,6 +550,7 @@ class EntitiesContainer extends React.Component { onDownloaded: onDownload, onError: this.handleError, onFilterChanged: this.handleFilterChanged, + onFilterRemoved: this.handleFilterRemoved, onFilterReset: this.handleFilterReset, onSortChange: this.handleSortChange, onSelectionTypeChange: this.handleSelectionTypeChange, From 04bf83445372294b3f0789ef5b85f91ec256ac32 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Thu, 9 Aug 2018 11:12:07 +0200 Subject: [PATCH 3/7] Pass handleFilterRemoved() to Powerfilter --- gsa/src/web/entities/page.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gsa/src/web/entities/page.js b/gsa/src/web/entities/page.js index 5d1f1b9b48..573a747330 100644 --- a/gsa/src/web/entities/page.js +++ b/gsa/src/web/entities/page.js @@ -200,6 +200,7 @@ class EntitiesPage extends React.Component { onError, onFilterChanged, onFilterCreated, + onFilterRemoved, onFilterReset, } = this.props; @@ -225,6 +226,7 @@ class EntitiesPage extends React.Component { onEditClick={handler} onError={onError} onFilterCreated={onFilterCreated} + onRemoveClick={onFilterRemoved} onResetClick={onFilterReset} onUpdate={onFilterChanged} /> @@ -309,6 +311,7 @@ EntitiesPage.propTypes = { onError: PropTypes.func.isRequired, onFilterChanged: PropTypes.func.isRequired, onFilterCreated: PropTypes.func.isRequired, + onFilterRemoved: PropTypes.func.isRequired, onFilterReset: PropTypes.func.isRequired, }; From ae2b7ae0e267d7e7500b7377d365d9492ad20668 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Thu, 9 Aug 2018 11:13:38 +0200 Subject: [PATCH 4/7] Add new "Reset Filter" button and functionality to Powerfilter The old reset button now removes any filter (instead of resetting to default). For resetting to default a new reset button is added. --- .../web/components/powerfilter/powerfilter.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gsa/src/web/components/powerfilter/powerfilter.js b/gsa/src/web/components/powerfilter/powerfilter.js index 5b3638d07b..d65ed7cf66 100644 --- a/gsa/src/web/components/powerfilter/powerfilter.js +++ b/gsa/src/web/components/powerfilter/powerfilter.js @@ -228,6 +228,7 @@ class PowerFilter extends React.Component { capabilities, filters, onEditClick, + onRemoveClick, onResetClick, } = this.props; const namedfilterid = isDefined(filter) && isDefined(filter.id) ? @@ -266,10 +267,18 @@ class PowerFilter extends React.Component { onClick={this.handleUpdateFilter} /> - {onResetClick && + {onRemoveClick && + } + {onResetClick && + @@ -333,6 +342,7 @@ PowerFilter.propTypes = { onEditClick: PropTypes.func, onError: PropTypes.func, onFilterCreated: PropTypes.func, + onRemoveClick: PropTypes.func, onResetClick: PropTypes.func, onUpdate: PropTypes.func, }; From 60e9571a94a9c325be9579085d80452c7f2074aa Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Thu, 9 Aug 2018 11:17:46 +0200 Subject: [PATCH 5/7] Reset Powerfilter if named filter is unselected --- gsa/src/web/components/powerfilter/powerfilter.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gsa/src/web/components/powerfilter/powerfilter.js b/gsa/src/web/components/powerfilter/powerfilter.js index d65ed7cf66..54771ee396 100644 --- a/gsa/src/web/components/powerfilter/powerfilter.js +++ b/gsa/src/web/components/powerfilter/powerfilter.js @@ -29,6 +29,8 @@ import _ from 'gmp/locale'; import logger from 'gmp/log'; +import Filter, {RESET_FILTER} from 'gmp/models/filter'; + import {KeyCode} from 'gmp/utils/event'; import {isDefined, isString} from 'gmp/utils/identity'; @@ -51,8 +53,6 @@ import Divider from 'web/components/layout/divider'; import IconDivider from 'web/components/layout/icondivider'; import Layout from 'web/components/layout/layout'; -import Filter from 'gmp/models/filter'; - const log = logger.getLogger('web.powerfilter'); const DEFAULT_FILTER_ID = '0'; @@ -140,8 +140,10 @@ class PowerFilter extends React.Component { handleNamedFilterChange(value) { const {filters} = this.props; - const filter = filters.find(f => f.id === value); - + let filter = filters.find(f => f.id === value); + if (!isDefined(filter)) { + filter = RESET_FILTER; + } this.updateFilter(filter); } From 3a92f85274e5ba4866590705503a711ac42bf5dd Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Thu, 9 Aug 2018 11:29:55 +0200 Subject: [PATCH 6/7] Fix first reload of entities --- gsa/src/web/entities/container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsa/src/web/entities/container.js b/gsa/src/web/entities/container.js index 65e70dfa70..762c063e81 100644 --- a/gsa/src/web/entities/container.js +++ b/gsa/src/web/entities/container.js @@ -160,7 +160,7 @@ class EntitiesContainer extends React.Component { reload() { // reload data from backend - this.load(this.state.loadedFilter); + this.load(this.props.filter); } getRefreshInterval() { From f16b501c2edb155d3c2c7b28383c3cf2c8853d53 Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Thu, 9 Aug 2018 11:30:23 +0200 Subject: [PATCH 7/7] Remove unnecessary prop from Powerfilter's DeleteIcon --- gsa/src/web/components/powerfilter/powerfilter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gsa/src/web/components/powerfilter/powerfilter.js b/gsa/src/web/components/powerfilter/powerfilter.js index 54771ee396..3f432f15ce 100644 --- a/gsa/src/web/components/powerfilter/powerfilter.js +++ b/gsa/src/web/components/powerfilter/powerfilter.js @@ -271,7 +271,6 @@ class PowerFilter extends React.Component { {onRemoveClick &&