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
0800f8d1
Commit
0800f8d1
authored
Jan 29, 2019
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Get the manifest title for each window to display in the window list
parent
850b48d6
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/components/WindowList.test.js
+84
-0
84 additions, 0 deletions
__tests__/src/components/WindowList.test.js
src/components/WindowList.js
+23
-2
23 additions, 2 deletions
src/components/WindowList.js
src/components/WorkspaceMenu.js
+5
-1
5 additions, 1 deletion
src/components/WorkspaceMenu.js
with
112 additions
and
3 deletions
__tests__/src/components/WindowList.test.js
0 → 100644
+
84
−
0
View file @
0800f8d1
import
React
from
'
react
'
;
import
{
shallow
}
from
'
enzyme
'
;
import
MenuItem
from
'
@material-ui/core/MenuItem
'
;
import
{
WindowList
}
from
'
../../../src/components/WindowList
'
;
describe
(
'
WindowList
'
,
()
=>
{
let
wrapper
;
let
handleClose
;
let
focusWindow
;
let
manifests
;
let
windows
;
beforeEach
(()
=>
{
handleClose
=
jest
.
fn
();
focusWindow
=
jest
.
fn
();
manifests
=
{};
windows
=
{};
wrapper
=
shallow
(
<
WindowList
anchorEl
=
{{}}
manifests
=
{
manifests
}
windows
=
{
windows
}
handleClose
=
{
handleClose
}
focusWindow
=
{
focusWindow
}
/>
,
);
});
it
(
'
renders without an error
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
WithStyles(Menu)
'
).
length
).
toBe
(
1
);
});
describe
(
'
with a window without a matching manifest
'
,
()
=>
{
beforeEach
(()
=>
{
windows
=
{
xyz
:
{
id
:
'
xyz
'
,
manifestId
:
'
abc
'
}
};
wrapper
=
shallow
(
<
WindowList
anchorEl
=
{{}}
manifests
=
{
manifests
}
windows
=
{
windows
}
handleClose
=
{
handleClose
}
focusWindow
=
{
focusWindow
}
/>
,
);
});
it
(
'
renders without an error
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
WithStyles(MenuItem)
'
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
'
WithStyles(MenuItem)
'
).
key
()).
toBe
(
'
xyz
'
);
expect
(
wrapper
.
find
(
'
WithStyles(MenuItem)
'
).
matchesElement
(
<
MenuItem
>
[
Untitled
]
<
/MenuItem>
)
,
).
toBe
(
true
);
wrapper
.
find
(
'
WithStyles(MenuItem)
'
).
simulate
(
'
click
'
,
{});
expect
(
handleClose
).
toBeCalled
();
expect
(
focusWindow
).
toBeCalledWith
(
'
xyz
'
);
});
});
describe
(
'
with a window with a matching manifest
'
,
()
=>
{
beforeEach
(()
=>
{
windows
=
{
xyz
:
{
id
:
'
xyz
'
,
manifestId
:
'
abc
'
}
};
manifests
=
{
abc
:
{
manifestation
:
{
getLabel
:
jest
.
fn
(()
=>
[{
value
:
'
Some title
'
}])
}
}
};
wrapper
=
shallow
(
<
WindowList
anchorEl
=
{{}}
manifests
=
{
manifests
}
windows
=
{
windows
}
handleClose
=
{
handleClose
}
focusWindow
=
{
focusWindow
}
/>
,
);
});
it
(
'
renders without an error
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
WithStyles(MenuItem)
'
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
'
WithStyles(MenuItem)
'
).
key
()).
toBe
(
'
xyz
'
);
expect
(
wrapper
.
find
(
'
WithStyles(MenuItem)
'
).
matchesElement
(
<
MenuItem
>
Some
title
<
/MenuItem>
)
,
).
toBe
(
true
);
});
});
});
This diff is collapsed.
Click to expand it.
src/components/WindowList.js
+
23
−
2
View file @
0800f8d1
...
...
@@ -12,6 +12,21 @@ import { actions } from '../store';
/**
*/
export
class
WindowList
extends
Component
{
/**
* Get the title for a window from its manifest title
* @private
*/
titleContent
(
window
)
{
const
{
manifests
}
=
this
.
props
;
if
(
window
.
manifestId
&&
manifests
[
window
.
manifestId
]
&&
manifests
[
window
.
manifestId
].
manifestation
)
{
return
manifests
[
window
.
manifestId
].
manifestation
.
getLabel
().
map
(
label
=>
label
.
value
)[
0
];
}
return
'
[Untitled]
'
;
}
/**
* render
* @return
...
...
@@ -33,7 +48,7 @@ export class WindowList extends Component {
onClick
=
{(
e
)
=>
{
focusWindow
(
window
.
id
);
handleClose
(
e
);
}}
>
{
window
.
id
this
.
titleContent
(
window
)
}
<
/MenuItem
>
))
...
...
@@ -46,8 +61,13 @@ export class WindowList extends Component {
WindowList
.
propTypes
=
{
focusWindow
:
PropTypes
.
func
.
isRequired
,
handleClose
:
PropTypes
.
func
.
isRequired
,
anchorEl
:
PropTypes
.
string
.
isRequired
,
anchorEl
:
PropTypes
.
object
,
// eslint-disable-line react/forbid-prop-types
windows
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
manifests
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
};
WindowList
.
defaultProps
=
{
anchorEl
:
null
,
};
/**
...
...
@@ -67,6 +87,7 @@ const mapDispatchToProps = {
const
mapStateToProps
=
state
=>
(
{
windows
:
state
.
windows
,
manifests
:
state
.
manifests
,
}
);
...
...
This diff is collapsed.
Click to expand it.
src/components/WorkspaceMenu.js
+
5
−
1
View file @
0800f8d1
...
...
@@ -77,7 +77,11 @@ export class WorkspaceMenu extends Component {
WorkspaceMenu
.
propTypes
=
{
handleClose
:
PropTypes
.
func
.
isRequired
,
anchorEl
:
PropTypes
.
string
.
isRequired
,
anchorEl
:
PropTypes
.
object
,
// eslint-disable-line react/forbid-prop-types
};
WorkspaceMenu
.
defaultProps
=
{
anchorEl
:
null
,
};
/**
...
...
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