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
72c5253b
Commit
72c5253b
authored
Jul 29, 2022
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add store state to hold content information banner data
parent
97da55d7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
viewer-test.js
src/sidebar/store/modules/test/viewer-test.js
+12
-0
viewer.js
src/sidebar/store/modules/viewer.js
+31
-0
No files found.
src/sidebar/store/modules/test/viewer-test.js
View file @
72c5253b
...
...
@@ -26,4 +26,16 @@ describe('store/modules/viewer', () => {
assert
.
isTrue
(
store
.
hasSidebarOpened
());
});
});
describe
(
'getContentInfo'
,
()
=>
{
it
(
'returns data for content info banner'
,
()
=>
{
const
contentInfo
=
{
logo
:
{},
item
:
{
title
:
'Some article'
},
links
:
{},
};
store
.
setContentInfo
(
contentInfo
);
assert
.
deepEqual
(
store
.
getContentInfo
(),
contentInfo
);
});
});
});
src/sidebar/store/modules/viewer.js
View file @
72c5253b
import
{
createStoreModule
,
makeAction
}
from
'../create-store'
;
/**
* @typedef {import('../../../types/annotator').ContentInfoConfig} ContentInfoConfig
*/
/**
* This module defines actions and state related to the display mode of the
* sidebar.
...
...
@@ -11,6 +15,13 @@ const initialState = {
* current state of the sidebar, but tracks whether it has ever been open
*/
sidebarHasOpened
:
false
,
/**
* Data for the content information banner shown in the host frame.
*
* @type {ContentInfoConfig|null}
*/
contentInfo
:
null
,
};
/** @typedef {typeof initialState} State */
...
...
@@ -28,6 +39,14 @@ const reducers = {
// Otherwise, nothing to do here
return
{};
},
/**
* @param {State} state
* @param {{ info: ContentInfoConfig }} action
*/
SET_CONTENT_INFO
(
state
,
action
)
{
return
{
contentInfo
:
action
.
info
};
},
};
/**
...
...
@@ -42,13 +61,25 @@ function hasSidebarOpened(state) {
return
state
.
sidebarHasOpened
;
}
/** @param {ContentInfoConfig} info */
function
setContentInfo
(
info
)
{
return
makeAction
(
reducers
,
'SET_CONTENT_INFO'
,
{
info
});
}
/** @param {State} state */
function
getContentInfo
(
state
)
{
return
state
.
contentInfo
;
}
export
const
viewerModule
=
createStoreModule
(
initialState
,
{
namespace
:
'viewer'
,
reducers
,
actionCreators
:
{
setContentInfo
,
setSidebarOpened
,
},
selectors
:
{
getContentInfo
,
hasSidebarOpened
,
},
});
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