Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit aa3e932

Browse files
committed
improve ability for wskflow to be incorporated into other views
Fixes #920
1 parent 4243608 commit aa3e932

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

lib/composer.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,17 +562,21 @@ exports.handleError = (err, reject) => {
562562
}
563563

564564
/**
565-
* Render the wskflow visualization for the given fsm
565+
* Render the wskflow visualization for the given fsm.
566+
*
567+
* `container` is optional; wskflow will render in the default way in
568+
* the sidecar if we don't pass a container in
566569
*
567570
* @return { view, controller } where controller is the API exported by graph2doms
568571
*/
569-
exports.wskflow = (visualize, viewName, { fsm, input, name, packageName, viewOptions }) => {
570-
571-
const { view, controller } = visualize(fsm, undefined, undefined, undefined, undefined, viewOptions);
572+
exports.wskflow = (visualize, viewName, { fsm, input, name, packageName, viewOptions, container }) => {
573+
const { view, controller } = visualize(fsm, container, undefined, undefined, undefined, viewOptions);
572574

573-
const onclick = undefined
574-
ui.addNameToSidecarHeader(undefined, name, packageName, onclick, viewName,
575-
'This is a preview of your app, it is not yet deployed')
575+
if (!viewOptions || !viewOptions.noHeader) {
576+
const onclick = undefined
577+
ui.addNameToSidecarHeader(undefined, name, packageName, onclick, viewName,
578+
'This is a preview of your app, it is not yet deployed')
579+
}
576580

577581
return { view, controller }
578582
}

lib/viz.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const viewName = 'preview', // for back button and sidecar header
3838
*
3939
*/
4040
module.exports = (commandTree, prequire) => {
41-
const render = (input, options) => new Promise((resolve, reject) => {
41+
const render = (input, options, execOptions) => new Promise((resolve, reject) => {
4242
debug('options', options)
4343
let fsmPromise, type, extraModes=[]
4444

@@ -64,16 +64,21 @@ module.exports = (commandTree, prequire) => {
6464

6565
// create a fake action/entity record
6666
const formatForUser = defaultMode => ({fsm,code}) => {
67-
6867
// pass through cli options for the wskflow renderer
6968
const viewOptions = { }
69+
7070
if (options.functions) {
7171
// note we must be careful not to pass false; only undefined
7272
viewOptions.renderFunctionsInView = options.functions // render all inline functions directly in the view?
7373
}
7474

75+
if (execOptions.container) {
76+
// if we're rendering this inside of a given viewport, then don't modify the sidecar header
77+
viewOptions.noHeader = true
78+
}
79+
7580
const {visualize} = prequire('wskflow')
76-
const { view, controller } = wskflow(visualize, viewName, { fsm, input, name, viewOptions })
81+
const { view, controller } = wskflow(visualize, viewName, { fsm, input, name, viewOptions, container: execOptions.container })
7782
extraModes = extraModes.concat(zoomToFitButtons(controller))
7883

7984
const entity = {
@@ -177,7 +182,7 @@ module.exports = (commandTree, prequire) => {
177182
options.alreadyWatching = execOptions.alreadyWatching;
178183
}
179184

180-
render(input, options).then(resolve, reject)
185+
render(input, options, execOptions).then(resolve, reject)
181186

182187
// and set up a file watcher to re-render upon change of the file
183188
if (!execOptions || !execOptions.alreadyWatching) {

0 commit comments

Comments
 (0)