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
18fd3307
Commit
18fd3307
authored
Apr 30, 2020
by
Lyza Danger Gardner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `sidebarHasOpened` to track whether sidebar has ever been opened
parent
d4777fa5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
5 deletions
+55
-5
frame-sync.js
src/sidebar/services/frame-sync.js
+1
-1
frame-sync-test.js
src/sidebar/services/test/frame-sync-test.js
+4
-2
viewer-test.js
src/sidebar/store/modules/test/viewer-test.js
+19
-0
viewer.js
src/sidebar/store/modules/viewer.js
+31
-2
No files found.
src/sidebar/services/frame-sync.js
View file @
18fd3307
...
...
@@ -176,7 +176,7 @@ export default function FrameSync($rootScope, $window, store, bridge) {
});
bridge
.
on
(
'sidebarOpened'
,
function
()
{
$rootScope
.
$broadcast
(
'sidebarOpened'
);
store
.
setSidebarOpened
(
true
);
});
// These invoke the matching methods by name on the Guests
...
...
src/sidebar/services/test/frame-sync-test.js
View file @
18fd3307
...
...
@@ -66,6 +66,7 @@ describe('sidebar/services/frame-sync', function () {
openSidebarPanel
:
sinon
.
stub
(),
selectAnnotations
:
sinon
.
stub
(),
selectTab
:
sinon
.
stub
(),
setSidebarOpened
:
sinon
.
stub
(),
toggleSelectedAnnotations
:
sinon
.
stub
(),
updateAnchorStatus
:
sinon
.
stub
(),
}
...
...
@@ -376,9 +377,10 @@ describe('sidebar/services/frame-sync', function () {
});
describe
(
'on "sidebarOpened" message'
,
function
()
{
it
(
'
broadcasts a sidebarOpened event
'
,
function
()
{
it
(
'
sets the sidebar open in the store
'
,
function
()
{
fakeBridge
.
emit
(
'sidebarOpened'
);
assert
.
calledWith
(
$rootScope
.
$broadcast
,
'sidebarOpened'
);
assert
.
calledWith
(
fakeStore
.
setSidebarOpened
,
true
);
});
});
...
...
src/sidebar/store/modules/test/viewer-test.js
View file @
18fd3307
...
...
@@ -19,4 +19,23 @@ describe('store/modules/viewer', function () {
assert
.
isFalse
(
store
.
getState
().
viewer
.
visibleHighlights
);
});
});
describe
(
'hasSidebarOpened'
,
()
=>
{
it
(
'is `false` if sidebar has never been opened'
,
()
=>
{
assert
.
isFalse
(
store
.
hasSidebarOpened
());
store
.
setSidebarOpened
(
false
);
assert
.
isFalse
(
store
.
hasSidebarOpened
());
});
it
(
'is `true` if sidebar has been opened'
,
()
=>
{
store
.
setSidebarOpened
(
true
);
assert
.
isTrue
(
store
.
hasSidebarOpened
());
});
it
(
'is `true` if sidebar is closed after being opened'
,
()
=>
{
store
.
setSidebarOpened
(
true
);
store
.
setSidebarOpened
(
false
);
assert
.
isTrue
(
store
.
hasSidebarOpened
());
});
});
});
src/sidebar/store/modules/viewer.js
View file @
18fd3307
...
...
@@ -7,6 +7,9 @@ import * as util from '../util';
function
init
()
{
return
{
// Has the sidebar ever been opened? NB: This is not necessarily the
// current state of the sidebar, but tracks whether it has ever been open
sidebarHasOpened
:
false
,
visibleHighlights
:
false
,
};
}
...
...
@@ -15,10 +18,20 @@ const update = {
SET_HIGHLIGHTS_VISIBLE
:
function
(
state
,
action
)
{
return
{
visibleHighlights
:
action
.
visible
};
},
SET_SIDEBAR_OPENED
:
(
state
,
action
)
=>
{
if
(
action
.
opened
===
true
)
{
// If the sidebar is open, track that it has ever been opened
return
{
sidebarHasOpened
:
true
};
}
// Otherwise, nothing to do here
return
{};
},
};
const
actions
=
util
.
actionTypes
(
update
);
// Action creators
/**
* Sets whether annotation highlights in connected documents are shown
* or not.
...
...
@@ -27,12 +40,28 @@ function setShowHighlights(show) {
return
{
type
:
actions
.
SET_HIGHLIGHTS_VISIBLE
,
visible
:
show
};
}
/**
* @param {boolean} sidebarState - If the sidebar is open
*/
function
setSidebarOpened
(
opened
)
{
return
{
type
:
actions
.
SET_SIDEBAR_OPENED
,
opened
};
}
// Selectors
function
hasSidebarOpened
(
state
)
{
return
state
.
viewer
.
sidebarHasOpened
;
}
export
default
{
init
:
init
,
namespace
:
'viewer'
,
update
:
update
,
actions
:
{
setShowHighlights
:
setShowHighlights
,
setShowHighlights
,
setSidebarOpened
,
},
selectors
:
{
hasSidebarOpened
,
},
selectors
:
{},
};
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