Prop drilling to re-render select

This commit is contained in:
Iván Ovejero 2022-05-04 11:38:42 +02:00
parent 64e08c8fdd
commit aa986e13be
5 changed files with 26 additions and 14 deletions

View file

@ -115,10 +115,16 @@ export default mixins(
.map((credentialTypeDescription) => credentialTypeDescription.name); .map((credentialTypeDescription) => credentialTypeDescription.name);
}, },
credentialTypesNodeDescriptionDisplayed (): INodeCredentialDescription[] { credentialTypesNodeDescriptionDisplayed (): INodeCredentialDescription[] {
return this.credentialTypesNodeDescription const descriptions = this.credentialTypesNodeDescription
.filter((credentialTypeDescription) => { .filter((credentialTypeDescription) => {
return this.displayCredentials(credentialTypeDescription); return this.displayCredentials(credentialTypeDescription);
}); });
if (descriptions.length === 1) {
this.$emit('newActiveCredentialType', descriptions[0].name);
}
return descriptions;
}, },
credentialTypesNodeDescription (): INodeCredentialDescription[] { credentialTypesNodeDescription (): INodeCredentialDescription[] {
const node = this.node as INodeUi; const node = this.node as INodeUi;

View file

@ -31,10 +31,12 @@
:parameters="parametersNoneSetting" :parameters="parametersNoneSetting"
:hideDelete="true" :hideDelete="true"
:nodeValues="nodeValues" path="parameters" @valueChanged="valueChanged" :nodeValues="nodeValues" path="parameters" @valueChanged="valueChanged"
:isSupportedByHttpRequestNode="isSupportedByHttpRequestNode"
> >
<node-credentials <node-credentials
:node="node" :node="node"
@credentialSelected="credentialSelected" @credentialSelected="credentialSelected"
@newActiveCredentialType="checkIfSupportedByHttpRequestNode"
/> />
</parameter-input-list> </parameter-input-list>
<div v-if="parametersNoneSetting.length === 0" class="no-parameters"> <div v-if="parametersNoneSetting.length === 0" class="no-parameters">
@ -209,6 +211,7 @@ export default mixins(
notes: '', notes: '',
parameters: {}, parameters: {},
} as INodeParameters, } as INodeParameters,
isSupportedByHttpRequestNode: false,
nodeSettings: [ nodeSettings: [
{ {
@ -310,6 +313,17 @@ export default mixins(
}, },
}, },
methods: { methods: {
/**
* Check if the node's currently active credential type may be used to make a request with the HTTP Request node v2.
*/
checkIfSupportedByHttpRequestNode(activeCredentialType: string) {
const credentialType = this.getCredentialTypeByName(activeCredentialType);
this.isSupportedByHttpRequestNode = (
credentialType.name.slice(0, -4).endsWith('OAuth') ||
credentialType.authenticate !== undefined
);
},
onNodeExecute () { onNodeExecute () {
this.$emit('execute'); this.$emit('execute');
}, },

View file

@ -258,6 +258,7 @@ export default mixins(
'hideIssues', // boolean 'hideIssues', // boolean
'errorHighlight', 'errorHighlight',
'isForCredential', // boolean 'isForCredential', // boolean
'isSupportedByHttpRequestNode', // boolean
], ],
data () { data () {
return { return {
@ -597,19 +598,6 @@ export default mixins(
return this.getWorkflow(); return this.getWorkflow();
}, },
/**
* Whether the node's credential may be used to make a request with the HTTP Request node.
*/
isSupportedByHttpRequestNode(): boolean {
if (!this.node || !this.node.activeCredentialType || !this.node.credentials) return false;
const credentialType = this.getCredentialTypeByName(this.node.activeCredentialType);
return (
credentialType.name.slice(0, -4).endsWith('OAuth') ||
credentialType.authenticate !== undefined
);
},
}, },
methods: { methods: {
getPlaceholder(): string { getPlaceholder(): string {

View file

@ -12,6 +12,7 @@
:displayOptions="displayOptions" :displayOptions="displayOptions"
:path="path" :path="path"
:isReadOnly="isReadOnly" :isReadOnly="isReadOnly"
:isSupportedByHttpRequestNode="isSupportedByHttpRequestNode"
@valueChanged="valueChanged" @valueChanged="valueChanged"
@focus="focused = true" @focus="focused = true"
@blur="focused = false" @blur="focused = false"
@ -48,6 +49,7 @@ export default Vue
'parameter', 'parameter',
'path', 'path',
'value', 'value',
'isSupportedByHttpRequestNode',
], ],
methods: { methods: {
getArgument (argumentName: string): string | number | boolean | undefined { getArgument (argumentName: string): string | number | boolean | undefined {

View file

@ -79,6 +79,7 @@
:path="getPath(parameter.name)" :path="getPath(parameter.name)"
:isReadOnly="isReadOnly" :isReadOnly="isReadOnly"
@valueChanged="valueChanged" @valueChanged="valueChanged"
:isSupportedByHttpRequestNode="isSupportedByHttpRequestNode"
/> />
</div> </div>
</div> </div>
@ -122,6 +123,7 @@ export default mixins(
'path', // string 'path', // string
'hideDelete', // boolean 'hideDelete', // boolean
'indent', 'indent',
'isSupportedByHttpRequestNode', // boolean
], ],
computed: { computed: {
filteredParameters (): INodeProperties[] { filteredParameters (): INodeProperties[] {