From ff0955c995578abd4106274a9314a7a7a0e9a597 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Fri, 3 May 2024 10:26:15 +0300 Subject: [PATCH 1/7] refactor(editor): Migrate `pushConnection` mixin to composable and remove collaboration store side effects (no-changelog) (#9249) --- packages/editor-ui/src/Interface.ts | 32 +- .../MainHeader/CollaborationPane.vue | 2 + .../src/components/MainHeader/MainHeader.vue | 22 +- .../src/components/WorkerList.ee.vue | 56 +- .../src/composables/usePushConnection.spec.ts | 123 ++++ .../src/composables/usePushConnection.ts | 632 +++++++++++++++++ .../editor-ui/src/mixins/pushConnection.ts | 637 ------------------ .../src/stores/collaboration.store.ts | 43 +- .../src/stores/pushConnection.store.ts | 1 + packages/editor-ui/src/types/index.ts | 1 + .../editor-ui/src/types/pushConnection.ts | 6 + packages/editor-ui/src/views/NodeView.vue | 3 + .../src/views/SettingsCommunityNodesView.vue | 21 +- 13 files changed, 874 insertions(+), 705 deletions(-) create mode 100644 packages/editor-ui/src/composables/usePushConnection.spec.ts create mode 100644 packages/editor-ui/src/composables/usePushConnection.ts delete mode 100644 packages/editor-ui/src/mixins/pushConnection.ts create mode 100644 packages/editor-ui/src/types/pushConnection.ts diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 1818b22776683..67a4053308199 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -447,6 +447,7 @@ export type IPushData = | PushDataExecutionStarted | PushDataExecuteAfter | PushDataExecuteBefore + | PushDataNodeDescriptionUpdated | PushDataConsoleMessage | PushDataReloadNodeType | PushDataRemoveNodeType @@ -458,67 +459,72 @@ export type IPushData = | PushDataWorkflowFailedToActivate | PushDataWorkflowUsersChanged; -type PushDataActiveWorkflowAdded = { +export type PushDataActiveWorkflowAdded = { data: IActiveWorkflowAdded; type: 'workflowActivated'; }; -type PushDataActiveWorkflowRemoved = { +export type PushDataActiveWorkflowRemoved = { data: IActiveWorkflowRemoved; type: 'workflowDeactivated'; }; -type PushDataWorkflowFailedToActivate = { +export type PushDataWorkflowFailedToActivate = { data: IWorkflowFailedToActivate; type: 'workflowFailedToActivate'; }; -type PushDataExecutionRecovered = { +export type PushDataExecutionRecovered = { data: IPushDataExecutionRecovered; type: 'executionRecovered'; }; -type PushDataExecutionFinished = { +export type PushDataExecutionFinished = { data: IPushDataExecutionFinished; type: 'executionFinished'; }; -type PushDataExecutionStarted = { +export type PushDataExecutionStarted = { data: IPushDataExecutionStarted; type: 'executionStarted'; }; -type PushDataExecuteAfter = { +export type PushDataExecuteAfter = { data: IPushDataNodeExecuteAfter; type: 'nodeExecuteAfter'; }; -type PushDataExecuteBefore = { +export type PushDataExecuteBefore = { data: IPushDataNodeExecuteBefore; type: 'nodeExecuteBefore'; }; -type PushDataConsoleMessage = { +export type PushDataNodeDescriptionUpdated = { + data: {}; + type: 'nodeDescriptionUpdated'; +}; + +export type PushDataConsoleMessage = { data: IPushDataConsoleMessage; type: 'sendConsoleMessage'; }; -type PushDataReloadNodeType = { +export type PushDataReloadNodeType = { data: IPushDataReloadNodeType; type: 'reloadNodeType'; }; -type PushDataRemoveNodeType = { +export type PushDataRemoveNodeType = { data: IPushDataRemoveNodeType; type: 'removeNodeType'; }; -type PushDataTestWebhook = { +export type PushDataTestWebhook = { data: IPushDataTestWebhook; type: 'testWebhookDeleted' | 'testWebhookReceived'; }; -type PushDataWorkerStatusMessage = { +export type PushDataWorkerStatusMessage = { data: IPushDataWorkerStatusMessage; type: 'sendWorkerStatusMessage'; }; diff --git a/packages/editor-ui/src/components/MainHeader/CollaborationPane.vue b/packages/editor-ui/src/components/MainHeader/CollaborationPane.vue index 31d387b3dbe46..daabc0a1780bc 100644 --- a/packages/editor-ui/src/components/MainHeader/CollaborationPane.vue +++ b/packages/editor-ui/src/components/MainHeader/CollaborationPane.vue @@ -54,6 +54,7 @@ const onDocumentVisibilityChange = () => { }; onMounted(() => { + collaborationStore.initialize(); startHeartbeat(); document.addEventListener('visibilitychange', onDocumentVisibilityChange); }); @@ -61,6 +62,7 @@ onMounted(() => { onBeforeUnmount(() => { document.removeEventListener('visibilitychange', onDocumentVisibilityChange); stopHeartbeat(); + collaborationStore.terminate(); }); diff --git a/packages/editor-ui/src/components/MainHeader/MainHeader.vue b/packages/editor-ui/src/components/MainHeader/MainHeader.vue index c0e70681402a7..ed7b43715e910 100644 --- a/packages/editor-ui/src/components/MainHeader/MainHeader.vue +++ b/packages/editor-ui/src/components/MainHeader/MainHeader.vue @@ -16,9 +16,9 @@