1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Deprecate editorTheme.palette.editable for externalModules.palette.allowInstall

Also deprecates editorTheme.palette.editable for externalModules.palette.allowUpload
This commit is contained in:
Nick O'Leary 2020-12-23 23:29:07 +00:00
parent 3151502a3f
commit fc459be531
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
6 changed files with 40 additions and 20 deletions

View File

@ -269,7 +269,7 @@ var RED = (function() {
}
}
]
// } else if (RED.settings.theme('palette.editable') !== false) {
// } else if (RED.settings.get('externalModules.palette.allowInstall', true) !== false) {
} else {
options.buttons = [
{
@ -509,7 +509,7 @@ var RED = (function() {
]});
menuOptions.push(null);
if (RED.settings.theme('palette.editable') !== false) {
if (RED.settings.get('externalModules.palette.allowInstall', true) !== false) {
menuOptions.push({id:"menu-item-edit-palette",label:RED._("menu.label.editPalette"),onselect:"core:manage-palette"});
menuOptions.push(null);
}
@ -544,7 +544,7 @@ var RED = (function() {
RED.palette.init();
RED.eventLog.init();
if (RED.settings.theme('palette.editable') !== false) {
if (RED.settings.get('externalModules.palette.allowInstall', true) !== false) {
RED.palette.editor.init();
} else {
console.log("Palette editor disabled");

View File

@ -57,12 +57,11 @@ RED.settings = (function () {
return JSON.parse(localStorage.getItem(key));
} else {
var v;
try {
v = RED.utils.getMessageProperty(userSettings,key);
if (v === undefined) {
v = defaultIfUndefined;
}
} catch(err) {
try { v = RED.utils.getMessageProperty(userSettings,key); } catch(err) {}
if (v === undefined) {
try { v = RED.utils.getMessageProperty(RED.settings,key); } catch(err) {}
}
if (v === undefined) {
v = defaultIfUndefined;
}
return v;

View File

@ -439,7 +439,7 @@ RED.palette.editor = (function() {
function init() {
if (RED.settings.theme('palette.editable') === false) {
if (RED.settings.get('externalModules.palette.allowInstall', true) === false) {
return;
}
createSettingsPane();
@ -880,7 +880,7 @@ RED.palette.editor = (function() {
}
});
if (RED.settings.theme('palette.upload') !== false) {
if (RED.settings.get('externalModules.palette.allowUpload', true) !== false) {
var uploadSpan = $('<span class="button-group">').prependTo(toolBar);
var uploadButton = $('<button type="button" class="red-ui-sidebar-header-button red-ui-palette-editor-upload-button"><label><i class="fa fa-upload"></i><form id="red-ui-palette-editor-upload-form" enctype="multipart/form-data"><input name="tarball" type="file" accept=".tgz"></label></button>').appendTo(uploadSpan);
@ -962,7 +962,7 @@ RED.palette.editor = (function() {
}
function update(entry,version,url,container,done) {
if (RED.settings.theme('palette.editable') === false) {
if (RED.settings.get('externalModules.palette.allowInstall', true) === false) {
done(new Error('Palette not editable'));
return;
}
@ -1021,7 +1021,7 @@ RED.palette.editor = (function() {
})
}
function remove(entry,container,done) {
if (RED.settings.theme('palette.editable') === false) {
if (RED.settings.get('externalModules.palette.allowInstall', true) === false) {
done(new Error('Palette not editable'));
return;
}
@ -1078,7 +1078,7 @@ RED.palette.editor = (function() {
})
}
function install(entry,container,done) {
if (RED.settings.theme('palette.editable') === false) {
if (RED.settings.get('externalModules.palette.allowInstall', true) === false) {
done(new Error('Palette not editable'));
return;
}

View File

@ -465,7 +465,7 @@ RED.projects.settings = (function() {
metaRow = $('<div class="red-ui-palette-module-meta"></div>').appendTo(headerRow);
var buttons = $('<div class="red-ui-palette-module-button-group"></div>').appendTo(metaRow);
if (RED.user.hasPermission("projects.write")) {
if (!entry.installed && RED.settings.theme('palette.editable') !== false) {
if (!entry.installed && RED.settings.get('externalModules.palette.allowInstall', true) !== false) {
$('<a href="#" class="red-ui-button red-ui-button-small">' + RED._("sidebar.project.projectSettings.install") + '</a>').appendTo(buttons)
.on("click", function(evt) {
evt.preventDefault();

View File

@ -335,7 +335,24 @@ function uninstallModule(module) {
return activePromise;
}
function checkPrereq() {
async function checkPrereq() {
try {
if (settings.editorTheme.palette.editable === false) {
log.info(log._("server.palette-editor.disabled"));
installerEnabled = false;
return
}
} catch(err) {}
try {
if (settings.externalModules.palette.allowInstall === false) {
log.info(log._("server.palette-editor.disabled"));
installerEnabled = false;
return
}
} catch(err) {}
if (settings.hasOwnProperty('editorTheme') &&
settings.editorTheme.hasOwnProperty('palette') &&
settings.editorTheme.palette.hasOwnProperty('editable') &&
@ -343,7 +360,6 @@ function checkPrereq() {
) {
log.info(log._("server.palette-editor.disabled"));
installerEnabled = false;
return Promise.resolve();
} else {
return new Promise(resolve => {
child_process.execFile(npmCommand,['-v'],function(err,stdout) {

View File

@ -90,10 +90,15 @@ var api = module.exports = {
safeSettings.flowFilePretty = runtime.settings.flowFilePretty;
}
if (runtime.settings.externalModules) {
safeSettings.externalModules = runtime.settings.externalModules;
}
if (!runtime.nodes.installerEnabled()) {
safeSettings.editorTheme = safeSettings.editorTheme || {};
safeSettings.editorTheme.palette = safeSettings.editorTheme.palette || {};
safeSettings.editorTheme.palette.editable = false;
safeSettings.externalModules = safeSettings.externalModules || {};
safeSettings.externalModules.palette = safeSettings.externalModules.palette || {};
safeSettings.externalModules.palette.allowInstall = false;
safeSettings.externalModules.palette.allowUpload = false;
}
if (runtime.storage.projects) {
var activeProject = runtime.storage.projects.getActiveProject();