mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
fix flags search without val
This commit is contained in:
parent
598bcf675f
commit
9540cfe749
@ -125,8 +125,8 @@ RED.search = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function search(val) {
|
function search(val) {
|
||||||
var results = [];
|
const results = [];
|
||||||
var flags = {};
|
const flags = {};
|
||||||
val = extractFlag(val,"invalid",flags);
|
val = extractFlag(val,"invalid",flags);
|
||||||
val = extractFlag(val,"unused",flags);
|
val = extractFlag(val,"unused",flags);
|
||||||
val = extractFlag(val,"config",flags);
|
val = extractFlag(val,"config",flags);
|
||||||
@ -137,7 +137,8 @@ RED.search = (function() {
|
|||||||
val = extractValue(val,"uses",flags);// uses:<node-id>
|
val = extractValue(val,"uses",flags);// uses:<node-id>
|
||||||
val = extractType(val,flags);// uses:<node-id>
|
val = extractType(val,flags);// uses:<node-id>
|
||||||
val = val.trim();
|
val = val.trim();
|
||||||
var hasFlags = Object.keys(flags).length > 0;
|
const hasFlags = Object.keys(flags).length > 0;
|
||||||
|
const hasTypeFilter = flags.type && flags.type.length > 0
|
||||||
if (flags.flow && flags.flow.indexOf("current") >= 0) {
|
if (flags.flow && flags.flow.indexOf("current") >= 0) {
|
||||||
let idx = flags.flow.indexOf("current");
|
let idx = flags.flow.indexOf("current");
|
||||||
flags.flow[idx] = RED.workspaces.active();//convert 'current' to active flow ID
|
flags.flow[idx] = RED.workspaces.active();//convert 'current' to active flow ID
|
||||||
@ -145,13 +146,12 @@ RED.search = (function() {
|
|||||||
if (flags.flow && flags.flow.length) {
|
if (flags.flow && flags.flow.length) {
|
||||||
flags.flow = [ ...new Set(flags.flow) ]; //deduplicate
|
flags.flow = [ ...new Set(flags.flow) ]; //deduplicate
|
||||||
}
|
}
|
||||||
const hasTypeFilter = flags.type && flags.type.length > 0
|
|
||||||
if (val.length > 0 || hasFlags) {
|
if (val.length > 0 || hasFlags) {
|
||||||
val = val.toLowerCase();
|
val = val.toLowerCase();
|
||||||
var i;
|
let i;
|
||||||
var j;
|
let j;
|
||||||
var list = [];
|
let list = [];
|
||||||
var nodes = {};
|
const nodes = {};
|
||||||
let keys = [];
|
let keys = [];
|
||||||
if (flags.uses) {
|
if (flags.uses) {
|
||||||
keys = flags.uses;
|
keys = flags.uses;
|
||||||
@ -159,10 +159,10 @@ RED.search = (function() {
|
|||||||
keys = Object.keys(index);
|
keys = Object.keys(index);
|
||||||
}
|
}
|
||||||
for (i=0;i<keys.length;i++) {
|
for (i=0;i<keys.length;i++) {
|
||||||
var key = keys[i];
|
const key = keys[i];
|
||||||
var kpos = val ? keys[i].indexOf(val) : -1;
|
const kpos = val ? keys[i].indexOf(val) : -1;
|
||||||
if (kpos > -1 || (val === "" && hasTypeFilter)) {
|
if (kpos > -1 || (val === "" && hasFlags)) {
|
||||||
var ids = Object.keys(index[key]||{});
|
const ids = Object.keys(index[key]||{});
|
||||||
for (j=0;j<ids.length;j++) {
|
for (j=0;j<ids.length;j++) {
|
||||||
var node = index[key][ids[j]];
|
var node = index[key][ids[j]];
|
||||||
var isConfigNode = node.node._def.category === "config" && node.node.type !== 'group';
|
var isConfigNode = node.node._def.category === "config" && node.node.type !== 'group';
|
||||||
@ -170,7 +170,7 @@ RED.search = (function() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (flags.hasOwnProperty("invalid")) {
|
if (flags.hasOwnProperty("invalid")) {
|
||||||
var nodeIsValid = !node.node.hasOwnProperty("valid") || node.node.valid;
|
const nodeIsValid = !node.node.hasOwnProperty("valid") || node.node.valid;
|
||||||
if (flags.invalid === nodeIsValid) {
|
if (flags.invalid === nodeIsValid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ RED.search = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags.hasOwnProperty("unused")) {
|
if (flags.hasOwnProperty("unused")) {
|
||||||
var isUnused = (node.node.type === 'subflow' && node.node.instances.length === 0) ||
|
const isUnused = (node.node.type === 'subflow' && node.node.instances.length === 0) ||
|
||||||
(isConfigNode && node.node.users.length === 0 && node.node._def.hasUsers !== false)
|
(isConfigNode && node.node.users.length === 0 && node.node._def.hasUsers !== false)
|
||||||
if (flags.unused !== isUnused) {
|
if (flags.unused !== isUnused) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user