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
e1cb9919
Unverified
Commit
e1cb9919
authored
Sep 06, 2019
by
Kyle Keating
Committed by
GitHub
Sep 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1349 from hypothesis/namespace-viewer-module
Namespace viewer module
parents
3c3017b3
7d332653
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
18 deletions
+36
-18
root-thread.js
src/sidebar/services/root-thread.js
+1
-1
root-thread-test.js
src/sidebar/services/test/root-thread-test.js
+3
-1
annotations.js
src/sidebar/store/modules/annotations.js
+1
-1
real-time-updates.js
src/sidebar/store/modules/real-time-updates.js
+2
-2
annotations-test.js
src/sidebar/store/modules/test/annotations-test.js
+2
-1
viewer-test.js
src/sidebar/store/modules/test/viewer-test.js
+21
-10
viewer.js
src/sidebar/store/modules/viewer.js
+2
-1
index-test.js
src/sidebar/store/test/index-test.js
+4
-1
No files found.
src/sidebar/services/root-thread.js
View file @
e1cb9919
...
@@ -68,7 +68,7 @@ function RootThread($rootScope, store, searchFilter, viewFilter) {
...
@@ -68,7 +68,7 @@ function RootThread($rootScope, store, searchFilter, viewFilter) {
}
}
let
threadFilterFn
;
let
threadFilterFn
;
if
(
state
.
base
.
isSidebar
&&
!
shouldFilterThread
())
{
if
(
state
.
viewer
.
isSidebar
&&
!
shouldFilterThread
())
{
threadFilterFn
=
function
(
thread
)
{
threadFilterFn
=
function
(
thread
)
{
if
(
!
thread
.
annotation
)
{
if
(
!
thread
.
annotation
)
{
return
false
;
return
false
;
...
...
src/sidebar/services/test/root-thread-test.js
View file @
e1cb9919
...
@@ -36,6 +36,8 @@ describe('rootThread', function() {
...
@@ -36,6 +36,8 @@ describe('rootThread', function() {
state
:
{
state
:
{
base
:
{
base
:
{
annotations
:
[],
annotations
:
[],
},
viewer
:
{
isSidebar
:
true
,
isSidebar
:
true
,
visibleHighlights
:
false
,
visibleHighlights
:
false
,
},
},
...
@@ -288,7 +290,7 @@ describe('rootThread', function() {
...
@@ -288,7 +290,7 @@ describe('rootThread', function() {
it
(
'does not filter annotations when not in the sidebar'
,
function
()
{
it
(
'does not filter annotations when not in the sidebar'
,
function
()
{
fakeBuildThread
.
reset
();
fakeBuildThread
.
reset
();
fakeStore
.
state
.
base
.
isSidebar
=
false
;
fakeStore
.
state
.
viewer
.
isSidebar
=
false
;
rootThread
.
thread
(
fakeStore
.
state
);
rootThread
.
thread
(
fakeStore
.
state
);
const
threadFilterFn
=
fakeBuildThread
.
args
[
0
][
1
].
threadFilterFn
;
const
threadFilterFn
=
fakeBuildThread
.
args
[
0
][
1
].
threadFilterFn
;
...
...
src/sidebar/store/modules/annotations.js
View file @
e1cb9919
...
@@ -252,7 +252,7 @@ function addAnnotations(annotations, now) {
...
@@ -252,7 +252,7 @@ function addAnnotations(annotations, now) {
currentAnnotationCount
:
getState
().
base
.
annotations
.
length
,
currentAnnotationCount
:
getState
().
base
.
annotations
.
length
,
});
});
if
(
!
getState
().
base
.
isSidebar
)
{
if
(
!
getState
().
viewer
.
isSidebar
)
{
return
;
return
;
}
}
...
...
src/sidebar/store/modules/real-time-updates.js
View file @
e1cb9919
...
@@ -97,8 +97,8 @@ function receiveRealTimeUpdates({
...
@@ -97,8 +97,8 @@ function receiveRealTimeUpdates({
// group and reload all annotations and discard pending updates
// group and reload all annotations and discard pending updates
// when switching groups.
// when switching groups.
if
(
if
(
ann
.
group
===
groupSelectors
.
focusedGroupId
(
getState
()
.
base
)
||
ann
.
group
===
groupSelectors
.
focusedGroupId
(
getState
())
||
!
viewerSelectors
.
isSidebar
(
getState
()
.
base
)
!
viewerSelectors
.
isSidebar
(
getState
())
)
{
)
{
pendingUpdates
[
ann
.
id
]
=
ann
;
pendingUpdates
[
ann
.
id
]
=
ann
;
}
}
...
...
src/sidebar/store/modules/test/annotations-test.js
View file @
e1cb9919
...
@@ -5,6 +5,7 @@ const createStoreFromModules = require('../../create-store');
...
@@ -5,6 +5,7 @@ const createStoreFromModules = require('../../create-store');
const
drafts
=
require
(
'../drafts'
);
const
drafts
=
require
(
'../drafts'
);
const
fixtures
=
require
(
'../../../test/annotation-fixtures'
);
const
fixtures
=
require
(
'../../../test/annotation-fixtures'
);
const
selection
=
require
(
'../selection'
);
const
selection
=
require
(
'../selection'
);
const
viewer
=
require
(
'../viewer'
);
const
uiConstants
=
require
(
'../../../ui-constants'
);
const
uiConstants
=
require
(
'../../../ui-constants'
);
const
unroll
=
require
(
'../../../../shared/test/util'
).
unroll
;
const
unroll
=
require
(
'../../../../shared/test/util'
).
unroll
;
...
@@ -14,7 +15,7 @@ const { actions, selectors } = annotations;
...
@@ -14,7 +15,7 @@ const { actions, selectors } = annotations;
* Create a Redux store which handles annotation, selection and draft actions.
* Create a Redux store which handles annotation, selection and draft actions.
*/
*/
function
createStore
()
{
function
createStore
()
{
return
createStoreFromModules
([
annotations
,
selection
,
drafts
],
[{},
{},
{}]);
return
createStoreFromModules
([
annotations
,
selection
,
drafts
,
viewer
],
[
{}]);
}
}
// Tests for most of the functionality in reducers/annotations.js are currently
// Tests for most of the functionality in reducers/annotations.js are currently
...
...
src/sidebar/store/modules/test/viewer-test.js
View file @
e1cb9919
'use strict'
;
'use strict'
;
const
viewer
=
require
(
'../viewer'
);
const
viewer
=
require
(
'../viewer'
);
const
createStore
=
require
(
'../../create-store'
);
const
util
=
require
(
'../../util'
);
describe
(
'store/modules/viewer'
,
function
()
{
let
store
;
const
{
init
,
actions
,
selectors
}
=
viewer
;
beforeEach
(()
=>
{
const
update
=
util
.
createReducer
(
viewer
.
update
);
store
=
createStore
([
viewer
]);
});
describe
(
'viewer reducer'
,
function
()
{
describe
(
'#setAppIsSidebar'
,
function
()
{
describe
(
'#setAppIsSidebar'
,
function
()
{
it
(
'sets a flag indicating that the app is not the sidebar'
,
function
()
{
store
.
setAppIsSidebar
(
false
);
assert
.
isFalse
(
store
.
isSidebar
());
});
it
(
'sets a flag indicating that the app is the sidebar'
,
function
()
{
it
(
'sets a flag indicating that the app is the sidebar'
,
function
()
{
const
state
=
update
(
init
(),
actions
.
setAppIsSidebar
(
true
)
);
store
.
setAppIsSidebar
(
true
);
assert
.
isTrue
(
s
electors
.
isSidebar
(
state
));
assert
.
isTrue
(
s
tore
.
isSidebar
(
));
});
});
it
(
'sets a flag indicating that the app is not the sidebar'
,
function
()
{
it
(
'sets a flag indicating that highlights are visible'
,
function
()
{
const
state
=
update
(
init
(),
actions
.
setAppIsSidebar
(
false
));
store
.
setShowHighlights
(
true
);
assert
.
isFalse
(
selectors
.
isSidebar
(
state
));
assert
.
isTrue
(
store
.
getRootState
().
viewer
.
visibleHighlights
);
});
it
(
'sets a flag indicating that highlights are not visible'
,
function
()
{
store
.
setShowHighlights
(
false
);
assert
.
isFalse
(
store
.
getRootState
().
viewer
.
visibleHighlights
);
});
});
});
});
});
});
src/sidebar/store/modules/viewer.js
View file @
e1cb9919
...
@@ -49,11 +49,12 @@ function setShowHighlights(show) {
...
@@ -49,11 +49,12 @@ function setShowHighlights(show) {
* client, as opposed to the standalone annotation page or stream views.
* client, as opposed to the standalone annotation page or stream views.
*/
*/
function
isSidebar
(
state
)
{
function
isSidebar
(
state
)
{
return
state
.
isSidebar
;
return
state
.
viewer
.
isSidebar
;
}
}
module
.
exports
=
{
module
.
exports
=
{
init
:
init
,
init
:
init
,
namespace
:
'viewer'
,
update
:
update
,
update
:
update
,
actions
:
{
actions
:
{
setAppIsSidebar
:
setAppIsSidebar
,
setAppIsSidebar
:
setAppIsSidebar
,
...
...
src/sidebar/store/test/index-test.js
View file @
e1cb9919
...
@@ -363,7 +363,10 @@ describe('store', function() {
...
@@ -363,7 +363,10 @@ describe('store', function() {
'sets the visibleHighlights state flag to #state'
,
'sets the visibleHighlights state flag to #state'
,
function
(
testCase
)
{
function
(
testCase
)
{
store
.
setShowHighlights
(
testCase
.
state
);
store
.
setShowHighlights
(
testCase
.
state
);
assert
.
equal
(
store
.
getState
().
visibleHighlights
,
testCase
.
state
);
assert
.
equal
(
store
.
getRootState
().
viewer
.
visibleHighlights
,
testCase
.
state
);
},
},
[{
state
:
true
},
{
state
:
false
}]
[{
state
:
true
},
{
state
:
false
}]
);
);
...
...
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