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

Commit d95e128

Browse files
Kerry Changstarpit
authored andcommitted
fixes for app preview syntax error messages not going away
1 parent b41359e commit d95e128

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

app/plugins/modules/composer/lib/composer.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,9 @@ exports.handleError = (err, reject) => {
566566
*
567567
* @return { view, controller } where controller is the API exported by graph2doms
568568
*/
569-
exports.wskflow = (visualize, viewName, { fsm, input, name, packageName, reuseContainer}) => {
570-
// wskflow's visualize function now returns the view as DOM and the controllers for mode buttons
571-
// container is only used in the app preview filewatch mode, where sidecar graph is updated by updating an existing wskflow container
572-
// in other cases, container is undefined and wskflow generates a container itself
569+
exports.wskflow = (visualize, viewName, { fsm, input, name, packageName}) => {
573570

574-
const { view, controller } = visualize(fsm, reuseContainer);
571+
const { view, controller } = visualize(fsm);
575572

576573
const onclick = undefined
577574
ui.addNameToSidecarHeader(undefined, name, packageName, onclick, viewName,

app/plugins/modules/composer/lib/viz.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module.exports = (commandTree, prequire) => {
6666
const formatForUser = defaultMode => ({fsm,code}) => {
6767

6868
const {visualize} = prequire('wskflow')
69-
const { view, controller } = wskflow(visualize, viewName, { fsm, input, name, pk: undefined, reuseContainer: options.alreadyWatching})
69+
const { view, controller } = wskflow(visualize, viewName, { fsm, input, name })
7070
extraModes = extraModes.concat(zoomToFitButtons(controller))
7171

7272
const entity = {
@@ -99,7 +99,15 @@ module.exports = (commandTree, prequire) => {
9999
entity.type = 'actions'
100100
}
101101

102-
resolve(entity)
102+
if(options.alreadyWatching && entity.type === 'custom'){
103+
// in filewatch mode (alreadyWatching), command echo is set to false
104+
// calling ui.showCustom as the main repl does not do anything for custom type entity when echo is false
105+
ui.showCustom(entity);
106+
}
107+
else{
108+
resolve(entity);
109+
}
110+
103111
}
104112
fsmPromise.then(formatForUser(defaultMode))
105113
.catch(err => {
@@ -158,16 +166,16 @@ module.exports = (commandTree, prequire) => {
158166
debug('environment', environment)
159167
}
160168

161-
if(execOptions.alreadyWatching)
169+
if(execOptions.alreadyWatching){
162170
options.alreadyWatching = execOptions.alreadyWatching;
163-
164-
// render now
171+
}
172+
165173
render(input, options).then(resolve, reject)
166-
174+
167175
// and set up a file watcher to re-render upon change of the file
168176
if (!execOptions || !execOptions.alreadyWatching) {
169177
chokidar.watch(expandHomeDir(input)).on('change', path => {
170-
repl.pexec(`preview ${path}`, { echo: false, alreadyWatching: true })
178+
repl.pexec(`preview ${path}`, { echo: false, alreadyWatching: true })
171179
})
172180
}
173181
})

app/plugins/modules/wskflow/lib/graph2doms.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,9 @@ function graph2doms(JSONgraph, ifReuseContainer, activations){
8585
let zoom = d3.behavior.zoom()
8686
.on("zoom", redraw);
8787

88-
let containerElement,
88+
let containerElement = $(`<div id="${containerId}" style="display: flex; flex: 1; width: 100%; height: 100%;"></div>`),
8989
wskflowContainer = $('<div id="wskflowContainer"></div>'),
90-
enterClickMode = false;
91-
92-
if(ifReuseContainer && $(`#${containerId}`).length>0){
93-
containerElement = $(`#${containerId}`);
94-
$(containerElement).html('').css('display', 'flex').css('flex', 1);
95-
$("#wskflowSVG").remove();
96-
$("#qtip").remove();
97-
}
98-
else{
99-
containerElement = $(`<div id="${containerId}" style="display: flex; flex: 1; width: 100%; height: 100%;"></div>`);
100-
}
90+
enterClickMode = false;
10191

10292
$(containerElement).append(wskflowContainer);
10393

tests/tests/passes/07/wskflow-tests.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ describe('app preview should actively watching an external file', function() {
8787
.then(verifyNodeExists('b'))
8888
.catch(common.oops(this)))
8989

90+
91+
it('should update the temp file to composer.sequence("a", "c")asdfasdf', () => {
92+
return new Promise((resolve, reject) => {
93+
fs.writeFile(tempFileName, `composer.sequence("a", "c")asdfasdf`, (err) => {
94+
if(err)
95+
reject(err);
96+
else
97+
resolve(true);
98+
});
99+
});
100+
});
101+
102+
// error message is shown as action code
103+
it('should update preview with the error message', () => this.app.client.waitForVisible(`${ui.selectors.SIDECAR}.entity-is-actions`, 3000));
104+
90105
it('should update the temp file to composer.sequence("a", "c")', () => {
91106
return new Promise((resolve, reject) => {
92107
fs.writeFile(tempFileName, `composer.sequence("a", "c")`, (err) => {
@@ -98,7 +113,8 @@ describe('app preview should actively watching an external file', function() {
98113
});
99114
});
100115

101-
it('should update preview', () => verifyNodeExists('a')(this.app)
116+
it('should update preview', () => this.app.client.waitForVisible(ui.selectors.SIDECAR_CUSTOM_CONTENT)
117+
.then(() => verifyNodeExists('a')(this.app))
102118
.then(verifyNodeExists('c'))
103119
.catch(common.oops(this)))
104120

0 commit comments

Comments
 (0)