Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
7542f1b5
Commit
7542f1b5
authored
8 years ago
by
Ray Schamp
Browse files
Options
Downloads
Patches
Plain Diff
Give GUIComponent responsibility of children
This will allow the GUIComponent to have control over the layout
parent
16fbb64c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/gui/gui.jsx
+81
-6
81 additions, 6 deletions
src/components/gui/gui.jsx
src/containers/gui.jsx
+8
-70
8 additions, 70 deletions
src/containers/gui.jsx
with
89 additions
and
76 deletions
src/components/gui/gui.jsx
+
81
−
6
View file @
7542f1b5
const
defaultsDeep
=
require
(
'
lodash.defaultsdeep
'
);
const
React
=
require
(
'
react
'
);
const
VM
=
require
(
'
scratch-vm
'
);
const
MediaLibrary
=
require
(
'
../../lib/media-library
'
);
const
shapeFromPropTypes
=
require
(
'
../../lib/shape-from-prop-types
'
);
const
Blocks
=
require
(
'
../../containers/blocks.jsx
'
);
const
GreenFlag
=
require
(
'
../../containers/green-flag.jsx
'
);
const
TargetPane
=
require
(
'
../../containers/target-pane.jsx
'
);
const
Stage
=
require
(
'
../../containers/stage.jsx
'
);
const
StopAll
=
require
(
'
../../containers/stop-all.jsx
'
);
const
styles
=
require
(
'
./gui.css
'
);
const
GUIComponent
=
props
=>
(
<
div
className
=
{
styles
.
gui
}
>
{
props
.
children
}
</
div
>
);
const
GUIComponent
=
props
=>
{
let
{
basePath
,
blocksProps
,
children
,
greenFlagProps
,
mediaLibrary
,
targetPaneProps
,
stageProps
,
stopAllProps
,
vm
}
=
props
;
blocksProps
=
defaultsDeep
({},
blocksProps
,
{
options
:
{
media
:
`
${
basePath
}
static/blocks-media/`
}
});
if
(
children
)
{
return
(
<
div
className
=
{
styles
.
gui
}
>
{
children
}
</
div
>
);
}
return
(
<
div
className
=
{
styles
.
gui
}
>
<
GreenFlag
vm
=
{
vm
}
{
...
greenFlagProps
}
/>
<
StopAll
vm
=
{
vm
}
{
...
stopAllProps
}
/>
<
Stage
vm
=
{
vm
}
{
...
stageProps
}
/>
<
TargetPane
mediaLibrary
=
{
mediaLibrary
}
vm
=
{
vm
}
{
...
targetPaneProps
}
/>
<
Blocks
vm
=
{
vm
}
{
...
blocksProps
}
/>
</
div
>
);
};
GUIComponent
.
propTypes
=
{
children
:
React
.
PropTypes
.
node
basePath
:
React
.
PropTypes
.
string
,
blocksProps
:
shapeFromPropTypes
(
Blocks
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
children
:
React
.
PropTypes
.
node
,
greenFlagProps
:
shapeFromPropTypes
(
GreenFlag
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
mediaLibrary
:
React
.
PropTypes
.
instanceOf
(
MediaLibrary
),
stageProps
:
shapeFromPropTypes
(
Stage
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
stopAllProps
:
shapeFromPropTypes
(
StopAll
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
targetPaneProps
:
shapeFromPropTypes
(
TargetPane
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
vm
:
React
.
PropTypes
.
instanceOf
(
VM
)
};
GUIComponent
.
defaultProps
=
{
basePath
:
'
/
'
,
blocksProps
:
{},
greenFlagProps
:
{},
mediaLibrary
:
new
MediaLibrary
(),
targetPaneProps
:
{},
stageProps
:
{},
stopAllProps
:
{},
vm
:
new
VM
()
};
module
.
exports
=
GUIComponent
;
This diff is collapsed.
Click to expand it.
src/containers/gui.jsx
+
8
−
70
View file @
7542f1b5
const
defaultsDeep
=
require
(
'
lodash.defaultsdeep
'
);
const
React
=
require
(
'
react
'
);
const
VM
=
require
(
'
scratch-vm
'
);
const
MediaLibrary
=
require
(
'
../lib/media-library
'
);
const
shapeFromPropTypes
=
require
(
'
../lib/shape-from-prop-types
'
);
const
vmListenerHOC
=
require
(
'
../lib/vm-listener-hoc.jsx
'
);
const
Blocks
=
require
(
'
./blocks.jsx
'
);
const
GUIComponent
=
require
(
'
../components/gui/gui.jsx
'
);
const
GreenFlag
=
require
(
'
./green-flag.jsx
'
);
const
TargetPane
=
require
(
'
./target-pane.jsx
'
);
const
Stage
=
require
(
'
./stage.jsx
'
);
const
StopAll
=
require
(
'
./stop-all.jsx
'
);
class
GUI
extends
React
.
Component
{
componentDidMount
()
{
...
...
@@ -27,80 +19,26 @@ class GUI extends React.Component {
this
.
props
.
vm
.
stopAll
();
}
render
()
{
let
{
basePath
,
blocksProps
,
greenFlagProps
,
mediaLibrary
,
const
{
projectData
,
// eslint-disable-line no-unused-vars
targetPaneProps
,
stageProps
,
stopAllProps
,
vm
,
...
gui
Props
...
component
Props
}
=
this
.
props
;
blocksProps
=
defaultsDeep
({},
blocksProps
,
{
options
:
{
media
:
`
${
basePath
}
static/blocks-media/`
}
});
if
(
this
.
props
.
children
)
{
return
(
<
GUIComponent
{
...
guiProps
}
>
{
this
.
props
.
children
}
</
GUIComponent
>
);
}
return
(
<
GUIComponent
{
...
guiProps
}
>
<
GreenFlag
vm
=
{
vm
}
{
...
greenFlagProps
}
/>
<
StopAll
vm
=
{
vm
}
{
...
stopAllProps
}
/>
<
Stage
vm
=
{
vm
}
{
...
stageProps
}
/>
<
TargetPane
mediaLibrary
=
{
mediaLibrary
}
vm
=
{
vm
}
{
...
targetPaneProps
}
/>
<
Blocks
vm
=
{
vm
}
{
...
blocksProps
}
/>
</
GUIComponent
>
<
GUIComponent
vm
=
{
vm
}
{
...
componentProps
}
/>
);
}
}
GUI
.
propTypes
=
{
basePath
:
React
.
PropTypes
.
string
,
blocksProps
:
shapeFromPropTypes
(
Blocks
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
children
:
React
.
PropTypes
.
node
,
greenFlagProps
:
shapeFromPropTypes
(
GreenFlag
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
mediaLibrary
:
React
.
PropTypes
.
instanceOf
(
MediaLibrary
),
...
GUIComponent
.
propTypes
,
projectData
:
React
.
PropTypes
.
string
,
stageProps
:
shapeFromPropTypes
(
Stage
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
stopAllProps
:
shapeFromPropTypes
(
StopAll
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
targetPaneProps
:
shapeFromPropTypes
(
TargetPane
.
propTypes
,
{
omit
:
[
'
vm
'
]}),
vm
:
React
.
PropTypes
.
instanceOf
(
VM
)
};
GUI
.
defaultProps
=
{
basePath
:
'
/
'
,
blocksProps
:
{},
greenFlagProps
:
{},
mediaLibrary
:
new
MediaLibrary
(),
targetPaneProps
:
{},
stageProps
:
{},
stopAllProps
:
{},
vm
:
new
VM
()
};
GUI
.
defaultProps
=
GUIComponent
.
defaultProps
;
module
.
exports
=
vmListenerHOC
(
GUI
);
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