mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
40e413d958
* ✨ Added pinia support. Migrated community nodes module. * ✨ Added ui pinia store, moved some data from root store to it, updated modals to work with pinia stores * ✨ Added ui pinia store and migrated a part of the root store * ✨ Migrated `settings` store to pinia * ✨ Removing vuex store refs from router * ✨ Migrated `users` module to pinia store * ⚡ Fixing errors after sync with master * ⚡ One more error after merge * ⚡ Created `workflows` pinia store. Moved large part of root store to it. Started updating references. * ✨ Finished migrating workflows store to pinia * ⚡ Renaming some getters and actions to make more sense * ✨ Finished migrating the root store to pinia * ✨ Migrated ndv store to pinia * ⚡ Renaming main panel dimensions getter so it doesn't clash with data prop name * ✔️ Fixing lint errors * ✨ Migrated `templates` store to pinia * ✨ Migrated the `nodeTypes`store * ⚡ Removed unused pieces of code and oold vuex modules * ✨ Adding vuex calls to pinia store, fi xing wrong references * 💄 Removing leftover $store refs * ⚡ Added legacy getters and mutations to store to support webhooks * ⚡ Added missing front-end hooks, updated vuex state subscriptions to pinia * ✔️ Fixing linting errors * ⚡ Removing vue composition api plugin * ⚡ Fixing main sidebar state when loading node view * 🐛 Fixing an error when activating workflows * 🐛 Fixing isses with workflow settings and executions auto-refresh * 🐛 Removing duplicate listeners which cause import error * 🐛 Fixing route authentication * ⚡ Updating freshly pulled $store refs * Adding deleted const * ⚡ Updating store references in ee features. Reseting NodeView credentials update flag when resetting workspace * ⚡ Adding return type to email submission modal * ⚡ Making NodeView only react to paste event when active * 🐛 Fixing signup view errors * 👌 Addressing PR review comments * 👌 Addressing new PR comments * 👌 Updating invite id logic in signup view
155 lines
4.6 KiB
Vue
155 lines
4.6 KiB
Vue
<template>
|
|
<div class="workflow-activator">
|
|
<div :class="$style.activeStatusText">
|
|
<n8n-text v-if="workflowActive" :color="couldNotBeStarted ? 'danger' : 'success'" size="small" bold>
|
|
{{ $locale.baseText('workflowActivator.active') }}
|
|
</n8n-text>
|
|
<n8n-text v-else color="text-base" size="small" bold>
|
|
{{ $locale.baseText('workflowActivator.inactive') }}
|
|
</n8n-text>
|
|
</div>
|
|
<n8n-tooltip :disabled="!disabled" placement="bottom">
|
|
<div slot="content">{{ $locale.baseText('workflowActivator.thisWorkflowHasNoTriggerNodes') }}</div>
|
|
<el-switch
|
|
v-loading="updatingWorkflowActivation"
|
|
:value="workflowActive"
|
|
@change="activeChanged"
|
|
:title="workflowActive ? $locale.baseText('workflowActivator.deactivateWorkflow') : $locale.baseText('workflowActivator.activateWorkflow')"
|
|
:disabled="disabled || updatingWorkflowActivation"
|
|
:active-color="getActiveColor"
|
|
inactive-color="#8899AA"
|
|
element-loading-spinner="el-icon-loading">
|
|
</el-switch>
|
|
</n8n-tooltip>
|
|
|
|
<div class="could-not-be-started" v-if="couldNotBeStarted">
|
|
<n8n-tooltip placement="top">
|
|
<div @click="displayActivationError" slot="content" v-html="$locale.baseText('workflowActivator.theWorkflowIsSetToBeActiveBut')"></div>
|
|
<font-awesome-icon @click="displayActivationError" icon="exclamation-triangle" />
|
|
</n8n-tooltip>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { showMessage } from '@/components/mixins/showMessage';
|
|
import { workflowActivate } from '@/components/mixins/workflowActivate';
|
|
import { useUIStore } from '@/stores/ui';
|
|
import { useWorkflowsStore } from '@/stores/workflows';
|
|
import { mapStores } from 'pinia';
|
|
import mixins from 'vue-typed-mixins';
|
|
import { getActivatableTriggerNodes } from './helpers';
|
|
|
|
export default mixins(
|
|
showMessage,
|
|
workflowActivate,
|
|
)
|
|
.extend(
|
|
{
|
|
name: 'WorkflowActivator',
|
|
props: [
|
|
'workflowActive',
|
|
'workflowId',
|
|
],
|
|
computed: {
|
|
...mapStores(
|
|
useUIStore,
|
|
useWorkflowsStore,
|
|
),
|
|
getStateIsDirty (): boolean {
|
|
return this.uiStore.stateIsDirty;
|
|
},
|
|
nodesIssuesExist (): boolean {
|
|
return this.workflowsStore.nodesIssuesExist;
|
|
},
|
|
isWorkflowActive (): boolean {
|
|
const activeWorkflows = this.workflowsStore.activeWorkflows;
|
|
return activeWorkflows.includes(this.workflowId);
|
|
},
|
|
couldNotBeStarted (): boolean {
|
|
return this.workflowActive === true && this.isWorkflowActive !== this.workflowActive;
|
|
},
|
|
getActiveColor (): string {
|
|
if (this.couldNotBeStarted === true) {
|
|
return '#ff4949';
|
|
}
|
|
return '#13ce66';
|
|
},
|
|
isCurrentWorkflow(): boolean {
|
|
return this.workflowsStore.workflowId === this.workflowId;
|
|
},
|
|
disabled(): boolean {
|
|
const isNewWorkflow = !this.workflowId;
|
|
if (isNewWorkflow || this.isCurrentWorkflow) {
|
|
return !this.workflowActive && !this.containsTrigger;
|
|
}
|
|
|
|
return false;
|
|
},
|
|
containsTrigger(): boolean {
|
|
const foundTriggers = getActivatableTriggerNodes(this.workflowsStore.workflowTriggerNodes);
|
|
return foundTriggers.length > 0;
|
|
},
|
|
},
|
|
methods: {
|
|
async activeChanged (newActiveState: boolean) {
|
|
return this.updateWorkflowActivation(this.workflowId, newActiveState);
|
|
},
|
|
async displayActivationError () {
|
|
let errorMessage: string;
|
|
try {
|
|
const errorData = await this.restApi().getActivationError(this.workflowId);
|
|
|
|
if (errorData === undefined) {
|
|
errorMessage = this.$locale.baseText('workflowActivator.showMessage.displayActivationError.message.errorDataUndefined');
|
|
} else {
|
|
errorMessage = this.$locale.baseText(
|
|
'workflowActivator.showMessage.displayActivationError.message.errorDataNotUndefined',
|
|
{ interpolate: { message: errorData.error.message } },
|
|
);
|
|
}
|
|
} catch (error) {
|
|
errorMessage = this.$locale.baseText('workflowActivator.showMessage.displayActivationError.message.catchBlock');
|
|
}
|
|
|
|
this.$showMessage({
|
|
title: this.$locale.baseText('workflowActivator.showMessage.displayActivationError.title'),
|
|
message: errorMessage,
|
|
type: 'warning',
|
|
duration: 0,
|
|
});
|
|
},
|
|
},
|
|
},
|
|
);
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.activeStatusText {
|
|
width: 64px; // Required to avoid jumping when changing active state
|
|
padding-right: var(--spacing-2xs);
|
|
box-sizing: border-box;
|
|
display: inline-block;
|
|
text-align: right;
|
|
}
|
|
</style>
|
|
|
|
<style lang="scss" scoped>
|
|
.workflow-activator {
|
|
display: inline-flex;
|
|
flex-wrap: nowrap;
|
|
align-items: center;
|
|
}
|
|
|
|
.could-not-be-started {
|
|
display: inline-block;
|
|
color: #ff4949;
|
|
margin-left: 0.5em;
|
|
}
|
|
|
|
::v-deep .el-loading-spinner {
|
|
margin-top: -10px;
|
|
}
|
|
</style>
|