",{class:"sidebar-projects-stack"}).appendTo(sidebarContent);
-
- RED.actions.add("core:show-projects-tab",showSidebar);
-
-
- outerSections = RED.stack.create({
- container: infoStackContainer,
- fill: true
- });
-
- var a = outerSections.add({
- title: "Project",
- collapsible: false
- })
-
- sidebarSectionsInfo = $("
",{class:"node-help"}).appendTo(a.content);
-
- sidebarSections = RED.stack.create({
- container: stackContainer,
- singleExpanded: true,
- fill: true
- });
-
- sidebarSectionsDesc = sidebarSections.add({
- title: RED._("sidebar.project.description"),
- expanded: true
- });
- sidebarSectionsDesc.content.css({padding:"6px"});
-
- var editDescription = $('
').appendTo(sidebarSectionsDesc.header);
- var editDescriptionFunc = function() {
- RED.editor.editMarkdown({
- title: RED._('sidebar.project.editDescription'),
- value: activeProject.description,
- complete: function(v) {
- var spinner = addSpinnerOverlay(sidebarSectionsDesc.content);
- editDescription.addClass('disabled');
- var done = function(err,res) {
- if (err) {
- editDescriptionFunc();
- }
- activeProject.description = v;
- updateProjectDescription();
+ function refresh(done) {
+ $.getJSON("projects",function(data) {
+ if (data.active) {
+ $.getJSON("projects/"+data.active, function(project) {
+ activeProject = project;
+ // updateProjectSummary();
+ // updateProjectDescription();
+ // updateProjectDependencies();
+ RED.sidebar.versionControl.refresh(true);
+ if (done) {
+ done();
}
- sendRequest({
- url: "projects/"+activeProject.name,
- type: "PUT",
- responses: {
- 0: function(error) {
- done(error,null);
- },
- 200: function(data) {
- done(null,data);
- },
- 400: {
- 'unexpected_error': function(error) {
- done(error,null);
- }
- },
- }
- },{description:v}).always(function() {
- spinner.remove();
- editDescription.removeClass('disabled');
- });
- }
- });
- }
-
- editDescription.click(function(evt) {
- evt.preventDefault();
- if ($(this).hasClass('disabled')) {
- return;
- }
- editDescriptionFunc();
- });
-
-
-
-
- sidebarSectionsDeps = sidebarSections.add({
- title:RED._("sidebar.project.dependencies")
- });
- sidebarSectionsDeps.content.addClass("sidebar-projects-dependencies");
-
- var editDependencies = $('
').appendTo(sidebarSectionsDeps.header);
- var editDependenciesFunc = function(depsJSON) {
-
- RED.editor.editJSON({
- title: RED._('sidebar.project.editDependencies'),
- value: JSON.stringify(depsJSON||activeProject.dependencies||{},"",4),
- complete: function(v) {
- try {
- var parsed = JSON.parse(v);
- var spinner = addSpinnerOverlay(sidebarSectionsDeps.content);
-
- editDependencies.addClass('disabled');
- var done = function(err,res) {
- if (err) {
- editDependenciesFunc(depsJSON);
- }
- activeProject.dependencies = parsed;
- updateProjectDependencies();
- }
- sendRequest({
- url: "projects/"+activeProject.name,
- type: "PUT",
- responses: {
- 0: function(error) {
- done(error,null);
- },
- 200: function(data) {
- done(null,data);
- },
- 400: {
- 'unexpected_error': function(error) {
- done(error,null);
- }
- },
- }
- },{dependencies:parsed}).always(function() {
- spinner.remove();
- editDependencies.removeClass('disabled');
- });
- } catch(err) {
- editDependenciesFunc(depsJSON);
- }
- }
- });
- }
- editDependencies.click(function(evt) {
- evt.preventDefault();
- editDependenciesFunc();
- });
-
- sidebarSectionsDepsList = $("
",{style:"position: absolute;top: 0;bottom: 0;left: 0;right: 0;"}).appendTo(sidebarSectionsDeps.content);
- sidebarSectionsDepsList.editableList({
- addButton: false,
- addItem: function(row,index,entry) {
- // console.log(entry);
- var headerRow = $('',{class:"palette-module-header"}).appendTo(row);
- if (entry.label) {
- row.parent().addClass("palette-module-section");
- headerRow.text(entry.label);
- if (entry.index === 1) {
- var addButton = $('
').appendTo(headerRow).click(function(evt) {
- evt.preventDefault();
- var deps = $.extend(true, {}, activeProject.dependencies);
- for (var m in modulesInUse) {
- if (modulesInUse.hasOwnProperty(m) && !modulesInUse[m].known) {
- deps[m] = modulesInUse[m].version;
- }
- }
- editDependenciesFunc(deps);
- });
- } else if (entry.index === 3) {
- var removeButton = $('
').appendTo(headerRow).click(function(evt) {
- evt.preventDefault();
- var deps = $.extend(true, {}, activeProject.dependencies);
- for (var m in modulesInUse) {
- if (modulesInUse.hasOwnProperty(m) && modulesInUse[m].known && modulesInUse[m].count === 0) {
- delete deps[m];
- }
- }
- editDependenciesFunc(deps);
- });
- }
- } else {
- headerRow.toggleClass("palette-module-unused",entry.count === 0);
- entry.element = headerRow;
- var titleRow = $('
').appendTo(headerRow);
- var icon = $('
').appendTo(titleRow);
- entry.icon = icon;
- $('
').html(entry.module).appendTo(titleRow);
- var metaRow = $('
').appendTo(headerRow);
- var versionSpan = $('').html(entry.version).appendTo(metaRow);
- if (!entry.known) {
- headerRow.addClass("palette-module-unknown");
- } else if (entry.known && entry.count === 0) {
-
- }
- }
- },
- sort: function(A,B) {
- if (A.index && B.index) {
- return A.index - B.index;
- }
- var Acategory = A.index?A.index:(A.known?(A.count>0?0:4):2);
- var Bcategory = B.index?B.index:(B.known?(B.count>0?0:4):2);
- if (Acategory === Bcategory) {
- return A.module.localeCompare(B.module);
- } else {
- return Acategory - Bcategory;
- }
+ });
}
});
- sidebarSectionsDeps.container.css("border-bottom","none");
-
- // sidebarSectionsSettings = sidebarSections.add({
- // title: RED._("sidebar.project.settings")
- // });
- // sidebarSectionsSettings.container.css("border-bottom","none");
-
- RED.sidebar.addTab({
- id: "project",
- label: RED._("sidebar.project.label"),
- name: RED._("sidebar.project.name"),
- content: sidebarContent,
- onchange: function() {
- setTimeout(function() {
- sidebarSections.resize();
- },10);
- }
- });
-
- RED.events.on('nodes:add', function(n) {
- if (!/^subflow:/.test(n.type)) {
- var module = RED.nodes.registry.getNodeSetForType(n.type).module;
- if (module !== 'node-red') {
- if (!modulesInUse.hasOwnProperty(module)) {
- modulesInUse[module] = {
- module: module,
- version: RED.nodes.registry.getModule(module).version,
- count: 0,
- known: false
- }
- }
- modulesInUse[module].count++;
- if (modulesInUse[module].count === 1 && !modulesInUse[module].known) {
- sidebarSectionsDepsList.editableList('addItem',modulesInUse[module]);
- } else {
- sidebarSectionsDepsList.editableList('sort');
- if (modulesInUse[module].element) {
- modulesInUse[module].element.removeClass("palette-module-unused");
- }
- }
- }
- }
- })
- RED.events.on('nodes:remove', function(n) {
- if (!/^subflow:/.test(n.type)) {
- var module = RED.nodes.registry.getNodeSetForType(n.type).module;
- if (module !== 'node-red' && modulesInUse.hasOwnProperty(module)) {
- modulesInUse[module].count--;
- if (modulesInUse[module].count === 0) {
- if (!modulesInUse[module].known) {
- sidebarSectionsDepsList.editableList('removeItem',modulesInUse[module]);
- delete modulesInUse[module];
- } else {
- // TODO: a known dependency is now unused by the flow
- sidebarSectionsDepsList.editableList('sort');
- modulesInUse[module].element.addClass("palette-module-unused");
- }
- }
- }
- }
- })
-
-
}
- function showSidebar() {
- RED.sidebar.show("project");
- }
- function addSpinnerOverlay(container) {
- var spinner = $('').appendTo(container);
- return spinner;
- }
- function updateProjectSummary() {
- sidebarSectionsInfo.empty();
- if (activeProject) {
- var table = $('').appendTo(sidebarSectionsInfo);
- var tableBody = $('').appendTo(table);
- var propRow;
- propRow = $('Project | |
').appendTo(tableBody);
- $(propRow.children()[1]).html(' '+(activeProject.name||""))
- }
- }
- function updateProjectDescription() {
- sidebarSectionsDesc.content.empty();
- if (activeProject) {
- var div = $('').appendTo(sidebarSectionsDesc.content);
- var desc = marked(activeProject.description||"");
- var description = addTargetToExternalLinks($(''+desc+'
')).appendTo(div);
- description.find(".bidiAware").contents().filter(function() { return this.nodeType === 3 && this.textContent.trim() !== "" }).wrap( "" );
- }
- }
- function updateProjectDependencies() {
- if (activeProject) {
- sidebarSectionsDepsList.editableList('empty');
- sidebarSectionsDepsList.editableList('addItem',{index:1, label:"Unknown Dependencies"});
- sidebarSectionsDepsList.editableList('addItem',{index:3, label:"Unused dependencies"});
- var dependencies = activeProject.dependencies||{};
- var moduleList = Object.keys(dependencies);
- if (moduleList.length > 0) {
- moduleList.sort();
- moduleList.forEach(function(module) {
- if (modulesInUse.hasOwnProperty(module)) {
- // TODO: this module is used by not currently 'known'
- modulesInUse[module].known = true;
- } else {
- modulesInUse[module] = {module:module,version:dependencies[module], known: true, count:0};
- }
- })
- }
- for (var module in modulesInUse) {
- if (modulesInUse.hasOwnProperty(module)) {
- var m = modulesInUse[module];
- if (!dependencies.hasOwnProperty(module) && m.count === 0) {
- delete modulesInUse[module];
- } else {
- sidebarSectionsDepsList.editableList('addItem',modulesInUse[module]);
- }
- }
- }
- }
- }
-
-
- // function getUsedModules() {
- // var inuseModules = {};
- // var inuseTypes = {};
- // var getNodeModule = function(node) {
- // if (inuseTypes[node.type]) {
- // return;
- // }
- // inuseTypes[node.type] = true;
- // inuseModules[RED.nodes.registry.getNodeSetForType(node.type).module] = true;
- // }
- // RED.nodes.eachNode(getNodeModule);
- // RED.nodes.eachConfig(getNodeModule);
- // console.log(Object.keys(inuseModules));
- // }
-
- // TODO: DRY - tab-info.js
- function addTargetToExternalLinks(el) {
- $(el).find("a").each(function(el) {
- var href = $(this).attr('href');
- if (/^https?:/.test(href)) {
- $(this).attr('target','_blank');
- }
- });
- return el;
- }
-*/
-
-function refresh() {
- $.getJSON("projects",function(data) {
- if (data.active) {
- $.getJSON("projects/"+data.active, function(project) {
- activeProject = project;
- // updateProjectSummary();
- // updateProjectDescription();
- // updateProjectDependencies();
- RED.sidebar.info.refresh();
- });
- }
- });
-}
diff --git a/editor/js/ui/tab-versionControl.js b/editor/js/ui/tab-versionControl.js
index 627ed1459..cf26e470d 100644
--- a/editor/js/ui/tab-versionControl.js
+++ b/editor/js/ui/tab-versionControl.js
@@ -306,6 +306,7 @@ RED.sidebar.versionControl = (function() {
spinner.remove();
cancelCommitButton.click();
refreshFiles(data);
+ refreshLocalCommits();
},
400: {
'unexpected_error': function(error) {
@@ -550,6 +551,7 @@ RED.sidebar.versionControl = (function() {
}
refreshInProgress = true;
+ refreshLocalCommits();
var activeProject = RED.projects.getActiveProject();
if (activeProject) {