add optional array type
This commit is contained in:
1 parent
728148bff1
commit
c53854eeca
3 files changed
+16
-12
No files matched your search
@@ -637,6 +637,7 @@ const NodeInspector: FC = () => {
|
|||||||
}}
|
}}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
|
danger={items.length === 0 && !isNodeArgOptional(arg)}
|
||||||
>
|
>
|
||||||
{t("node.args.add")}
|
{t("node.args.add")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
+8
-1
@@ -8,24 +8,31 @@ export interface NodeArg {
|
|||||||
| "boolean"
|
| "boolean"
|
||||||
| "boolean?"
|
| "boolean?"
|
||||||
| "boolean[]"
|
| "boolean[]"
|
||||||
|
| "boolean[]?"
|
||||||
| "int"
|
| "int"
|
||||||
| "int?"
|
| "int?"
|
||||||
| "int[]"
|
| "int[]"
|
||||||
|
| "int[]?"
|
||||||
| "float"
|
| "float"
|
||||||
| "float?"
|
| "float?"
|
||||||
| "float[]"
|
| "float[]"
|
||||||
|
| "float[]?"
|
||||||
| "string"
|
| "string"
|
||||||
| "string?"
|
| "string?"
|
||||||
| "string[]"
|
| "string[]"
|
||||||
|
| "string[]?"
|
||||||
| "json"
|
| "json"
|
||||||
| "json?"
|
| "json?"
|
||||||
| "json[]"
|
| "json[]"
|
||||||
|
| "json[]?"
|
||||||
| "enum"
|
| "enum"
|
||||||
| "enum?"
|
| "enum?"
|
||||||
| "enum[]"
|
| "enum[]"
|
||||||
|
| "enum[]?"
|
||||||
| "code"
|
| "code"
|
||||||
| "code?"
|
| "code?"
|
||||||
| "code[]";
|
| "code[]"
|
||||||
|
| "code[]?";
|
||||||
desc: string;
|
desc: string;
|
||||||
oneof?: string;
|
oneof?: string;
|
||||||
default?: unknown;
|
default?: unknown;
|
||||||
|
|||||||
+7
-11
@@ -199,13 +199,11 @@ export const checkNodeArg = (
|
|||||||
const arg = conf.args![i] as NodeArg;
|
const arg = conf.args![i] as NodeArg;
|
||||||
const value = data.args?.[arg.name];
|
const value = data.args?.[arg.name];
|
||||||
if (isNodeArgArray(arg)) {
|
if (isNodeArgArray(arg)) {
|
||||||
if (!Array.isArray(value)) {
|
if (!Array.isArray(value) || (!isNodeArgOptional(arg) && value.length === 0)) {
|
||||||
if (value !== undefined) {
|
if (verbose) {
|
||||||
if (verbose) {
|
error(data, `'${arg.name}=${JSON.stringify(value)}' is not an array or empty array`);
|
||||||
error(data, `'${arg.name}=${value}' is not an array`);
|
|
||||||
}
|
|
||||||
hasError = true;
|
|
||||||
}
|
}
|
||||||
|
hasError = true;
|
||||||
} else {
|
} else {
|
||||||
for (let j = 0; j < value.length; j++) {
|
for (let j = 0; j < value.length; j++) {
|
||||||
if (!checkNodeArgValue(data, arg, value[j], verbose)) {
|
if (!checkNodeArgValue(data, arg, value[j], verbose)) {
|
||||||
@@ -300,13 +298,11 @@ export const checkNodeData = (data: NodeModel | null | undefined) => {
|
|||||||
for (let i = 0; i < conf.args.length; i++) {
|
for (let i = 0; i < conf.args.length; i++) {
|
||||||
const key = conf.args[i].name;
|
const key = conf.args[i].name;
|
||||||
const value = data.args?.[key];
|
const value = data.args?.[key];
|
||||||
if (!checkNodeArg(data, conf, i, true)) {
|
|
||||||
hasError = true;
|
|
||||||
}
|
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
args[key] = value;
|
args[key] = value;
|
||||||
} else if (isNodeArgArray(conf.args[i])) {
|
}
|
||||||
args[key] = [];
|
if (!checkNodeArg(data, conf, i, true)) {
|
||||||
|
hasError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.args = args;
|
data.args = args;
|
||||||
|
|||||||
Reference in new issue
Block a user