Skip to content

Commit 3d64683

Browse files
committed
Allow a project's flow file to be changed
1 parent 5218a3f commit 3d64683

13 files changed

Lines changed: 704 additions & 194 deletions

File tree

editor/js/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@
6969
return;
7070
}
7171
if (msg.text) {
72+
console.log(msg);
7273
var text = RED._(msg.text,{default:msg.text});
7374
if (notificationId === "runtime-state") {
7475
if (msg.error === "credentials_load_failed") {
76+
// TODO: NLS
7577
text += '<p><a href="#" onclick="RED.projects.showCredentialsPrompt(); return false;">'+'Setup credentials'+'</a></p>';
78+
} else if (msg.error === "missing_flow_file") {
79+
// TODO: NLS
80+
text += '<p><a href="#" onclick="RED.projects.showFilesPrompt(); return false;">'+'Setup project files'+'</a></p>';
7681
}
7782
}
7883
if (!persistentNotifications.hasOwnProperty(notificationId)) {

editor/js/ui/common/popover.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ RED.popover = (function() {
3333
var trigger = options.trigger;
3434
var content = options.content;
3535
var delay = options.delay;
36+
var autoClose = options.autoClose;
3637
var width = options.width||"auto";
3738
var size = options.size||"default";
3839
if (!deltaSizes[size]) {
@@ -92,7 +93,6 @@ RED.popover = (function() {
9293
}
9394

9495
if (trigger === 'hover') {
95-
9696
target.on('mouseenter',function(e) {
9797
clearTimeout(timer);
9898
active = true;
@@ -116,6 +116,11 @@ RED.popover = (function() {
116116
openPopup();
117117
}
118118
});
119+
} else if (autoClose) {
120+
setTimeout(function() {
121+
active = false;
122+
closePopup();
123+
},autoClose);
119124
}
120125
var res = {
121126
setContent: function(_content) {

editor/js/ui/projectSettings.js

Lines changed: 457 additions & 151 deletions
Large diffs are not rendered by default.

editor/js/ui/projects.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,9 @@ function refresh() {
933933
showCredentialsPrompt: function() { //TODO: rename this function
934934
RED.projects.settings.show('settings');
935935
},
936+
showFilesPrompt: function() { //TODO: rename this function
937+
RED.projects.settings.show('settings');
938+
},
936939
// showSidebar: showSidebar,
937940
refresh: refresh,
938941
editProject: function() {

editor/sass/projects.scss

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,76 @@
371371
transition: all 0.2s ease-in-out;
372372
}
373373
}
374+
.project-file-listing-container > .red-ui-editableList > .red-ui-editableList-border {
375+
border-radius: 0;
376+
border: none;
377+
border-top: 1px solid $secondary-border-color;
378+
379+
}
380+
.red-ui-editableList-container .projects-dialog-file-list {
381+
.red-ui-editableList-border {
382+
border: none;
383+
}
384+
li {
385+
padding: 0 !important;
386+
border: none;
387+
}
388+
.red-ui-editableList-container {
389+
padding: 0;
390+
}
391+
}
392+
.projects-dialog-file-list-entry {
393+
padding: 3px 0;
394+
border-left: 2px solid #fff;
395+
border-right: 2px solid #fff;
396+
&.projects-list-entry-current {
397+
&:not(.selectable) {
398+
background: #f9f9f9;
399+
}
400+
i {
401+
color: #999;
402+
}
403+
}
404+
&.selectable {
405+
cursor: pointer;
406+
&:hover {
407+
background: #f3f3f3;
408+
border-left-color:#999;
409+
border-right-color:#999;
410+
}
411+
}
412+
413+
i {
414+
color: #999;
415+
width: 16px;
416+
text-align: center;
417+
}
418+
&.selected {
419+
background: #efefef;
420+
border-left-color:#999;
421+
border-right-color:#999;
422+
}
423+
span {
424+
display: inline-block;
425+
vertical-align:middle;
426+
}
427+
.projects-dialog-file-list-entry-folder {
428+
margin: 0 10px 0 0px;
429+
430+
.fa-angle-right {
431+
color: #333;
432+
transition: all 0.2s ease-in-out;
433+
434+
}
435+
}
436+
.projects-dialog-file-list-entry-file {
437+
margin: 0 10px 0 20px;
438+
}
439+
.projects-dialog-file-list-entry-name {
440+
font-size: 1em;
441+
}
442+
&.expanded .fa-angle-right {
443+
transform: rotate(90deg);
444+
}
445+
}
446+
.projects-dialog-file-list-entry-file-type-git { color: #999 }

editor/sass/userSettings.scss

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
padding-bottom: 0;
4444
}
4545
}
46-
input {
47-
margin-bottom: 0;
46+
input, div.uneditable-input {
47+
//margin-bottom: 0;
48+
}
49+
div.uneditable-input {
50+
position: relative;
4851
}
4952
input[type='number'] {
5053
width: 60px;
@@ -57,3 +60,14 @@
5760
.user-settings-row {
5861
padding: 5px 10px 2px;
5962
}
63+
.user-settings-section {
64+
position: relative;
65+
&:after {
66+
content: "";
67+
display: table;
68+
clear: both;
69+
}
70+
.uneditable-input, input {
71+
width: calc(100% - 150px);
72+
}
73+
}

red/api/editor/comms.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function handleStatus(event) {
3333
publish("status/"+event.id,event.status,true);
3434
}
3535
function handleRuntimeEvent(event) {
36+
log.trace("runtime event: "+JSON.stringify(event));
3637
publish("notification/"+event.id,event.payload||{},event.retain);
3738
}
3839
function init(_server,runtime) {

red/api/editor/locales/en-US/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@
8585
"nodeActionDisabled": "node actions disabled within subflow",
8686
"missing-types": "Flows stopped due to missing node types. Check logs for details.",
8787
"restartRequired": "Node-RED must be restarted to enable upgraded modules",
88-
"invalid-credentials-secret": "Flows stopped due to missing or invalid credentialSecret"
88+
"credentials_load_failed": "Flows stopped due to missing or invalid credentialSecret",
89+
"missing_flow_file": "Could not find the project flow file"
8990
},
9091

9192
"error": "<strong>Error</strong>: __message__",

red/api/editor/projects/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,24 @@ module.exports = {
7777
}
7878
})
7979
} else {
80-
res.redirect(303,req.baseUrl + '/');
80+
res.redirect(303,req.baseUrl + '/'+ req.params.id);
8181
}
8282
} else if (req.body.hasOwnProperty('credentialSecret') ||
8383
req.body.hasOwnProperty('description') ||
8484
req.body.hasOwnProperty('dependencies')||
85-
req.body.hasOwnProperty('summary')) {
85+
req.body.hasOwnProperty('summary') ||
86+
req.body.hasOwnProperty('files')) {
8687
runtime.storage.projects.updateProject(req.params.id, req.body).then(function() {
87-
res.redirect(303,req.baseUrl + '/');
88+
res.redirect(303,req.baseUrl + '/'+ req.params.id);
8889
}).catch(function(err) {
8990
if (err.code) {
9091
res.status(400).json({error:err.code, message: err.message});
9192
} else {
9293
res.status(400).json({error:"unexpected_error", message:err.toString()});
9394
}
9495
})
96+
} else {
97+
res.status(400).json({error:"unexpected_error", message:"invalid_request"});
9598
}
9699

97100
});

red/runtime/nodes/flows/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function loadFlows() {
7878
});
7979
}).catch(function(err) {
8080
activeConfig = null;
81-
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:"credentials_load_failed",text:"notification.warnings.invalid-credentials-secret"},retain:true});
81+
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,text:"notification.warnings."+err.code},retain:true});
8282
log.warn(log._("nodes.flows.error",{message:err.toString()}));
8383
throw err;
8484
});

0 commit comments

Comments
 (0)