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
20ee6b2e
Commit
20ee6b2e
authored
Feb 14, 2019
by
Mathias Maaß
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: clicking info panel before manifest loaded throws error. Closes #1880
parent
14b0e4dd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
__tests__/src/selectors/index.test.js
+8
-9
8 additions, 9 deletions
__tests__/src/selectors/index.test.js
src/containers/WindowSideBarInfoPanel.js
+2
-1
2 additions, 1 deletion
src/containers/WindowSideBarInfoPanel.js
src/state/selectors/index.js
+22
-9
22 additions, 9 deletions
src/state/selectors/index.js
with
32 additions
and
19 deletions
__tests__/src/selectors/index.test.js
+
8
−
9
View file @
20ee6b2e
...
...
@@ -205,10 +205,10 @@ describe('getSelectedCanvas', () => {
);
});
it
(
'
should return
an empty object
when there is no manifestation to get a canvas from
'
,
()
=>
{
it
(
'
should return
undefined
when there is no manifestation to get a canvas from
'
,
()
=>
{
const
selectedCanvas
=
getSelectedCanvas
(
noManifestationState
,
'
a
'
);
expect
(
selectedCanvas
).
to
Equal
({}
);
expect
(
selectedCanvas
).
to
BeUndefined
(
);
});
});
...
...
@@ -223,15 +223,14 @@ describe('getCanvasLabel', () => {
expect
(
received
).
toBe
(
'
Whole Page
'
);
});
it
(
'
should return the given canvas index (+1) if the canvas is undefined
'
,
()
=>
{
expect
(
getCanvasLabel
(
undefined
)).
toBe
(
1
);
expect
(
getCanvasLabel
(
undefined
,
2
)).
toBe
(
3
);
it
(
'
should return undefined if the canvas is undefined
'
,
()
=>
{
expect
(
getCanvasLabel
(
undefined
)).
toBeUndefined
();
});
it
(
'
should return the canvas index (+1)
if no manifestatio
n
'
,
()
=>
{
const
canvas
=
{
getLabel
:
()
=>
{}
};
const
received
=
getCanvasLabel
(
canvas
);
expect
(
received
).
toBe
(
1
);
it
(
'
should return the canvas index
as
(+1)
as string if no label give
n
'
,
()
=>
{
const
canvas
=
{
getLabel
:
()
=>
[]
};
const
received
=
getCanvasLabel
(
canvas
,
42
);
expect
(
received
).
toBe
(
'
43
'
);
});
});
...
...
This diff is collapsed.
Click to expand it.
src/containers/WindowSideBarInfoPanel.js
+
2
−
1
View file @
20ee6b2e
...
...
@@ -9,6 +9,7 @@ import {
getManifestTitle
,
getSelectedCanvas
,
getWindowManifest
,
getCanvasDescription
,
}
from
'
../state/selectors
'
;
import
WindowSideBarInfoPanel
from
'
../components/WindowSideBarInfoPanel
'
;
...
...
@@ -22,7 +23,7 @@ const mapStateToProps = (state, { windowId }) => ({
getSelectedCanvas
(
state
,
windowId
),
state
.
windows
[
windowId
].
canvasIndex
,
),
canvasDescription
:
getSelectedCanvas
(
state
,
windowId
)
.
getProperty
(
'
description
'
),
canvasDescription
:
getCanvasDescription
(
getSelectedCanvas
(
state
,
windowId
)),
canvasMetadata
:
getDestructuredMetadata
(
getSelectedCanvas
(
state
,
windowId
)),
manifestLabel
:
getManifestTitle
(
getWindowManifest
(
state
,
windowId
)),
manifestDescription
:
getManifestDescription
(
getWindowManifest
(
state
,
windowId
)),
...
...
This diff is collapsed.
Click to expand it.
src/state/selectors/index.js
+
22
−
9
View file @
20ee6b2e
...
...
@@ -44,11 +44,11 @@ export function getSelectedCanvas(state, windowId) {
const
manifest
=
getWindowManifest
(
state
,
windowId
);
const
{
canvasIndex
}
=
state
.
windows
[
windowId
];
if
(
!
manifest
.
manifestation
)
{
return
{};
}
return
manifest
.
manifestation
.
getSequences
()[
0
]
.
getCanvasByIndex
(
canvasIndex
);
return
manifest
&&
manifest
.
manifestation
&&
manifest
.
manifestation
.
getSequences
()[
0
]
.
getCanvasByIndex
(
canvasIndex
);
}
...
...
@@ -99,10 +99,13 @@ export function getManifestDescription(manifest) {
* @return {String|Integer}
*/
export
function
getCanvasLabel
(
canvas
,
canvasIndex
)
{
return
(
canvas
&&
canvas
.
getLabel
()
&&
canvas
.
getLabel
().
map
(
label
=>
label
.
value
)[
0
])
||
(
canvasIndex
||
0
)
+
1
;
if
(
!
canvas
)
{
return
undefined
;
}
if
(
canvas
.
getLabel
().
length
>
0
)
{
return
canvas
.
getLabel
().
map
(
label
=>
label
.
value
)[
0
];
}
return
String
(
canvasIndex
+
1
);
}
/**
...
...
@@ -122,3 +125,13 @@ export function getDestructuredMetadata(iiifResoruce) {
}))
);
}
/**
* Return canvas description
* @param {object} canvas
* @param {String}
*/
export
function
getCanvasDescription
(
canvas
)
{
return
canvas
&&
canvas
.
getProperty
(
'
description
'
);
}
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