From 11656382a7de0458be8d42e7484e9d24ccc5ef2f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 10 Aug 2016 20:15:17 +0100 Subject: [PATCH] Allow palette-editor to be disabled via editorTheme --- editor/js/ui/palette-editor.js | 5 ++++- editor/js/ui/palette.js | 25 +++++++++++++++---------- editor/templates/index.mst | 2 +- red/api/theme.js | 7 +++++-- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/editor/js/ui/palette-editor.js b/editor/js/ui/palette-editor.js index 4825d2f28..7fa849e91 100644 --- a/editor/js/ui/palette-editor.js +++ b/editor/js/ui/palette-editor.js @@ -304,7 +304,8 @@ RED.palette.editor = (function() { function initInstallTab() { $("#palette-module-install-shade").show(); - $.getJSON('http://catalog.nodered.org/catalog.json',function(v) { + + $.getJSON('http://catalogue.nodered.org/catalogue.json',function(v) { loadedList = v; searchInput.searchBox('count',loadedList.length); loadedList.forEach(function(m) { @@ -321,6 +322,8 @@ RED.palette.editor = (function() { } function init() { + $(".palette-editor-button").show(); + editorTabs = RED.tabs.create({ id:"palette-editor-tabs", onchange:function(tab) { diff --git a/editor/js/ui/palette.js b/editor/js/ui/palette.js index 081d0b84d..cf5c0e58e 100644 --- a/editor/js/ui/palette.js +++ b/editor/js/ui/palette.js @@ -17,7 +17,7 @@ RED.palette = (function() { var exclusion = ['config','unknown','deprecated']; - var core = ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced']; + var coreCategories = ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced']; var categoryContainers = {}; @@ -174,7 +174,7 @@ RED.palette = (function() { } if ($("#palette-base-category-"+rootCategory).length === 0) { - if(core.indexOf(rootCategory) !== -1){ + if(coreCategories.indexOf(rootCategory) !== -1){ createCategoryContainer(rootCategory, RED._("node-red:palette.label."+rootCategory, {defaultValue:rootCategory})); } else { var ns = def.set.id; @@ -438,15 +438,18 @@ RED.palette = (function() { } }) + var categoryList = coreCategories; if (RED.settings.paletteCategories) { - RED.settings.paletteCategories.forEach(function(category){ - createCategoryContainer(category, RED._("palette.label."+category,{defaultValue:category})); - }); - } else { - core.forEach(function(category){ - createCategoryContainer(category, RED._("palette.label."+category,{defaultValue:category})); - }); + categoryList = RED.settings.paletteCategories; + } else if (RED.settings.theme('palette.categories')) { + categoryList = RED.settings.theme('palette.categories'); } + if (!Array.isArray(categoryList)) { + categoryList = coreCategories + } + categoryList.forEach(function(category){ + createCategoryContainer(category, RED._("palette.label."+category,{defaultValue:category})); + }); $("#palette-collapse-all").on("click", function(e) { e.preventDefault(); @@ -465,7 +468,9 @@ RED.palette = (function() { } }); - RED.palette.editor.init(); + if (RED.settings.theme('palette.editable') !== false) { + RED.palette.editor.init(); + } } return { diff --git a/editor/templates/index.mst b/editor/templates/index.mst index 2ddbea2c3..92d6464b6 100644 --- a/editor/templates/index.mst +++ b/editor/templates/index.mst @@ -67,7 +67,7 @@