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
bcd488c7
Unverified
Commit
bcd488c7
authored
Mar 08, 2018
by
Robert Knight
Committed by
GitHub
Mar 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #686 from hypothesis/default-to-notes-tab-when-only-notes-present
Default to notes tab when only notes present
parents
99d764ab
07301504
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
selection.js
src/sidebar/reducers/selection.js
+12
-0
annotation-ui-test.js
src/sidebar/test/annotation-ui-test.js
+22
-0
No files found.
src/sidebar/reducers/selection.js
View file @
bcd488c7
...
...
@@ -14,6 +14,7 @@ var immutable = require('seamless-immutable');
var
toSet
=
require
(
'../util/array-util'
).
toSet
;
var
uiConstants
=
require
(
'../ui-constants'
);
var
tabs
=
require
(
'../tabs'
);
var
util
=
require
(
'./util'
);
...
...
@@ -132,6 +133,17 @@ var update = {
};
},
ADD_ANNOTATIONS
(
state
,
action
)
{
var
counts
=
tabs
.
counts
(
action
.
annotations
);
// If there are no annotations at all, ADD_ANNOTATIONS will not be called.
var
haveOnlyPageNotes
=
counts
.
notes
===
action
.
annotations
.
length
;
// If this is the init phase and there are only page notes, select the page notes tab.
if
(
state
.
annotations
.
length
===
0
&&
haveOnlyPageNotes
){
return
{
selectedTab
:
uiConstants
.
TAB_NOTES
};
}
return
{};
},
SET_FILTER_QUERY
:
function
(
state
,
action
)
{
return
{
filterQuery
:
action
.
query
,
...
...
src/sidebar/test/annotation-ui-test.js
View file @
bcd488c7
...
...
@@ -10,6 +10,7 @@ var uiConstants = require('../ui-constants');
var
defaultAnnotation
=
annotationFixtures
.
defaultAnnotation
;
var
newAnnotation
=
annotationFixtures
.
newAnnotation
;
var
oldPageNote
=
annotationFixtures
.
oldPageNote
;
var
fixtures
=
immutable
({
pair
:
[
...
...
@@ -79,6 +80,27 @@ describe('annotationUI', function () {
[
sinon
.
match
(
annot
)]);
});
it
(
'does not change `selectedTab` state if annotations are already loaded'
,
function
()
{
var
annot
=
defaultAnnotation
();
annotationUI
.
addAnnotations
([
annot
]);
var
page
=
oldPageNote
();
annotationUI
.
addAnnotations
([
page
]);
assert
.
equal
(
annotationUI
.
getState
().
selectedTab
,
uiConstants
.
TAB_ANNOTATIONS
);
});
it
(
'sets `selectedTab` to "note" if only page notes are present'
,
function
()
{
var
page
=
oldPageNote
();
annotationUI
.
addAnnotations
([
page
]);
assert
.
equal
(
annotationUI
.
getState
().
selectedTab
,
uiConstants
.
TAB_NOTES
);
});
it
(
'leaves `selectedTab` as "annotation" if annotations and/or page notes are present'
,
function
()
{
var
page
=
oldPageNote
();
var
annot
=
defaultAnnotation
();
annotationUI
.
addAnnotations
([
annot
,
page
]);
assert
.
equal
(
annotationUI
.
getState
().
selectedTab
,
uiConstants
.
TAB_ANNOTATIONS
);
});
it
(
'assigns a local tag to annotations'
,
function
()
{
var
annotA
=
Object
.
assign
(
defaultAnnotation
(),
{
id
:
'a1'
});
var
annotB
=
Object
.
assign
(
defaultAnnotation
(),
{
id
:
'a2'
});
...
...
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