refactor: Fix type issues for parameter input components (#9449)

This commit is contained in:
Elias Meire
2024-05-21 15:04:20 +02:00
committed by GitHub
parent cd751e7cc8
commit 711c46f205
36 changed files with 315 additions and 243 deletions

View File

@@ -95,7 +95,7 @@
<div v-if="parameterOptions.length > 0 && !isReadOnly" class="controls">
<n8n-button
v-if="parameter.options.length === 1"
v-if="parameter.options && parameter.options.length === 1"
type="tertiary"
block
:label="getPlaceholderText"
@@ -126,12 +126,7 @@ import { defineComponent } from 'vue';
import type { PropType } from 'vue';
import type { IUpdateInformation } from '@/Interface';
import type {
INodeParameters,
INodeProperties,
INodePropertyCollection,
NodeParameterValue,
} from 'n8n-workflow';
import type { INodeParameters, INodeProperties, INodePropertyCollection } from 'n8n-workflow';
import { deepCopy, isINodePropertyCollectionList } from 'n8n-workflow';
import { get } from 'lodash-es';
@@ -140,7 +135,7 @@ export default defineComponent({
name: 'FixedCollectionParameter',
props: {
nodeValues: {
type: Object as PropType<Record<string, INodeParameters[]>>,
type: Object as PropType<INodeParameters>,
required: true,
},
parameter: {
@@ -297,23 +292,18 @@ export default defineComponent({
optionParameter.typeOptions.multipleValues === true
) {
// Multiple values are allowed so append option to array
newParameterValue[optionParameter.name] = get(
this.nodeValues,
[this.path, optionParameter.name],
[],
);
const multiValue = get(this.nodeValues, [this.path, optionParameter.name], []);
if (Array.isArray(optionParameter.default)) {
(newParameterValue[optionParameter.name] as INodeParameters[]).push(
...deepCopy(optionParameter.default as INodeParameters[]),
);
multiValue.push(...deepCopy(optionParameter.default));
} else if (
optionParameter.default !== '' &&
typeof optionParameter.default !== 'object'
) {
(newParameterValue[optionParameter.name] as NodeParameterValue[]).push(
deepCopy(optionParameter.default),
);
multiValue.push(deepCopy(optionParameter.default));
}
newParameterValue[optionParameter.name] = multiValue;
} else {
// Add a new option
newParameterValue[optionParameter.name] = deepCopy(optionParameter.default);
@@ -322,7 +312,7 @@ export default defineComponent({
let newValue;
if (this.multipleValues) {
newValue = get(this.nodeValues, name, [] as INodeParameters[]);
newValue = get(this.nodeValues, name, []) as INodeParameters[];
newValue.push(newParameterValue);
} else {