Skip to content

Commit 1165638

Browse files
committed
Allow palette-editor to be disabled via editorTheme
1 parent e4d788a commit 1165638

4 files changed

Lines changed: 25 additions & 14 deletions

File tree

editor/js/ui/palette-editor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ RED.palette.editor = (function() {
304304

305305
function initInstallTab() {
306306
$("#palette-module-install-shade").show();
307-
$.getJSON('http://catalog.nodered.org/catalog.json',function(v) {
307+
308+
$.getJSON('http://catalogue.nodered.org/catalogue.json',function(v) {
308309
loadedList = v;
309310
searchInput.searchBox('count',loadedList.length);
310311
loadedList.forEach(function(m) {
@@ -321,6 +322,8 @@ RED.palette.editor = (function() {
321322
}
322323
function init() {
323324

325+
$(".palette-editor-button").show();
326+
324327
editorTabs = RED.tabs.create({
325328
id:"palette-editor-tabs",
326329
onchange:function(tab) {

editor/js/ui/palette.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
RED.palette = (function() {
1818

1919
var exclusion = ['config','unknown','deprecated'];
20-
var core = ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'];
20+
var coreCategories = ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'];
2121

2222
var categoryContainers = {};
2323

@@ -174,7 +174,7 @@ RED.palette = (function() {
174174
}
175175

176176
if ($("#palette-base-category-"+rootCategory).length === 0) {
177-
if(core.indexOf(rootCategory) !== -1){
177+
if(coreCategories.indexOf(rootCategory) !== -1){
178178
createCategoryContainer(rootCategory, RED._("node-red:palette.label."+rootCategory, {defaultValue:rootCategory}));
179179
} else {
180180
var ns = def.set.id;
@@ -438,15 +438,18 @@ RED.palette = (function() {
438438
}
439439
})
440440

441+
var categoryList = coreCategories;
441442
if (RED.settings.paletteCategories) {
442-
RED.settings.paletteCategories.forEach(function(category){
443-
createCategoryContainer(category, RED._("palette.label."+category,{defaultValue:category}));
444-
});
445-
} else {
446-
core.forEach(function(category){
447-
createCategoryContainer(category, RED._("palette.label."+category,{defaultValue:category}));
448-
});
443+
categoryList = RED.settings.paletteCategories;
444+
} else if (RED.settings.theme('palette.categories')) {
445+
categoryList = RED.settings.theme('palette.categories');
446+
}
447+
if (!Array.isArray(categoryList)) {
448+
categoryList = coreCategories
449449
}
450+
categoryList.forEach(function(category){
451+
createCategoryContainer(category, RED._("palette.label."+category,{defaultValue:category}));
452+
});
450453

451454
$("#palette-collapse-all").on("click", function(e) {
452455
e.preventDefault();
@@ -465,7 +468,9 @@ RED.palette = (function() {
465468
}
466469
});
467470

468-
RED.palette.editor.init();
471+
if (RED.settings.theme('palette.editable') !== false) {
472+
RED.palette.editor.init();
473+
}
469474
}
470475

471476
return {

editor/templates/index.mst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</div>
6868
<div id="palette-container" class="palette-scroll hide"></div>
6969
<div id="palette-footer">
70-
<div style="float:left">
70+
<div style="float:left" class="palette-editor-button hide">
7171
<a class="palette-button palette-button-left" id="palette-edit" href="#"><i class="fa fa-cog"></i></a>
7272
</div>
7373
<a class="palette-button" id="palette-collapse-all" href="#"><i class="fa fa-angle-double-up"></i></a>

red/api/theme.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015 IBM Corp.
2+
* Copyright 2015, 2016 IBM Corp.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -94,7 +94,7 @@ module.exports = {
9494
themeContext.page.favicon = url;
9595
}
9696
}
97-
97+
9898
if (theme.page.tabicon) {
9999
url = serveFile(themeApp,"/tabicon/",theme.page.tabicon)
100100
if (url) {
@@ -161,6 +161,9 @@ module.exports = {
161161
themeSettings.menu = theme.menu;
162162
}
163163

164+
if (theme.hasOwnProperty("palette")) {
165+
themeSettings.palette = theme.palette;
166+
}
164167
return themeApp;
165168
},
166169
context: function() {

0 commit comments

Comments
 (0)