Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
f1d34f28
Commit
f1d34f28
authored
Apr 30, 2020
by
Lyza Danger Gardner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `hasAppliedFilter` selector
Add selector to check if there are any applied filters on annotations
parent
18fd3307
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletion
+45
-1
selection.js
src/sidebar/store/modules/selection.js
+17
-1
selection-test.js
src/sidebar/store/modules/test/selection-test.js
+28
-0
No files found.
src/sidebar/store/modules/selection.js
View file @
f1d34f28
...
...
@@ -519,6 +519,21 @@ function getSelectedAnnotationMap(state) {
return
state
.
selection
.
selectedAnnotationMap
;
}
/**
* Is any sort of filtering currently applied to the list of annotations? This
* includes a search query, but also if annotations are selected or a user
* is focused.
*
* @return {boolean}
*/
const
hasAppliedFilter
=
createSelector
(
filterQuery
,
focusModeFocused
,
hasSelectedAnnotations
,
(
filterQuery
,
focusModeFocused
,
hasSelectedAnnotations
)
=>
!!
filterQuery
||
focusModeFocused
||
hasSelectedAnnotations
);
export
default
{
init
:
init
,
namespace
:
'selection'
,
...
...
@@ -541,7 +556,6 @@ export default {
},
selectors
:
{
hasSelectedAnnotations
,
expandedThreads
,
filterQuery
,
focusModeFocused
,
...
...
@@ -553,5 +567,7 @@ export default {
isAnnotationSelected
,
getFirstSelectedAnnotationId
,
getSelectedAnnotationMap
,
hasAppliedFilter
,
hasSelectedAnnotations
,
},
};
src/sidebar/store/modules/test/selection-test.js
View file @
f1d34f28
...
...
@@ -62,6 +62,34 @@ describe('sidebar/store/modules/selection', () => {
});
});
describe
(
'hasAppliedFilter'
,
()
=>
{
it
(
'returns true if there is a search query set'
,
()
=>
{
store
.
setFilterQuery
(
'foobar'
);
assert
.
isTrue
(
store
.
hasAppliedFilter
());
});
it
(
'returns true if in user-focused mode'
,
()
=>
{
store
=
createStore
([
selection
],
[{
focus
:
{
user
:
{}
}
}]);
store
.
setFocusModeFocused
(
true
);
assert
.
isTrue
(
store
.
hasAppliedFilter
());
});
it
(
'returns true if there are selected annotations'
,
()
=>
{
store
.
selectAnnotations
([
1
]);
assert
.
isTrue
(
store
.
hasAppliedFilter
());
});
it
(
'returns false after selection is cleared'
,
()
=>
{
store
.
setFilterQuery
(
'foobar'
);
store
.
clearSelection
();
assert
.
isFalse
(
store
.
hasAppliedFilter
());
});
});
describe
(
'hasSelectedAnnotations'
,
function
()
{
it
(
'returns true if there are any selected annotations'
,
function
()
{
store
.
selectAnnotations
([
1
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment