mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
refactor(editor): Migrate pushConnection mixin to composable and remove collaboration store side effects (no-changelog) (#9249)
This commit is contained in:
@@ -29,53 +29,36 @@ import type { ExecutionStatus } from 'n8n-workflow';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useOrchestrationStore } from '@/stores/orchestration.store';
|
||||
import { setPageTitle } from '@/utils/htmlUtils';
|
||||
import { pushConnection } from '@/mixins/pushConnection';
|
||||
import WorkerCard from './Workers/WorkerCard.ee.vue';
|
||||
import { usePushConnection } from '@/composables/usePushConnection';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { usePushConnectionStore } from '@/stores/pushConnection.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default defineComponent({
|
||||
name: 'WorkerList',
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/naming-convention
|
||||
components: { PushConnectionTracker, WorkerCard },
|
||||
mixins: [pushConnection],
|
||||
props: {
|
||||
autoRefreshEnabled: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
setup(props, ctx) {
|
||||
setup() {
|
||||
const router = useRouter();
|
||||
const i18n = useI18n();
|
||||
const pushConnection = usePushConnection({ router });
|
||||
|
||||
return {
|
||||
i18n,
|
||||
pushConnection,
|
||||
...useToast(),
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
...pushConnection.setup?.(props, ctx),
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
setPageTitle(`n8n - ${this.pageTitle}`);
|
||||
|
||||
this.$telemetry.track('User viewed worker view', {
|
||||
instance_id: this.rootStore.instanceId,
|
||||
});
|
||||
},
|
||||
beforeMount() {
|
||||
if (window.Cypress !== undefined) {
|
||||
return;
|
||||
}
|
||||
this.pushStore.pushConnect();
|
||||
this.orchestrationManagerStore.startWorkerStatusPolling();
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (window.Cypress !== undefined) {
|
||||
return;
|
||||
}
|
||||
this.orchestrationManagerStore.stopWorkerStatusPolling();
|
||||
this.pushStore.pushDisconnect();
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useUIStore, useOrchestrationStore),
|
||||
...mapStores(useRootStore, useUIStore, usePushConnectionStore, useOrchestrationStore),
|
||||
combinedWorkers(): IPushDataWorkerStatusPayload[] {
|
||||
const returnData: IPushDataWorkerStatusPayload[] = [];
|
||||
for (const workerId in this.orchestrationManagerStore.workers) {
|
||||
@@ -93,6 +76,31 @@ export default defineComponent({
|
||||
return this.i18n.baseText('workerList.pageTitle');
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
setPageTitle(`n8n - ${this.pageTitle}`);
|
||||
|
||||
this.$telemetry.track('User viewed worker view', {
|
||||
instance_id: this.rootStore.instanceId,
|
||||
});
|
||||
},
|
||||
beforeMount() {
|
||||
if (window.Cypress !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pushConnection.initialize();
|
||||
this.pushStore.pushConnect();
|
||||
this.orchestrationManagerStore.startWorkerStatusPolling();
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (window.Cypress !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.orchestrationManagerStore.stopWorkerStatusPolling();
|
||||
this.pushStore.pushDisconnect();
|
||||
this.pushConnection.terminate();
|
||||
},
|
||||
methods: {
|
||||
averageLoadAvg(loads: number[]) {
|
||||
return (loads.reduce((prev, curr) => prev + curr, 0) / loads.length).toFixed(2);
|
||||
|
||||
Reference in New Issue
Block a user