fix(editor): Fix type errors in TriggerPanel.vue (no-changelog) (#9578)

This commit is contained in:
Milorad FIlipović
2024-05-31 17:22:27 +02:00
committed by GitHub
parent 05f50c1926
commit 9419c28ff3
3 changed files with 60 additions and 60 deletions

View File

@@ -14,7 +14,7 @@
<n8n-text>
{{
$locale.baseText('ndv.trigger.webhookNode.requestHint', {
interpolate: { type: webhookHttpMethod },
interpolate: { type: webhookHttpMethod ?? '' },
})
}}
</n8n-text>
@@ -130,6 +130,7 @@ import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { createEventBus } from 'n8n-design-system/utils';
import { useRouter } from 'vue-router';
import { useWorkflowHelpers } from '@/composables/useWorkflowHelpers';
import { isTriggerPanelObject } from '@/utils/typeGuards';
export default defineComponent({
name: 'TriggerPanel',
@@ -141,11 +142,14 @@ export default defineComponent({
props: {
nodeName: {
type: String,
required: true,
},
pushRef: {
type: String,
default: '',
},
},
emits: { activate: null, execute: null },
setup() {
const router = useRouter();
const workflowHelpers = useWorkflowHelpers({ router });
@@ -162,7 +166,7 @@ export default defineComponent({
computed: {
...mapStores(useNodeTypesStore, useNDVStore, useUIStore, useWorkflowsStore),
node(): INodeUi | null {
return this.workflowsStore.getNodeByName(this.nodeName as string);
return this.workflowsStore.getNodeByName(this.nodeName);
},
nodeType(): INodeTypeDescription | null {
if (this.node) {
@@ -171,28 +175,26 @@ export default defineComponent({
return null;
},
triggerPanel() {
const panel = this.nodeType?.triggerPanel;
if (isTriggerPanelObject(panel)) {
return panel;
}
return undefined;
},
hideContent(): boolean {
if (!this.nodeType?.triggerPanel) {
return false;
const hideContent = this.triggerPanel?.hideContent;
if (typeof hideContent === 'boolean') {
return hideContent;
}
if (
this.nodeType?.triggerPanel &&
this.nodeType?.triggerPanel.hasOwnProperty('hideContent')
) {
const hideContent = this.nodeType?.triggerPanel.hideContent;
if (typeof hideContent === 'boolean') {
return hideContent;
}
if (this.node) {
const hideContentValue = this.workflowHelpers
.getCurrentWorkflow()
.expression.getSimpleParameterValue(this.node, hideContent, 'internal', {});
if (this.node) {
const hideContentValue = this.workflowHelpers
.getCurrentWorkflow()
.expression.getSimpleParameterValue(this.node, hideContent, 'internal', {});
if (typeof hideContentValue === 'boolean') {
return hideContentValue;
}
if (typeof hideContentValue === 'boolean') {
return hideContentValue;
}
}
@@ -200,7 +202,7 @@ export default defineComponent({
},
hasIssues(): boolean {
return Boolean(
this.node?.issues && (this.node.issues.parameters || this.node.issues.credentials),
this.node?.issues && (this.node.issues.parameters ?? this.node.issues.credentials),
);
},
serviceName(): string {
@@ -296,8 +298,8 @@ export default defineComponent({
return this.$locale.baseText('ndv.trigger.pollingNode.fetchingEvent');
}
if (this.nodeType?.triggerPanel && typeof this.nodeType.triggerPanel.header === 'string') {
return this.nodeType.triggerPanel.header;
if (this.triggerPanel?.header) {
return this.triggerPanel.header;
}
if (this.isWebhookBasedNode) {
@@ -319,15 +321,15 @@ export default defineComponent({
return '';
},
executionsHelp(): string {
if (this.nodeType?.triggerPanel?.executionsHelp !== undefined) {
if (typeof this.nodeType.triggerPanel.executionsHelp === 'string') {
return this.nodeType.triggerPanel.executionsHelp;
if (this.triggerPanel?.executionsHelp) {
if (typeof this.triggerPanel.executionsHelp === 'string') {
return this.triggerPanel.executionsHelp;
}
if (!this.isWorkflowActive && this.nodeType.triggerPanel.executionsHelp.inactive) {
return this.nodeType.triggerPanel.executionsHelp.inactive;
if (!this.isWorkflowActive && this.triggerPanel.executionsHelp.inactive) {
return this.triggerPanel.executionsHelp.inactive;
}
if (this.isWorkflowActive && this.nodeType.triggerPanel.executionsHelp.active) {
return this.nodeType.triggerPanel.executionsHelp.active;
if (this.isWorkflowActive && this.triggerPanel.executionsHelp.active) {
return this.triggerPanel.executionsHelp.active;
}
}
@@ -358,25 +360,22 @@ export default defineComponent({
return '';
},
activationHint(): string {
if (this.isActivelyPolling) {
if (this.isActivelyPolling || !this.triggerPanel) {
return '';
}
if (this.nodeType?.triggerPanel?.activationHint) {
if (typeof this.nodeType.triggerPanel.activationHint === 'string') {
return this.nodeType.triggerPanel.activationHint;
if (this.triggerPanel.activationHint) {
if (typeof this.triggerPanel.activationHint === 'string') {
return this.triggerPanel.activationHint;
}
if (
!this.isWorkflowActive &&
typeof this.nodeType.triggerPanel.activationHint.inactive === 'string'
typeof this.triggerPanel.activationHint.inactive === 'string'
) {
return this.nodeType.triggerPanel.activationHint.inactive;
return this.triggerPanel.activationHint.inactive;
}
if (
this.isWorkflowActive &&
typeof this.nodeType.triggerPanel.activationHint.active === 'string'
) {
return this.nodeType.triggerPanel.activationHint.active;
if (this.isWorkflowActive && typeof this.triggerPanel.activationHint.active === 'string') {
return this.triggerPanel.activationHint.active;
}
}