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
dcf59584
Commit
dcf59584
authored
Aug 06, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of duplicative actionCreator `clearSelectedAnnotations`
`clearSelection` does the same thing
parent
a46fe918
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
40 deletions
+16
-40
selection-tabs.js
src/sidebar/components/selection-tabs.js
+2
-2
sidebar-content.js
src/sidebar/components/sidebar-content.js
+3
-5
hypothesis-app-test.js
src/sidebar/components/test/hypothesis-app-test.js
+0
-1
selection-tabs-test.js
src/sidebar/components/test/selection-tabs-test.js
+3
-3
sidebar-content-test.js
src/sidebar/components/test/sidebar-content-test.js
+4
-4
selection.js
src/sidebar/store/modules/selection.js
+4
-11
selection-test.js
src/sidebar/store/modules/test/selection-test.js
+0
-14
No files found.
src/sidebar/components/selection-tabs.js
View file @
dcf59584
...
...
@@ -100,14 +100,14 @@ function SelectionTabs({ isLoading, settings }) {
);
// actions
const
store
=
useStore
(
store
=>
({
clearSelect
edAnnotations
:
store
.
clearSelectedAnnotations
,
clearSelect
ion
:
store
.
clearSelection
,
selectTab
:
store
.
selectTab
,
}));
const
isThemeClean
=
settings
.
theme
===
'clean'
;
const
selectTab
=
tabId
=>
{
store
.
clearSelect
edAnnotations
();
store
.
clearSelect
ion
();
store
.
selectTab
(
tabId
);
};
...
...
src/sidebar/components/sidebar-content.js
View file @
dcf59584
...
...
@@ -60,9 +60,7 @@ function SidebarContent({
:
null
;
// Actions
const
clearSelectedAnnotations
=
useStore
(
store
=>
store
.
clearSelectedAnnotations
);
const
clearSelection
=
useStore
(
store
=>
store
.
clearSelection
);
const
selectTab
=
useStore
(
store
=>
store
.
selectTab
);
// If, after loading completes, no `linkedAnnotation` object is present when
...
...
@@ -96,14 +94,14 @@ function SidebarContent({
useEffect
(()
=>
{
if
(
!
prevGroupId
.
current
||
prevGroupId
.
current
!==
focusedGroupId
)
{
// Clear any selected annotations when the group ID changes
clearSelect
edAnnotations
();
clearSelect
ion
();
prevGroupId
.
current
=
focusedGroupId
;
}
if
(
focusedGroupId
&&
searchUris
.
length
)
{
loadAnnotationsService
.
load
(
searchUris
,
focusedGroupId
);
}
},
[
clearSelect
edAnnotations
,
clearSelect
ion
,
loadAnnotationsService
,
focusedGroupId
,
userId
,
...
...
src/sidebar/components/test/hypothesis-app-test.js
View file @
dcf59584
...
...
@@ -37,7 +37,6 @@ describe('HypothesisApp', () => {
fakeShouldAutoDisplayTutorial
=
sinon
.
stub
().
returns
(
false
);
fakeStore
=
{
clearSelectedAnnotations
:
sinon
.
spy
(),
clearGroups
:
sinon
.
stub
(),
closeSidebarPanel
:
sinon
.
stub
(),
openSidebarPanel
:
sinon
.
stub
(),
...
...
src/sidebar/components/test/selection-tabs-test.js
View file @
dcf59584
...
...
@@ -29,7 +29,7 @@ describe('SelectionTabs', function () {
enableExperimentalNewNoteButton
:
false
,
};
fakeStore
=
{
clearSelect
edAnnotations
:
sinon
.
stub
(),
clearSelect
ion
:
sinon
.
stub
(),
selectTab
:
sinon
.
stub
(),
annotationCount
:
sinon
.
stub
().
returns
(
123
),
noteCount
:
sinon
.
stub
().
returns
(
456
),
...
...
@@ -245,7 +245,7 @@ describe('SelectionTabs', function () {
findButton
(
wrapper
,
label
).
simulate
(
'click'
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
ion
);
assert
.
calledWith
(
fakeStore
.
selectTab
,
tab
);
});
});
...
...
@@ -260,7 +260,7 @@ describe('SelectionTabs', function () {
findButton
(
wrapper
,
'Page Notes'
).
simulate
(
'click'
);
assert
.
notCalled
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
notCalled
(
fakeStore
.
clearSelect
ion
);
assert
.
notCalled
(
fakeStore
.
selectTab
);
});
...
...
src/sidebar/components/test/sidebar-content-test.js
View file @
dcf59584
...
...
@@ -41,7 +41,7 @@ describe('SidebarContent', () => {
};
fakeStore
=
{
// actions
clearSelect
edAnnotations
:
sinon
.
stub
(),
clearSelect
ion
:
sinon
.
stub
(),
selectTab
:
sinon
.
stub
(),
// selectors
annotationExists
:
sinon
.
stub
(),
...
...
@@ -91,21 +91,21 @@ describe('SidebarContent', () => {
fakeStore
.
profile
.
returns
({
userid
:
'somethingElse'
});
wrapper
.
setProps
({});
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
assert
.
notCalled
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
notCalled
(
fakeStore
.
clearSelect
ion
);
});
it
(
'clears selected annotations and loads annotations when groupId changes'
,
()
=>
{
fakeStore
.
focusedGroupId
.
returns
(
'affable'
);
wrapper
.
setProps
({});
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
ion
);
});
it
(
'loads annotations when searchURIs change'
,
()
=>
{
fakeStore
.
searchUris
.
returns
([
'abandon-ship'
]);
wrapper
.
setProps
({});
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
assert
.
notCalled
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
notCalled
(
fakeStore
.
clearSelect
ion
);
});
});
...
...
src/sidebar/store/modules/selection.js
View file @
dcf59584
...
...
@@ -193,10 +193,6 @@ const update = {
};
},
CLEAR_SELECTED_ANNOTATIONS
:
function
()
{
return
resetSelection
();
},
CLEAR_SELECTION
:
function
()
{
return
resetSelection
();
},
...
...
@@ -306,11 +302,10 @@ function changeFocusModeUser(user) {
return
{
type
:
actions
.
CHANGE_FOCUS_MODE_USER
,
user
};
}
/** De-select all annotations. */
function
clearSelectedAnnotations
()
{
return
{
type
:
actions
.
CLEAR_SELECTED_ANNOTATIONS
};
}
/**
* Clear all selected annotations and filters. This will leave user-focus
* alone, however.
*/
function
clearSelection
()
{
return
{
type
:
actions
.
CLEAR_SELECTION
,
...
...
@@ -602,7 +597,6 @@ const threadState = createSelector(
*
* // Actions
* @prop {typeof changeFocusModeUser} changeFocusModeUser
* @prop {typeof clearSelectedAnnotations} clearSelectedAnnotations
* @prop {typeof clearSelection} clearSelection
* @prop {typeof selectAnnotations} selectAnnotations
* @prop {typeof selectTab} selectTab
...
...
@@ -639,7 +633,6 @@ export default {
actions
:
{
changeFocusModeUser
,
clearSelectedAnnotations
,
clearSelection
,
selectAnnotations
,
selectTab
,
...
...
src/sidebar/store/modules/test/selection-test.js
View file @
dcf59584
...
...
@@ -279,20 +279,6 @@ describe('sidebar/store/modules/selection', () => {
});
});
describe
(
'clearSelectedAnnotations()'
,
function
()
{
it
(
'removes all annotations from the selection'
,
function
()
{
store
.
selectAnnotations
([
1
]);
store
.
clearSelectedAnnotations
();
assert
.
isEmpty
(
getSelectionState
().
selected
);
});
it
(
'clears the current search query'
,
function
()
{
store
.
setFilterQuery
(
'foo'
);
store
.
clearSelectedAnnotations
();
assert
.
isNull
(
getSelectionState
().
filterQuery
);
});
});
describe
(
'setFilterQuery()'
,
function
()
{
it
(
'sets the filter query'
,
function
()
{
store
.
setFilterQuery
(
'a-query'
);
...
...
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