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
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
a541060b
Commit
a541060b
authored
6 years ago
by
Mathias Maaß
Browse files
Options
Downloads
Patches
Plain Diff
Refactor <App/> component.
parent
4b4f4032
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/App.test.js
+43
-20
43 additions, 20 deletions
__tests__/src/components/App.test.js
src/components/App.js
+21
-20
21 additions, 20 deletions
src/components/App.js
src/containers/App.js
+2
-4
2 additions, 4 deletions
src/containers/App.js
with
66 additions
and
44 deletions
__tests__/src/components/App.test.js
+
43
−
20
View file @
a541060b
import
React
from
'
react
'
;
import
{
shallow
}
from
'
enzyme
'
;
import
{
MuiThemeProvider
}
from
'
@material-ui/core/styles
'
;
import
Fullscreen
from
'
react-fullscreen-crossbrowser
'
;
import
WorkspaceControlPanel
from
'
../../../src/components/WorkspaceControlPanel
'
;
import
Workspace
from
'
../../../src/containers/Workspace
'
;
import
App
from
'
../../../src/components/App
'
;
describe
(
'
App
'
,
()
=>
{
it
(
'
renders without an error
'
,
()
=>
{
const
wrapper
=
shallow
(
/** */
function
createWrapper
(
props
)
{
return
shallow
(
<
App
manifests
=
{[]}
workspace
=
{{}}
config
=
{{
theme
:
'
light
'
}}
isFullscreenEnabled
=
{
false
}
setWorkspaceFullscreen
=
{()
=>
{}}
theme
=
"
light
"
classes
=
{{}}
{...
props
}
/>
,
);
expect
(
wrapper
.
dive
().
find
(
'
div.mirador-app
'
).
length
).
toBe
(
1
);
).
dive
();
// to unwrapp HOC created by withStyle()
}
describe
(
'
App
'
,
()
=>
{
it
(
'
should render outer element correctly
'
,
()
=>
{
const
wrapper
=
createWrapper
();
expect
(
wrapper
.
find
(
'
div.mirador-app
'
).
length
).
toBe
(
1
);
});
describe
(
'
FullScreen
'
,
()
=>
{
it
(
'
is enabled by the workspace.fullscreen state
'
,
()
=>
{
const
wrapper
=
shallow
(
<
App
manifests
=
{[]}
workspace
=
{{
isFullscreenEnabled
:
true
}}
config
=
{{
theme
:
'
light
'
}}
/>
,
);
expect
(
wrapper
.
dive
().
find
(
'
FullScreen
'
).
first
().
prop
(
'
enabled
'
)).
toEqual
(
true
);
it
(
'
should render all needed elements
'
,
()
=>
{
const
wrapper
=
createWrapper
();
expect
(
wrapper
.
find
(
MuiThemeProvider
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
Fullscreen
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
Workspace
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
WorkspaceControlPanel
).
length
).
toBe
(
1
);
});
it
(
'
should pass setWorkspaceFullscreen to Fullscreen.onChange
'
,
()
=>
{
const
mockFn
=
jest
.
fn
();
const
wrapper
=
createWrapper
({
setWorkspaceFullscreen
:
mockFn
});
expect
(
wrapper
.
find
(
Fullscreen
).
first
().
prop
(
'
onChange
'
))
.
toBe
(
mockFn
);
});
it
(
'
should pass isFullscreenEnabled to Fullscreen.enabled
'
,
()
=>
{
let
wrapper
=
createWrapper
({
isFullscreenEnabled
:
false
});
expect
(
wrapper
.
find
(
Fullscreen
).
first
().
prop
(
'
enabled
'
))
.
toEqual
(
false
);
wrapper
=
createWrapper
({
isFullscreenEnabled
:
true
});
expect
(
wrapper
.
find
(
Fullscreen
).
first
().
prop
(
'
enabled
'
))
.
toEqual
(
true
);
});
});
This diff is collapsed.
Click to expand it.
src/components/App.js
+
21
−
20
View file @
a541060b
...
...
@@ -13,28 +13,34 @@ import ns from '../config/css-ns';
*/
class
App
extends
Component
{
/**
* render
* @return {String} - HTML markup for the component
*/
render
()
{
const
{
workspace
,
setWorkspaceFullscreen
,
config
,
classes
,
}
=
this
.
props
;
const
theme
=
createMuiTheme
({
makeMuiTheme
()
{
const
{
theme
}
=
this
.
props
;
return
createMuiTheme
({
palette
:
{
type
:
config
.
theme
,
type
:
theme
,
},
typography
:
{
useNextVariants
:
true
,
},
});
}
/**
* render
* @return {String} - HTML markup for the component
*/
render
()
{
const
{
isFullscreenEnabled
,
setWorkspaceFullscreen
,
classes
,
}
=
this
.
props
;
return
(
<
div
className
=
{
classNames
(
classes
.
background
,
ns
(
'
app
'
))}
>
<
MuiThemeProvider
theme
=
{
theme
}
>
<
MuiThemeProvider
theme
=
{
th
is
.
makeMuiTh
eme
()
}
>
<
Fullscreen
enabled
=
{
workspace
.
isFullscreenEnabled
}
onChange
=
{
isFullscreenEnabled
=>
setWorkspaceFullscreen
(
isFullscreenEnabled
)
}
enabled
=
{
isFullscreenEnabled
}
onChange
=
{
setWorkspaceFullscreen
}
>
<
Workspace
/>
<
/Fullscreen
>
...
...
@@ -46,15 +52,10 @@ class App extends Component {
}
App
.
propTypes
=
{
config
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
workspace
:
PropTypes
.
object
,
// eslint-disable-line react/forbid-prop-types
theme
:
PropTypes
.
string
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
isFullscreenEnabled
:
PropTypes
.
bool
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
classes
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types,
setWorkspaceFullscreen
:
PropTypes
.
func
,
};
App
.
defaultProps
=
{
workspace
:
{},
setWorkspaceFullscreen
:
()
=>
{},
setWorkspaceFullscreen
:
PropTypes
.
func
.
isRequired
,
};
/**
...
...
This diff is collapsed.
Click to expand it.
src/containers/App.js
+
2
−
4
View file @
a541060b
...
...
@@ -10,9 +10,8 @@ import App from '../components/App';
*/
const
mapStateToProps
=
state
=>
(
{
config
:
state
.
config
,
workspace
:
state
.
workspace
,
manifests
:
state
.
manifests
,
theme
:
state
.
config
.
theme
,
isFullscreenEnabled
:
state
.
workspace
.
isFullscreenEnabled
,
}
);
...
...
@@ -22,7 +21,6 @@ const mapStateToProps = state => (
* @private
*/
const
mapDispatchToProps
=
{
fetchManifest
:
actions
.
fetchManifest
,
setWorkspaceFullscreen
:
actions
.
setWorkspaceFullscreen
,
};
...
...
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