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
45550473
Commit
45550473
authored
6 years ago
by
Mathias Maaß
Committed by
Mathias Maaß
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Refactor <Workspace/> component.
parent
6b1d1af0
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/Workspace.test.js
+21
-24
21 additions, 24 deletions
__tests__/src/components/Workspace.test.js
src/components/Workspace.js
+3
-11
3 additions, 11 deletions
src/components/Workspace.js
src/containers/Workspace.js
+1
-1
1 addition, 1 deletion
src/containers/Workspace.js
with
25 additions
and
36 deletions
__tests__/src/components/Workspace.test.js
+
21
−
24
View file @
45550473
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
shallow
}
from
'
enzyme
'
;
import
{
shallow
}
from
'
enzyme
'
;
import
Workspace
from
'
../../../src/co
mponent
s/Workspace
'
;
import
Workspace
Mosaic
from
'
../../../src/co
ntainer
s/Workspace
Mosaic
'
;
import
Window
from
'
../../../src/containers/Window
'
;
import
Window
from
'
../../../src/containers/Window
'
;
import
Workspace
from
'
../../../src/components/Workspace
'
;
describe
(
'
Workspace
'
,
()
=>
{
const
windows
=
{
1
:
{
id
:
1
},
2
:
{
id
:
2
}
};
const
windows
=
{
1
:
{
id
:
1
},
2
:
{
id
:
2
}
};
let
wrapper
;
beforeEach
(()
=>
{
describe
(
'
Workspace
'
,
()
=>
{
wrapper
=
shallow
(
describe
(
'
if workspace type is mosaic
'
,
()
=>
{
<
Workspace
it
(
'
should render <WorkspaceMosaic/> properly
'
,
()
=>
{
windows
=
{
windows
}
const
wrapper
=
shallow
(
config
=
{{
workspace
:
{
type
:
'
mosaic
'
}
}}
<
Workspace
windows
=
{
windows
}
workspaceType
=
"
mosaic
"
/>
,
/>
,
);
);
expect
(
wrapper
.
matchesElement
(
<
div
className
=
"
mirador-workspace
"
>
<
WorkspaceMosaic
windows
=
{
windows
}
/
>
<
/div>
,
)).
toBe
(
true
);
});
});
it
(
'
should render properly
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.mirador-workspace
'
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
'
Connect(WorkspaceMosaic)
'
).
length
).
toBe
(
1
);
});
describe
(
'
workspaceByType
'
,
()
=>
{
it
(
'
when mosaic
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
Connect(WorkspaceMosaic)
'
).
length
).
toBe
(
1
);
});
});
it
(
'
anything else
'
,
()
=>
{
describe
(
'
if workspace type is unknown
'
,
()
=>
{
wrapper
=
shallow
(
it
(
'
should render <Window/> components as list
'
,
()
=>
{
<
Workspace
const
wrapper
=
shallow
(
windows
=
{
windows
}
<
Workspace
windows
=
{
windows
}
workspaceType
=
"
bubu
"
/>
,
config
=
{{
workspace
:
{
type
:
'
foo
'
}
}}
/>
,
);
);
expect
(
wrapper
.
matchesElement
(
expect
(
wrapper
.
matchesElement
(
<
div
className
=
"
mirador-workspace
"
>
<
div
className
=
"
mirador-workspace
"
>
<
Window
window
=
{{
id
:
1
}}
/
>
<
Window
window
=
{{
id
:
1
}}
/
>
...
...
This diff is collapsed.
Click to expand it.
src/components/Workspace.js
+
3
−
11
View file @
45550473
...
@@ -10,20 +10,12 @@ import ns from '../config/css-ns';
...
@@ -10,20 +10,12 @@ import ns from '../config/css-ns';
* @private
* @private
*/
*/
class
Workspace
extends
React
.
Component
{
class
Workspace
extends
React
.
Component
{
/**
*/
constructor
(
props
)
{
super
(
props
);
this
.
workspaceByType
=
this
.
workspaceByType
.
bind
(
this
);
}
/**
/**
* Determine which workspace to render by configured type
* Determine which workspace to render by configured type
*/
*/
workspaceByType
()
{
workspaceByType
()
{
const
{
config
,
windows
}
=
this
.
props
;
const
{
workspaceType
,
windows
}
=
this
.
props
;
switch
(
config
.
workspace
.
t
ype
)
{
switch
(
workspace
T
ype
)
{
case
'
mosaic
'
:
case
'
mosaic
'
:
return
<
WorkspaceMosaic
windows
=
{
windows
}
/>
;
return
<
WorkspaceMosaic
windows
=
{
windows
}
/>
;
default
:
default
:
...
@@ -50,7 +42,7 @@ class Workspace extends React.Component {
...
@@ -50,7 +42,7 @@ class Workspace extends React.Component {
Workspace
.
propTypes
=
{
Workspace
.
propTypes
=
{
windows
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
windows
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
config
:
PropTypes
.
object
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
workspaceType
:
PropTypes
.
string
.
isRequired
,
// eslint-disable-line react/forbid-prop-types
};
};
export
default
Workspace
;
export
default
Workspace
;
This diff is collapsed.
Click to expand it.
src/containers/Workspace.js
+
1
−
1
View file @
45550473
...
@@ -9,7 +9,7 @@ import Workspace from '../components/Workspace';
...
@@ -9,7 +9,7 @@ import Workspace from '../components/Workspace';
*/
*/
const
mapStateToProps
=
state
=>
(
const
mapStateToProps
=
state
=>
(
{
{
config
:
state
.
config
,
workspaceType
:
state
.
config
.
workspace
.
type
,
windows
:
state
.
windows
,
windows
:
state
.
windows
,
}
}
);
);
...
...
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