fix i18n and such

This commit is contained in:
Mutasem 2022-01-18 11:11:46 +01:00
parent 686548cc28
commit 8f0db915cf
3 changed files with 38 additions and 34 deletions

View file

@ -39,7 +39,7 @@
import Vue from 'vue'; import Vue from 'vue';
import Modal from '@/components/Modal.vue'; import Modal from '@/components/Modal.vue';
import { WORKFLOW_ACTIVE_MODAL_KEY, EXECUTIONS_MODAL_KEY, WORKFLOW_SETTINGS_MODAL_KEY, LOCAL_STORAGE_ACTIVATION_FLAG } from '../constants'; import { WORKFLOW_ACTIVE_MODAL_KEY, EXECUTIONS_MODAL_KEY, WORKFLOW_SETTINGS_MODAL_KEY, LOCAL_STORAGE_ACTIVATION_FLAG, ERROR_TRIGGER_NODE_TYPE } from '../constants';
import { INodeUi } from '../Interface'; import { INodeUi } from '../Interface';
import { getTriggerNodeServiceName } from './helpers'; import { getTriggerNodeServiceName } from './helpers';
@ -73,14 +73,11 @@ export default Vue.extend({
triggerContent (): string { triggerContent (): string {
const foundTriggers = this.$store.getters.workflowTriggerNodes const foundTriggers = this.$store.getters.workflowTriggerNodes
.filter((node: INodeUi) => { .filter((node: INodeUi) => {
return !node.disabled; return !node.disabled && node.type !== ERROR_TRIGGER_NODE_TYPE;
})
.filter(({ type }: INodeUi) => {
return type !== 'n8n-nodes-base.errorTrigger';
}); });
// if multiple triggers
if (foundTriggers.length > 1) { if (foundTriggers.length > 1) {
return 'Your triggers will now fire production executions automatically.'; return this.$locale.baseText('activationModal.yourTriggersWillNowFire');
} }
const trigger = foundTriggers[0]; const trigger = foundTriggers[0];
const triggerNodeType = this.$store.getters.nodeType(trigger.type); const triggerNodeType = this.$store.getters.nodeType(trigger.type);
@ -89,15 +86,20 @@ export default Vue.extend({
return triggerNodeType.activationMessage; return triggerNodeType.activationMessage;
} }
const serviceName = getTriggerNodeServiceName(triggerNodeType.displayName); const serviceName = getTriggerNodeServiceName(triggerNodeType.displayName);
//check if webhook
if (trigger.webhookId) { if (trigger.webhookId) {
return `Your workflow will now listen for events from ${serviceName} and trigger executions.`; return this.$locale.baseText('activationModal.yourWorkflowWillNowListenForEvents', {
interpolate: {
serviceName,
},
});
} else if (triggerNodeType.polling) { } else if (triggerNodeType.polling) {
//check if a polling trigger return this.$locale.baseText('activationModal.yourWorkflowWillNowRegularlyCheck', {
return `Your workflow will now regularly check ${serviceName} for events and trigger executions for them.`; interpolate: {
serviceName,
},
});
} else { } else {
// default message return this.$locale.baseText('activationModal.yourTriggerWillNowFire');
return 'Your trigger will now fire production executions automatically.';
} }
}, },
}, },

View file

@ -103,25 +103,7 @@ export default mixins(
}, },
}, },
methods: { methods: {
async updateCurrentWorkflow(newActiveState: boolean) { async changeWorkflowActivationState(newActiveState: boolean) {
if (this.nodesIssuesExist === true) {
this.$showMessage({
title: this.$locale.baseText('workflowActivator.showMessage.activeChangedNodesIssuesExistTrue.title'),
message: this.$locale.baseText('workflowActivator.showMessage.activeChangedNodesIssuesExistTrue.message'),
type: 'error',
});
return;
}
await this.saveCurrentWorkflow({
active: newActiveState,
});
if (newActiveState && window.localStorage.getItem(LOCAL_STORAGE_ACTIVATION_FLAG) !== 'true') {
this.$store.dispatch('ui/openModal', WORKFLOW_ACTIVE_MODAL_KEY);
}
},
async activateOtherWorkflow(newActiveState: boolean) {
// Set that the active state should be changed // Set that the active state should be changed
const data: IWorkflowDataUpdate = {}; const data: IWorkflowDataUpdate = {};
data.active = newActiveState; data.active = newActiveState;
@ -134,6 +116,22 @@ export default mixins(
this.$store.commit('setWorkflowInactive', this.workflowId); this.$store.commit('setWorkflowInactive', this.workflowId);
} }
}, },
async updateCurrentWorkflow(newActiveState: boolean) {
if (this.nodesIssuesExist === true) {
this.$showMessage({
title: this.$locale.baseText('workflowActivator.showMessage.activeChangedNodesIssuesExistTrue.title'),
message: this.$locale.baseText('workflowActivator.showMessage.activeChangedNodesIssuesExistTrue.message'),
type: 'error',
});
return;
}
await this.saveCurrentWorkflow({active: newActiveState});
if (newActiveState && window.localStorage.getItem(LOCAL_STORAGE_ACTIVATION_FLAG) !== 'true') {
this.$store.dispatch('ui/openModal', WORKFLOW_ACTIVE_MODAL_KEY);
}
},
async activeChanged (newActiveState: boolean) { async activeChanged (newActiveState: boolean) {
this.loading = true; this.loading = true;
@ -142,7 +140,7 @@ export default mixins(
await this.updateCurrentWorkflow(newActiveState); await this.updateCurrentWorkflow(newActiveState);
} }
else { else {
await this.activateOtherWorkflow(newActiveState); await this.changeWorkflowActivationState(newActiveState);
} }
} catch (error) { } catch (error) {
const newStateName = newActiveState === true ? 'activated' : 'deactivated'; const newStateName = newActiveState === true ? 'activated' : 'deactivated';

View file

@ -1043,6 +1043,10 @@
"executionList": "execution list", "executionList": "execution list",
"ifYouChooseTo": "if you choose to", "ifYouChooseTo": "if you choose to",
"saveExecutions": "save executions.", "saveExecutions": "save executions.",
"dontShowAgain": "Don't show again" "dontShowAgain": "Don't show again",
"yourTriggersWillNowFire": "Your triggers will now fire production executions automatically.",
"yourTriggerWillNowFire": "Your trigger will now fire production executions automatically.",
"yourWorkflowWillNowRegularlyCheck": "Your workflow will now regularly check {serviceName} for events and trigger executions for them.",
"yourWorkflowWillNowListenForEvents": "Your workflow will now listen for events from ${serviceName} and trigger executions."
} }
} }