mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Hide params during custom action
This commit is contained in:
parent
ba9c85e131
commit
216d2e0379
|
@ -60,7 +60,7 @@
|
||||||
</n8n-text>
|
</n8n-text>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="customActionSelected" class="parameter-item parameter-notice">
|
<div v-if="isCustomActionSelected(nodeValues)" class="parameter-item parameter-notice">
|
||||||
<n8n-notice
|
<n8n-notice
|
||||||
:content="$locale.baseText(
|
:content="$locale.baseText(
|
||||||
'nodeSettings.useTheHttpRequestNode',
|
'nodeSettings.useTheHttpRequestNode',
|
||||||
|
@ -132,18 +132,6 @@ export default mixins(
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('credentials', [ 'getCredentialTypeByName' ]),
|
...mapGetters('credentials', [ 'getCredentialTypeByName' ]),
|
||||||
customActionSelected (): boolean {
|
|
||||||
return (
|
|
||||||
this.nodeValues.parameters !== undefined &&
|
|
||||||
typeof this.nodeValues.parameters === 'object' &&
|
|
||||||
this.nodeValues.parameters !== null &&
|
|
||||||
!Array.isArray(this.nodeValues.parameters) &&
|
|
||||||
(
|
|
||||||
this.nodeValues.parameters.resource === 'customAction' ||
|
|
||||||
this.nodeValues.parameters.operation === 'customAction'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
nodeType (): INodeTypeDescription | null {
|
nodeType (): INodeTypeDescription | null {
|
||||||
if (this.node) {
|
if (this.node) {
|
||||||
return this.$store.getters.nodeType(this.node.type, this.node.typeVersion);
|
return this.$store.getters.nodeType(this.node.type, this.node.typeVersion);
|
||||||
|
|
|
@ -178,6 +178,13 @@ export default mixins(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.isCustomActionSelected(this.nodeValues) &&
|
||||||
|
this.mustHideDuringCustomAction(parameter, this.nodeValues)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (parameter.displayOptions === undefined) {
|
if (parameter.displayOptions === undefined) {
|
||||||
// If it is not defined no need to do a proper check
|
// If it is not defined no need to do a proper check
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -47,6 +47,23 @@ export const nodeHelpers = mixins(
|
||||||
return node.type === HTTP_REQUEST_NODE_TYPE && node.typeVersion === 2;
|
return node.type === HTTP_REQUEST_NODE_TYPE && node.typeVersion === 2;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isCustomActionSelected (nodeValues: INodeParameters): boolean {
|
||||||
|
const { parameters } = nodeValues;
|
||||||
|
|
||||||
|
return (
|
||||||
|
isObjectLiteral(parameters) &&
|
||||||
|
(parameters.resource === 'customAction' || parameters.operation === 'customAction')
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
mustHideDuringCustomAction (parameter: INodeProperties, nodeValues: INodeParameters): boolean {
|
||||||
|
if (parameter && parameter.displayOptions && parameter.displayOptions.hide) return true;
|
||||||
|
|
||||||
|
const MUST_REMAIN_VISIBLE = ['authentication', 'resource', 'operation', ...Object.keys(nodeValues)];
|
||||||
|
|
||||||
|
return !MUST_REMAIN_VISIBLE.includes(parameter.name);
|
||||||
|
},
|
||||||
|
|
||||||
// Returns the parameter value
|
// Returns the parameter value
|
||||||
getParameterValue (nodeValues: INodeParameters, parameterName: string, path: string) {
|
getParameterValue (nodeValues: INodeParameters, parameterName: string, path: string) {
|
||||||
return get(
|
return get(
|
||||||
|
@ -57,6 +74,9 @@ export const nodeHelpers = mixins(
|
||||||
|
|
||||||
// Returns if the given parameter should be displayed or not
|
// Returns if the given parameter should be displayed or not
|
||||||
displayParameter (nodeValues: INodeParameters, parameter: INodeProperties | INodeCredentialDescription, path: string, node: INodeUi | null) {
|
displayParameter (nodeValues: INodeParameters, parameter: INodeProperties | INodeCredentialDescription, path: string, node: INodeUi | null) {
|
||||||
|
// TODO: If enabled, cannot select operation // If disabled (per original), cannot hide displayOptions.hide
|
||||||
|
// if (this.isCustomActionSelected(nodeValues)) return false;
|
||||||
|
|
||||||
return NodeHelpers.displayParameterPath(nodeValues, parameter, path, node);
|
return NodeHelpers.displayParameterPath(nodeValues, parameter, path, node);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -495,3 +515,7 @@ declare namespace HttpRequestNode {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isObjectLiteral(maybeObject: unknown): maybeObject is { [key: string]: string } {
|
||||||
|
return typeof maybeObject === 'object' && maybeObject !== null && !Array.isArray(maybeObject);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue