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
193f6f7f
Commit
193f6f7f
authored
Dec 17, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Dec 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle focus-user filter conflict when setting filters
parent
f7a74a2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
4 deletions
+61
-4
filters.js
src/sidebar/store/modules/filters.js
+20
-4
filters-test.js
src/sidebar/store/modules/test/filters-test.js
+41
-0
No files found.
src/sidebar/store/modules/filters.js
View file @
193f6f7f
...
@@ -170,10 +170,21 @@ function changeFocusModeUser(user) {
...
@@ -170,10 +170,21 @@ function changeFocusModeUser(user) {
* @param {FilterOption} filterOption
* @param {FilterOption} filterOption
*/
*/
function
setFilter
(
filterName
,
filterOption
)
{
function
setFilter
(
filterName
,
filterOption
)
{
return
{
return
(
dispatch
,
getState
)
=>
{
type
:
actions
.
SET_FILTER
,
// If there is a filter conflict with focusFilters, deactivate focus
filterName
,
// mode to prevent unintended collisions and let the new filter value
filterOption
,
// take precedence.
if
(
getState
().
filters
.
focusFilters
?.[
filterName
])
{
dispatch
({
type
:
actions
.
SET_FOCUS_MODE
,
active
:
false
,
});
}
dispatch
({
type
:
actions
.
SET_FILTER
,
filterName
,
filterOption
,
});
};
};
}
}
...
@@ -263,6 +274,10 @@ const getFilterValues = createSelector(
...
@@ -263,6 +274,10 @@ const getFilterValues = createSelector(
}
}
);
);
function
getFocusFilters
(
state
)
{
return
state
.
focusFilters
;
}
/**
/**
* Are there currently any active (applied) filters?
* Are there currently any active (applied) filters?
*/
*/
...
@@ -286,6 +301,7 @@ export default storeModule({
...
@@ -286,6 +301,7 @@ export default storeModule({
getFilter
,
getFilter
,
getFilters
,
getFilters
,
getFilterValues
,
getFilterValues
,
getFocusFilters
,
hasAppliedFilter
,
hasAppliedFilter
,
},
},
});
});
src/sidebar/store/modules/test/filters-test.js
View file @
193f6f7f
...
@@ -74,6 +74,26 @@ describe('sidebar/store/modules/filters', () => {
...
@@ -74,6 +74,26 @@ describe('sidebar/store/modules/filters', () => {
assert
.
isUndefined
(
filters
.
whatever
);
assert
.
isUndefined
(
filters
.
whatever
);
});
});
it
(
'disables focus mode if there is a conflicting filter key'
,
()
=>
{
store
=
createStore
(
[
filters
],
[{
focus
:
{
user
:
{
username
:
'somebody'
}
}
}]
);
assert
.
isTrue
(
store
.
focusState
().
active
);
// No conflict in focusFilters on `elephant`
store
.
setFilter
(
'elephant'
,
{
value
:
'pink'
,
display
:
'Pink Elephant'
,
});
assert
.
isTrue
(
store
.
focusState
().
active
);
store
.
setFilter
(
'user'
,
{
value
:
''
,
display
:
'Everybody'
});
assert
.
isFalse
(
store
.
focusState
().
active
);
});
it
(
'replaces pre-existing filter with the same key'
,
()
=>
{
it
(
'replaces pre-existing filter with the same key'
,
()
=>
{
store
.
setFilter
(
'whatever'
,
{
store
.
setFilter
(
'whatever'
,
{
value
:
'anyOldThing'
,
value
:
'anyOldThing'
,
...
@@ -251,6 +271,27 @@ describe('sidebar/store/modules/filters', () => {
...
@@ -251,6 +271,27 @@ describe('sidebar/store/modules/filters', () => {
});
});
});
});
describe
(
'getFocusFilters'
,
()
=>
{
it
(
'returns any set focus filters'
,
()
=>
{
store
=
createStore
(
[
filters
],
[
{
focus
:
{
user
:
{
username
:
'somebody'
,
displayName
:
'Ding Bat'
},
},
},
]
);
const
focusFilters
=
store
.
getFocusFilters
();
assert
.
exists
(
focusFilters
.
user
);
assert
.
deepEqual
(
focusFilters
.
user
,
{
value
:
'somebody'
,
display
:
'Ding Bat'
,
});
});
});
describe
(
'hasAppliedFilter'
,
()
=>
{
describe
(
'hasAppliedFilter'
,
()
=>
{
it
(
'returns true if there is a search query set'
,
()
=>
{
it
(
'returns true if there is a search query set'
,
()
=>
{
store
.
setFilterQuery
(
'foobar'
);
store
.
setFilterQuery
(
'foobar'
);
...
...
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