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
722dbef2
Unverified
Commit
722dbef2
authored
6 years ago
by
Chris Beer
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1820 from ProjectMirador/refactor-app-component
Refactor <App/> component.
parents
ae14d7ad
a541060b
No related branches found
No related tags found
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 @
722dbef2
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
shallow
}
from
'
enzyme
'
;
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
'
;
import
App
from
'
../../../src/components/App
'
;
describe
(
'
App
'
,
()
=>
{
/** */
it
(
'
renders without an error
'
,
()
=>
{
function
createWrapper
(
props
)
{
const
wrapper
=
shallow
(
return
shallow
(
<
App
<
App
manifests
=
{[]}
isFullscreenEnabled
=
{
false
}
workspace
=
{{}}
setWorkspaceFullscreen
=
{()
=>
{}}
config
=
{{
theme
:
'
light
'
}}
theme
=
"
light
"
classes
=
{{}}
{...
props
}
/>
,
/>
,
);
).
dive
();
// to unwrapp HOC created by withStyle()
expect
(
wrapper
.
dive
().
find
(
'
div.mirador-app
'
).
length
).
toBe
(
1
);
}
describe
(
'
App
'
,
()
=>
{
it
(
'
should render outer element correctly
'
,
()
=>
{
const
wrapper
=
createWrapper
();
expect
(
wrapper
.
find
(
'
div.mirador-app
'
).
length
).
toBe
(
1
);
});
});
describe
(
'
FullScreen
'
,
()
=>
{
it
(
'
should render all needed elements
'
,
()
=>
{
it
(
'
is enabled by the workspace.fullscreen state
'
,
()
=>
{
const
wrapper
=
createWrapper
();
const
wrapper
=
shallow
(
expect
(
wrapper
.
find
(
MuiThemeProvider
).
length
).
toBe
(
1
);
<
App
expect
(
wrapper
.
find
(
Fullscreen
).
length
).
toBe
(
1
);
manifests
=
{[]}
expect
(
wrapper
.
find
(
Workspace
).
length
).
toBe
(
1
);
workspace
=
{{
isFullscreenEnabled
:
true
}}
expect
(
wrapper
.
find
(
WorkspaceControlPanel
).
length
).
toBe
(
1
);
config
=
{{
theme
:
'
light
'
}}
/>
,
);
expect
(
wrapper
.
dive
().
find
(
'
FullScreen
'
).
first
().
prop
(
'
enabled
'
)).
toEqual
(
true
);
});
});
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 @
722dbef2
...
@@ -13,28 +13,34 @@ import ns from '../config/css-ns';
...
@@ -13,28 +13,34 @@ import ns from '../config/css-ns';
*/
*/
class
App
extends
Component
{
class
App
extends
Component
{
/**
/**
* render
* @return {String} - HTML markup for the component
*/
*/
render
()
{
makeMuiTheme
()
{
const
{
const
{
theme
}
=
this
.
props
;
workspace
,
setWorkspaceFullscreen
,
config
,
classes
,
return
createMuiTheme
({
}
=
this
.
props
;
const
theme
=
createMuiTheme
({
palette
:
{
palette
:
{
type
:
config
.
theme
,
type
:
theme
,
},
},
typography
:
{
typography
:
{
useNextVariants
:
true
,
useNextVariants
:
true
,
},
},
});
});
}
/**
* render
* @return {String} - HTML markup for the component
*/
render
()
{
const
{
isFullscreenEnabled
,
setWorkspaceFullscreen
,
classes
,
}
=
this
.
props
;
return
(
return
(
<
div
className
=
{
classNames
(
classes
.
background
,
ns
(
'
app
'
))}
>
<
div
className
=
{
classNames
(
classes
.
background
,
ns
(
'
app
'
))}
>
<
MuiThemeProvider
theme
=
{
theme
}
>
<
MuiThemeProvider
theme
=
{
th
is
.
makeMuiTh
eme
()
}
>
<
Fullscreen
<
Fullscreen
enabled
=
{
workspace
.
isFullscreenEnabled
}
enabled
=
{
isFullscreenEnabled
}
onChange
=
{
isFullscreenEnabled
=>
setWorkspaceFullscreen
(
isFullscreenEnabled
)
}
onChange
=
{
setWorkspaceFullscreen
}
>
>
<
Workspace
/>
<
Workspace
/>
<
/Fullscreen
>
<
/Fullscreen
>
...
@@ -46,15 +52,10 @@ class App extends Component {
...
@@ -46,15 +52,10 @@ class App extends Component {
}
}
App
.
propTypes
=
{
App
.
propTypes
=
{
config
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
theme
:
PropTypes
.
string
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
workspace
:
PropTypes
.
object
,
// 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,
classes
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types,
setWorkspaceFullscreen
:
PropTypes
.
func
,
setWorkspaceFullscreen
:
PropTypes
.
func
.
isRequired
,
};
App
.
defaultProps
=
{
workspace
:
{},
setWorkspaceFullscreen
:
()
=>
{},
};
};
/**
/**
...
...
This diff is collapsed.
Click to expand it.
src/containers/App.js
+
2
−
4
View file @
722dbef2
...
@@ -10,9 +10,8 @@ import App from '../components/App';
...
@@ -10,9 +10,8 @@ import App from '../components/App';
*/
*/
const
mapStateToProps
=
state
=>
(
const
mapStateToProps
=
state
=>
(
{
{
config
:
state
.
config
,
theme
:
state
.
config
.
theme
,
workspace
:
state
.
workspace
,
isFullscreenEnabled
:
state
.
workspace
.
isFullscreenEnabled
,
manifests
:
state
.
manifests
,
}
}
);
);
...
@@ -22,7 +21,6 @@ const mapStateToProps = state => (
...
@@ -22,7 +21,6 @@ const mapStateToProps = state => (
* @private
* @private
*/
*/
const
mapDispatchToProps
=
{
const
mapDispatchToProps
=
{
fetchManifest
:
actions
.
fetchManifest
,
setWorkspaceFullscreen
:
actions
.
setWorkspaceFullscreen
,
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