Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
40d34bb6
Commit
40d34bb6
authored
5 years ago
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Only create a sidebar panel if a default panel type is configured
parent
0789034f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
__tests__/src/actions/window.test.js
+32
-1
32 additions, 1 deletion
__tests__/src/actions/window.test.js
src/state/actions/window.js
+28
-22
28 additions, 22 deletions
src/state/actions/window.js
with
60 additions
and
23 deletions
__tests__/src/actions/window.test.js
+
32
−
1
View file @
40d34bb6
...
...
@@ -150,7 +150,9 @@ describe('window actions', () => {
companionWindows
:
{},
config
:
{
thumbnailNavigation
:
{},
window
:
{},
window
:
{
defaultSideBarPanel
:
'
info
'
,
},
},
windows
:
{},
};
...
...
@@ -167,6 +169,35 @@ describe('window actions', () => {
expect
(
action
.
window
.
companionWindowIds
[
2
]).
toEqual
(
action
.
companionWindows
[
2
].
id
);
expect
(
action
.
companionWindows
[
2
]).
toMatchObject
({
content
:
'
attribution
'
,
position
:
'
right
'
});
});
it
(
'
creates a new window without a default sidebar
'
,
()
=>
{
const
options
=
{
canvasIndex
:
1
,
companionWindows
:
[],
id
:
'
helloworld
'
,
};
const
mockState
=
{
companionWindows
:
{},
config
:
{
thumbnailNavigation
:
{},
window
:
{
defaultSideBarPanel
:
null
,
},
},
windows
:
{},
};
const
mockDispatch
=
jest
.
fn
(()
=>
({}));
const
mockGetState
=
jest
.
fn
(()
=>
mockState
);
const
thunk
=
actions
.
addWindow
(
options
);
thunk
(
mockDispatch
,
mockGetState
);
const
action
=
mockDispatch
.
mock
.
calls
[
0
][
0
];
expect
(
action
.
window
.
companionWindowIds
.
length
).
toEqual
(
1
);
expect
(
action
.
companionWindows
[
0
]).
toMatchObject
({
content
:
'
thumbnailNavigation
'
});
});
});
describe
(
'
updateWindow
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/state/actions/window.js
+
28
−
22
View file @
40d34bb6
...
...
@@ -42,14 +42,37 @@ export function addWindow({ companionWindows, ...options }) {
const
{
config
,
windows
}
=
getState
();
const
numWindows
=
Object
.
keys
(
windows
).
length
;
const
cwDefault
=
`cw-
${
uuid
()}
`
;
const
cwThumbs
=
`cw-
${
uuid
()}
`
;
const
additionalCompanionWindowIds
=
(
companionWindows
||
[]).
map
(
e
=>
`cw-
${
uuid
()}
`
);
const
defaultCompanionWindows
=
[
{
content
:
'
thumbnailNavigation
'
,
default
:
true
,
id
:
cwThumbs
,
position
:
options
.
thumbnailNavigationPosition
||
config
.
thumbnailNavigation
.
defaultPosition
,
},
...(
(
companionWindows
||
[]).
map
((
cw
,
i
)
=>
({
...
cw
,
id
:
`cw-
${
uuid
()}
`
}))
),
];
if
(
config
.
window
.
defaultSideBarPanel
)
{
defaultCompanionWindows
.
unshift
(
{
content
:
config
.
window
.
defaultSideBarPanel
,
default
:
true
,
id
:
`cw-
${
uuid
()}
`
,
position
:
'
left
'
,
},
);
}
const
defaultOptions
=
{
canvasId
:
undefined
,
collectionIndex
:
0
,
companionAreaOpen
:
true
,
companionWindowIds
:
[
cwD
efault
,
cwThumbs
,
...
additionalCompanionWindowIds
]
,
companionWindowIds
:
d
efault
CompanionWindows
.
map
(
cw
=>
cw
.
id
)
,
displayAllAnnotations
:
config
.
displayAllAnnotations
||
false
,
draggingEnabled
:
true
,
id
:
`window-
${
uuid
()}
`
,
...
...
@@ -59,7 +82,7 @@ export function addWindow({ companionWindows, ...options }) {
rangeId
:
null
,
rotation
:
null
,
selectedAnnotations
:
{},
sideBarOpen
:
config
.
window
.
sideBarOpenByDefault
,
sideBarOpen
:
config
.
window
.
defaultSideBarPanel
&&
config
.
window
.
sideBarOpenByDefault
,
sideBarPanel
:
config
.
window
.
defaultSideBarPanel
,
thumbnailNavigationId
:
cwThumbs
,
};
...
...
@@ -72,24 +95,7 @@ export function addWindow({ companionWindows, ...options }) {
};
dispatch
({
companionWindows
:
[
{
content
:
config
.
window
.
defaultSideBarPanel
,
default
:
true
,
id
:
cwDefault
,
position
:
'
left
'
,
},
{
content
:
'
thumbnailNavigation
'
,
default
:
true
,
id
:
cwThumbs
,
position
:
options
.
thumbnailNavigationPosition
||
config
.
thumbnailNavigation
.
defaultPosition
,
},
...(
(
companionWindows
||
[]).
map
((
cw
,
i
)
=>
({
...
cw
,
id
:
additionalCompanionWindowIds
[
i
]
}))
),
],
companionWindows
:
defaultCompanionWindows
,
elasticLayout
,
type
:
ActionTypes
.
ADD_WINDOW
,
window
:
{
...
defaultOptions
,
...
options
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment