mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 03:42:16 +00:00
feat: Add global event bus (#4860)
* fix branch * fix deserialize, add filewriter * add catchAll eventGroup/Name * adding simple Redis sender and receiver to eventbus * remove native node threads * improve eventbus * refactor and simplify * more refactoring and syslog client * more refactor, improved endpoints and eventbus * remove local broker and receivers from mvp * destination de/serialization * create MessageEventBusDestinationEntity * db migrations, load destinations at startup * add delete destination endpoint * pnpm merge and circular import fix * delete destination fix * trigger log file shuffle after size reached * add environment variables for eventbus * reworking event messages * serialize to thread fix * some refactor and lint fixing * add emit to eventbus * cleanup and fix sending unsent * quicksave frontend trial * initial EventTree vue component * basic log streaming settings in vue * http request code merge * create destination settings modals * fix eventmessage options types * credentials are loaded * fix and clean up frontend code * move request code to axios * update lock file * merge fix * fix redis build * move destination interfaces into workflow pkg * revive sentry as destination * migration fixes and frontend cleanup * N8N-5777 / N8N-5789 N8N-5788 * N8N-5784 * N8N-5782 removed event levels * N8N-5790 sentry destination cleanup * N8N-5786 and refactoring * N8N-5809 and refactor/cleanup * UI fixes and anonymize renaming * N8N-5837 * N8N-5834 * fix no-items UI issues * remove card / settings label in modal * N8N-5842 fix * disable webhook auth for now and update ui * change sidebar to tabs * remove payload option * extend audit events with more user data * N8N-5853 and UI revert to sidebar * remove redis destination * N8N-5864 / N8N-5868 / N8N-5867 / N8N-5865 * ui and licensing fixes * add node events and info bubbles to frontend * ui wording changes * frontend tests * N8N-5896 and ee rename * improves backend tests * merge fix * fix backend test * make linter happy * remove unnecessary cfg / limit actions to owners * fix multiple sentry DSN and anon bug * eslint fix * more tests and fixes * merge fix * fix workflow audit events * remove 'n8n.workflow.execution.error' event * merge fix * lint fix * lint fix * review fixes * fix merge * prettier fixes * merge * review changes * use loggerproxy * remove catch from internal hook promises * fix tests * lint fix * include review PR changes * review changes * delete duplicate lines from a bad merge * decouple log-streaming UI options from public API * logstreaming -> log-streaming for consistency * do not make unnecessary api calls when log streaming is disabled * prevent sentryClient.close() from being called if init failed * fix the e2e test for log-streaming * review changes * cleanup * use `private` for one last private property * do not use node prefix package names.. just yet * remove unused import * fix the tests because there is a folder called `events`, tsc-alias is messing up all imports for native events module. https://github.com/justkey007/tsc-alias/issues/152 Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
committed by
GitHub
parent
0795cdb74c
commit
b67f803cbe
@@ -0,0 +1,207 @@
|
||||
<template>
|
||||
<n8n-card :class="$style.cardLink" data-test-id="destination-card" @click="onClick">
|
||||
<template #header>
|
||||
<div>
|
||||
<n8n-heading tag="h2" bold class="ph-no-capture" :class="$style.cardHeading">
|
||||
{{ destination.label }}
|
||||
</n8n-heading>
|
||||
<div :class="$style.cardDescription">
|
||||
<n8n-text color="text-light" size="small">
|
||||
<span>{{ $locale.baseText(typeLabelName) }}</span>
|
||||
</n8n-text>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #append>
|
||||
<div :class="$style.cardActions">
|
||||
<div :class="$style.activeStatusText" data-test-id="destination-activator-status">
|
||||
<n8n-text v-if="nodeParameters.enabled" :color="'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>
|
||||
|
||||
<el-switch
|
||||
class="mr-s"
|
||||
:disabled="!isInstanceOwner"
|
||||
:value="nodeParameters.enabled"
|
||||
@change="onEnabledSwitched($event, destination.id)"
|
||||
:title="
|
||||
nodeParameters.enabled
|
||||
? $locale.baseText('workflowActivator.deactivateWorkflow')
|
||||
: $locale.baseText('workflowActivator.activateWorkflow')
|
||||
"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#8899AA"
|
||||
element-loading-spinner="el-icon-loading"
|
||||
data-test-id="workflow-activate-switch"
|
||||
>
|
||||
</el-switch>
|
||||
|
||||
<n8n-action-toggle :actions="actions" theme="dark" @action="onAction" />
|
||||
</div>
|
||||
</template>
|
||||
</n8n-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import mixins from 'vue-typed-mixins';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { showMessage } from '@/mixins/showMessage';
|
||||
import { useLogStreamingStore } from '../../stores/logStreamingStore';
|
||||
import { restApi } from '@/mixins/restApi';
|
||||
import Vue from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import {
|
||||
deepCopy,
|
||||
defaultMessageEventBusDestinationOptions,
|
||||
MessageEventBusDestinationOptions,
|
||||
} from 'n8n-workflow';
|
||||
import { saveDestinationToDb } from './Helpers.ee';
|
||||
import { BaseTextKey } from '../../plugins/i18n';
|
||||
|
||||
export const DESTINATION_LIST_ITEM_ACTIONS = {
|
||||
OPEN: 'open',
|
||||
DELETE: 'delete',
|
||||
};
|
||||
|
||||
export default mixins(showMessage, restApi).extend({
|
||||
data() {
|
||||
return {
|
||||
EnterpriseEditionFeature,
|
||||
nodeParameters: {} as MessageEventBusDestinationOptions,
|
||||
};
|
||||
},
|
||||
components: {},
|
||||
props: {
|
||||
eventBus: {
|
||||
type: Vue,
|
||||
},
|
||||
destination: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: deepCopy(
|
||||
defaultMessageEventBusDestinationOptions,
|
||||
) as MessageEventBusDestinationOptions,
|
||||
},
|
||||
isInstanceOwner: Boolean,
|
||||
},
|
||||
mounted() {
|
||||
this.nodeParameters = Object.assign(
|
||||
deepCopy(defaultMessageEventBusDestinationOptions),
|
||||
this.destination,
|
||||
);
|
||||
this.eventBus.$on('destinationWasSaved', () => {
|
||||
const updatedDestination = this.logStreamingStore.getDestination(this.destination.id);
|
||||
if (updatedDestination) {
|
||||
this.nodeParameters = Object.assign(
|
||||
deepCopy(defaultMessageEventBusDestinationOptions),
|
||||
this.destination,
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useLogStreamingStore),
|
||||
actions(): Array<{ label: string; value: string }> {
|
||||
const actions = [
|
||||
{
|
||||
label: this.$locale.baseText('workflows.item.open'),
|
||||
value: DESTINATION_LIST_ITEM_ACTIONS.OPEN,
|
||||
},
|
||||
];
|
||||
if (this.isInstanceOwner) {
|
||||
actions.push({
|
||||
label: this.$locale.baseText('workflows.item.delete'),
|
||||
value: DESTINATION_LIST_ITEM_ACTIONS.DELETE,
|
||||
});
|
||||
}
|
||||
return actions;
|
||||
},
|
||||
typeLabelName(): BaseTextKey {
|
||||
return `settings.log-streaming.${this.destination.__type}` as BaseTextKey;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async onClick(event?: PointerEvent) {
|
||||
if (
|
||||
event &&
|
||||
event.target &&
|
||||
'className' in event.target &&
|
||||
event.target['className'] === 'el-switch__core'
|
||||
) {
|
||||
event.stopPropagation();
|
||||
} else {
|
||||
this.$emit('edit', this.destination.id);
|
||||
}
|
||||
},
|
||||
onEnabledSwitched(state: boolean, destinationId: string) {
|
||||
this.nodeParameters.enabled = state;
|
||||
this.saveDestination();
|
||||
},
|
||||
async saveDestination() {
|
||||
await saveDestinationToDb(this.restApi(), this.nodeParameters);
|
||||
},
|
||||
async onAction(action: string) {
|
||||
if (action === DESTINATION_LIST_ITEM_ACTIONS.OPEN) {
|
||||
this.$emit('edit', this.destination.id);
|
||||
} else if (action === DESTINATION_LIST_ITEM_ACTIONS.DELETE) {
|
||||
const deleteConfirmed = await this.confirmMessage(
|
||||
this.$locale.baseText('settings.log-streaming.destinationDelete.message', {
|
||||
interpolate: { destinationName: this.destination.label },
|
||||
}),
|
||||
this.$locale.baseText('settings.log-streaming.destinationDelete.headline'),
|
||||
'warning',
|
||||
this.$locale.baseText('settings.log-streaming.destinationDelete.confirmButtonText'),
|
||||
this.$locale.baseText('settings.log-streaming.destinationDelete.cancelButtonText'),
|
||||
);
|
||||
|
||||
if (deleteConfirmed === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit('remove', this.destination.id);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
.cardLink {
|
||||
transition: box-shadow 0.3s ease;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 2px 8px rgba(#441c17, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.cardHeading {
|
||||
font-size: var(--font-size-s);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.cardDescription {
|
||||
min-height: 19px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.cardActions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user