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 }) {
...
@@ -100,14 +100,14 @@ function SelectionTabs({ isLoading, settings }) {
);
);
// actions
// actions
const
store
=
useStore
(
store
=>
({
const
store
=
useStore
(
store
=>
({
clearSelect
edAnnotations
:
store
.
clearSelectedAnnotations
,
clearSelect
ion
:
store
.
clearSelection
,
selectTab
:
store
.
selectTab
,
selectTab
:
store
.
selectTab
,
}));
}));
const
isThemeClean
=
settings
.
theme
===
'clean'
;
const
isThemeClean
=
settings
.
theme
===
'clean'
;
const
selectTab
=
tabId
=>
{
const
selectTab
=
tabId
=>
{
store
.
clearSelect
edAnnotations
();
store
.
clearSelect
ion
();
store
.
selectTab
(
tabId
);
store
.
selectTab
(
tabId
);
};
};
...
...
src/sidebar/components/sidebar-content.js
View file @
dcf59584
...
@@ -60,9 +60,7 @@ function SidebarContent({
...
@@ -60,9 +60,7 @@ function SidebarContent({
:
null
;
:
null
;
// Actions
// Actions
const
clearSelectedAnnotations
=
useStore
(
const
clearSelection
=
useStore
(
store
=>
store
.
clearSelection
);
store
=>
store
.
clearSelectedAnnotations
);
const
selectTab
=
useStore
(
store
=>
store
.
selectTab
);
const
selectTab
=
useStore
(
store
=>
store
.
selectTab
);
// If, after loading completes, no `linkedAnnotation` object is present when
// If, after loading completes, no `linkedAnnotation` object is present when
...
@@ -96,14 +94,14 @@ function SidebarContent({
...
@@ -96,14 +94,14 @@ function SidebarContent({
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
prevGroupId
.
current
||
prevGroupId
.
current
!==
focusedGroupId
)
{
if
(
!
prevGroupId
.
current
||
prevGroupId
.
current
!==
focusedGroupId
)
{
// Clear any selected annotations when the group ID changes
// Clear any selected annotations when the group ID changes
clearSelect
edAnnotations
();
clearSelect
ion
();
prevGroupId
.
current
=
focusedGroupId
;
prevGroupId
.
current
=
focusedGroupId
;
}
}
if
(
focusedGroupId
&&
searchUris
.
length
)
{
if
(
focusedGroupId
&&
searchUris
.
length
)
{
loadAnnotationsService
.
load
(
searchUris
,
focusedGroupId
);
loadAnnotationsService
.
load
(
searchUris
,
focusedGroupId
);
}
}
},
[
},
[
clearSelect
edAnnotations
,
clearSelect
ion
,
loadAnnotationsService
,
loadAnnotationsService
,
focusedGroupId
,
focusedGroupId
,
userId
,
userId
,
...
...
src/sidebar/components/test/hypothesis-app-test.js
View file @
dcf59584
...
@@ -37,7 +37,6 @@ describe('HypothesisApp', () => {
...
@@ -37,7 +37,6 @@ describe('HypothesisApp', () => {
fakeShouldAutoDisplayTutorial
=
sinon
.
stub
().
returns
(
false
);
fakeShouldAutoDisplayTutorial
=
sinon
.
stub
().
returns
(
false
);
fakeStore
=
{
fakeStore
=
{
clearSelectedAnnotations
:
sinon
.
spy
(),
clearGroups
:
sinon
.
stub
(),
clearGroups
:
sinon
.
stub
(),
closeSidebarPanel
:
sinon
.
stub
(),
closeSidebarPanel
:
sinon
.
stub
(),
openSidebarPanel
:
sinon
.
stub
(),
openSidebarPanel
:
sinon
.
stub
(),
...
...
src/sidebar/components/test/selection-tabs-test.js
View file @
dcf59584
...
@@ -29,7 +29,7 @@ describe('SelectionTabs', function () {
...
@@ -29,7 +29,7 @@ describe('SelectionTabs', function () {
enableExperimentalNewNoteButton
:
false
,
enableExperimentalNewNoteButton
:
false
,
};
};
fakeStore
=
{
fakeStore
=
{
clearSelect
edAnnotations
:
sinon
.
stub
(),
clearSelect
ion
:
sinon
.
stub
(),
selectTab
:
sinon
.
stub
(),
selectTab
:
sinon
.
stub
(),
annotationCount
:
sinon
.
stub
().
returns
(
123
),
annotationCount
:
sinon
.
stub
().
returns
(
123
),
noteCount
:
sinon
.
stub
().
returns
(
456
),
noteCount
:
sinon
.
stub
().
returns
(
456
),
...
@@ -245,7 +245,7 @@ describe('SelectionTabs', function () {
...
@@ -245,7 +245,7 @@ describe('SelectionTabs', function () {
findButton
(
wrapper
,
label
).
simulate
(
'click'
);
findButton
(
wrapper
,
label
).
simulate
(
'click'
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
ion
);
assert
.
calledWith
(
fakeStore
.
selectTab
,
tab
);
assert
.
calledWith
(
fakeStore
.
selectTab
,
tab
);
});
});
});
});
...
@@ -260,7 +260,7 @@ describe('SelectionTabs', function () {
...
@@ -260,7 +260,7 @@ describe('SelectionTabs', function () {
findButton
(
wrapper
,
'Page Notes'
).
simulate
(
'click'
);
findButton
(
wrapper
,
'Page Notes'
).
simulate
(
'click'
);
assert
.
notCalled
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
notCalled
(
fakeStore
.
clearSelect
ion
);
assert
.
notCalled
(
fakeStore
.
selectTab
);
assert
.
notCalled
(
fakeStore
.
selectTab
);
});
});
...
...
src/sidebar/components/test/sidebar-content-test.js
View file @
dcf59584
...
@@ -41,7 +41,7 @@ describe('SidebarContent', () => {
...
@@ -41,7 +41,7 @@ describe('SidebarContent', () => {
};
};
fakeStore
=
{
fakeStore
=
{
// actions
// actions
clearSelect
edAnnotations
:
sinon
.
stub
(),
clearSelect
ion
:
sinon
.
stub
(),
selectTab
:
sinon
.
stub
(),
selectTab
:
sinon
.
stub
(),
// selectors
// selectors
annotationExists
:
sinon
.
stub
(),
annotationExists
:
sinon
.
stub
(),
...
@@ -91,21 +91,21 @@ describe('SidebarContent', () => {
...
@@ -91,21 +91,21 @@ describe('SidebarContent', () => {
fakeStore
.
profile
.
returns
({
userid
:
'somethingElse'
});
fakeStore
.
profile
.
returns
({
userid
:
'somethingElse'
});
wrapper
.
setProps
({});
wrapper
.
setProps
({});
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
assert
.
notCalled
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
notCalled
(
fakeStore
.
clearSelect
ion
);
});
});
it
(
'clears selected annotations and loads annotations when groupId changes'
,
()
=>
{
it
(
'clears selected annotations and loads annotations when groupId changes'
,
()
=>
{
fakeStore
.
focusedGroupId
.
returns
(
'affable'
);
fakeStore
.
focusedGroupId
.
returns
(
'affable'
);
wrapper
.
setProps
({});
wrapper
.
setProps
({});
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
edAnnotations
);
assert
.
calledOnce
(
fakeStore
.
clearSelect
ion
);
});
});
it
(
'loads annotations when searchURIs change'
,
()
=>
{
it
(
'loads annotations when searchURIs change'
,
()
=>
{
fakeStore
.
searchUris
.
returns
([
'abandon-ship'
]);
fakeStore
.
searchUris
.
returns
([
'abandon-ship'
]);
wrapper
.
setProps
({});
wrapper
.
setProps
({});
assert
.
calledOnce
(
fakeLoadAnnotationsService
.
load
);
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 = {
...
@@ -193,10 +193,6 @@ const update = {
};
};
},
},
CLEAR_SELECTED_ANNOTATIONS
:
function
()
{
return
resetSelection
();
},
CLEAR_SELECTION
:
function
()
{
CLEAR_SELECTION
:
function
()
{
return
resetSelection
();
return
resetSelection
();
},
},
...
@@ -306,11 +302,10 @@ function changeFocusModeUser(user) {
...
@@ -306,11 +302,10 @@ function changeFocusModeUser(user) {
return
{
type
:
actions
.
CHANGE_FOCUS_MODE_USER
,
user
};
return
{
type
:
actions
.
CHANGE_FOCUS_MODE_USER
,
user
};
}
}
/** De-select all annotations. */
/**
function
clearSelectedAnnotations
()
{
* Clear all selected annotations and filters. This will leave user-focus
return
{
type
:
actions
.
CLEAR_SELECTED_ANNOTATIONS
};
* alone, however.
}
*/
function
clearSelection
()
{
function
clearSelection
()
{
return
{
return
{
type
:
actions
.
CLEAR_SELECTION
,
type
:
actions
.
CLEAR_SELECTION
,
...
@@ -602,7 +597,6 @@ const threadState = createSelector(
...
@@ -602,7 +597,6 @@ const threadState = createSelector(
*
*
* // Actions
* // Actions
* @prop {typeof changeFocusModeUser} changeFocusModeUser
* @prop {typeof changeFocusModeUser} changeFocusModeUser
* @prop {typeof clearSelectedAnnotations} clearSelectedAnnotations
* @prop {typeof clearSelection} clearSelection
* @prop {typeof clearSelection} clearSelection
* @prop {typeof selectAnnotations} selectAnnotations
* @prop {typeof selectAnnotations} selectAnnotations
* @prop {typeof selectTab} selectTab
* @prop {typeof selectTab} selectTab
...
@@ -639,7 +633,6 @@ export default {
...
@@ -639,7 +633,6 @@ export default {
actions
:
{
actions
:
{
changeFocusModeUser
,
changeFocusModeUser
,
clearSelectedAnnotations
,
clearSelection
,
clearSelection
,
selectAnnotations
,
selectAnnotations
,
selectTab
,
selectTab
,
...
...
src/sidebar/store/modules/test/selection-test.js
View file @
dcf59584
...
@@ -279,20 +279,6 @@ describe('sidebar/store/modules/selection', () => {
...
@@ -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
()
{
describe
(
'setFilterQuery()'
,
function
()
{
it
(
'sets the filter query'
,
function
()
{
it
(
'sets the filter query'
,
function
()
{
store
.
setFilterQuery
(
'a-query'
);
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