mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch 'export-module-info' into feature/export-module-info
This commit is contained in:
commit
44e00b415e
@ -1571,8 +1571,9 @@ RED.nodes = (function() {
|
|||||||
/**
|
/**
|
||||||
* Converts the current configuration to an exportable JSON Object
|
* Converts the current configuration to an exportable JSON Object
|
||||||
* @param {object} opts
|
* @param {object} opts
|
||||||
* @param {boolean} [opts.credentials] whether to include (known) credentials. Default `false`.
|
* @param {boolean} [opts.credentials] whether to include (known) credentials. Default `true`.
|
||||||
* @param {boolean} [opts.dimensions] whether to include node dimensions. Default `false`.
|
* @param {boolean} [opts.dimensions] whether to include node dimensions. Default `false`.
|
||||||
|
* @param {boolean} [opts.includeModuleConfig] whether to include modules. Default `false`.
|
||||||
* @returns {Array<Node>}
|
* @returns {Array<Node>}
|
||||||
*/
|
*/
|
||||||
function createCompleteNodeSet(opts) {
|
function createCompleteNodeSet(opts) {
|
||||||
@ -1606,7 +1607,9 @@ RED.nodes = (function() {
|
|||||||
RED.nodes.eachNode(function(n) {
|
RED.nodes.eachNode(function(n) {
|
||||||
nns.push(convertNode(n, opts));
|
nns.push(convertNode(n, opts));
|
||||||
})
|
})
|
||||||
updateGlobalConfigModuleList(nns)
|
if (opts?.includeModuleConfig) {
|
||||||
|
updateGlobalConfigModuleList(nns);
|
||||||
|
}
|
||||||
return nns;
|
return nns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,7 +747,7 @@ RED.clipboard = (function() {
|
|||||||
nodes.unshift(parentNode);
|
nodes.unshift(parentNode);
|
||||||
nodes = RED.nodes.createExportableNodeSet(nodes, { includeModuleConfig: true });
|
nodes = RED.nodes.createExportableNodeSet(nodes, { includeModuleConfig: true });
|
||||||
} else if (type === 'full') {
|
} else if (type === 'full') {
|
||||||
nodes = RED.nodes.createCompleteNodeSet({ credentials: false });
|
nodes = RED.nodes.createCompleteNodeSet({ credentials: false, includeModuleConfig: true });
|
||||||
}
|
}
|
||||||
if (nodes !== null) {
|
if (nodes !== null) {
|
||||||
if (format === "red-ui-clipboard-dialog-export-fmt-full") {
|
if (format === "red-ui-clipboard-dialog-export-fmt-full") {
|
||||||
|
@ -5676,17 +5676,38 @@ RED.view = (function() {
|
|||||||
filteredNodesToImport = nodesToImport.filter(function (n) {
|
filteredNodesToImport = nodesToImport.filter(function (n) {
|
||||||
if (n.type === "global-config") {
|
if (n.type === "global-config") {
|
||||||
importedGlobalConfig = n
|
importedGlobalConfig = n
|
||||||
|
// Do not import it if one exists
|
||||||
|
// The properties of this one will be merged after import
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
filteredNodesToImport = nodesToImport.filter(function (n) {
|
||||||
|
if (n.type === "global-config") {
|
||||||
|
importedGlobalConfig = n
|
||||||
|
if (n.env && n.env.length) {
|
||||||
|
// No existing global-config
|
||||||
|
// Contains env and maybe modules, so import it
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// Contains modules only - do not import it
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const modules = importedGlobalConfig?.modules || {}
|
||||||
|
// Ensure do not import modules - since it can contain it
|
||||||
|
delete importedGlobalConfig?.modules
|
||||||
|
|
||||||
var result = RED.nodes.import(filteredNodesToImport,{
|
var result = RED.nodes.import(filteredNodesToImport,{
|
||||||
generateIds: options.generateIds,
|
generateIds: options.generateIds,
|
||||||
addFlow: addNewFlow,
|
addFlow: addNewFlow,
|
||||||
importMap: options.importMap,
|
importMap: options.importMap,
|
||||||
markChanged: true,
|
markChanged: true,
|
||||||
modules: importedGlobalConfig ? (importedGlobalConfig.modules || {}) : {}
|
modules: modules
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result) {
|
||||||
var new_nodes = result.nodes;
|
var new_nodes = result.nodes;
|
||||||
@ -5810,7 +5831,7 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (importedGlobalConfig) {
|
if (importedGlobalConfig && existingGlobalConfig) {
|
||||||
// merge global env to existing global-config
|
// merge global env to existing global-config
|
||||||
var existingEnv = existingGlobalConfig.env || [];
|
var existingEnv = existingGlobalConfig.env || [];
|
||||||
var importedEnv = importedGlobalConfig.env || []
|
var importedEnv = importedGlobalConfig.env || []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user