From 59db96771e1a773aea0af7e1840e1766deda67c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Mon, 24 Apr 2023 10:50:49 +0200 Subject: [PATCH] refactor(editor): Remove the `restApi` mixin (#6065) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Removing the `makeApiRequest` method from `restAPI` mixin, removing the mixing from the App component * ✨ Removing `restApi` mixin * 👕 Fixing lint errors * ✔️ Fixing execution list unit tests and merge bug in workflowRun mixin * 🐛 Added missing useStore --- packages/editor-ui/src/App.vue | 3 +- packages/editor-ui/src/Interface.ts | 37 - .../src/components/BinaryDataDisplay.vue | 3 +- .../src/components/BinaryDataDisplayEmbed.vue | 12 +- .../CredentialEdit/CredentialConfig.vue | 13 +- .../components/DuplicateWorkflowDialog.vue | 8 +- .../src/components/ExecutionsList.vue | 1175 ++++++++--------- .../ExecutionsView/ExecutionCard.vue | 3 +- .../ExecutionsView/ExecutionPreview.vue | 4 +- .../ExecutionsView/ExecutionsList.vue | 24 +- .../components/MainHeader/WorkflowDetails.vue | 2 +- .../editor-ui/src/components/MainSidebar.vue | 2 - .../src/components/NodeCredentials.vue | 3 +- .../src/components/NodeExecuteButton.vue | 2 +- packages/editor-ui/src/components/RunData.vue | 2 +- .../components/UserActivationSurveyModal.vue | 2 +- .../src/components/WorkflowActivator.vue | 2 +- .../editor-ui/src/components/WorkflowCard.vue | 5 +- .../src/components/WorkflowSettings.vue | 9 +- .../src/components/WorkflowShareModal.ee.vue | 2 +- .../__tests__/ExecutionsList.test.ts | 47 +- packages/editor-ui/src/mixins/nodeHelpers.ts | 6 +- .../editor-ui/src/mixins/workflowHelpers.ts | 13 +- packages/editor-ui/src/mixins/workflowRun.ts | 5 +- packages/editor-ui/src/stores/credentials.ts | 12 +- packages/editor-ui/src/stores/settings.ts | 5 + packages/editor-ui/src/stores/workflows.ts | 183 ++- packages/editor-ui/src/utils/apiUtils.ts | 32 +- packages/editor-ui/src/views/NodeView.vue | 17 +- packages/editor-ui/src/views/SetupView.vue | 6 +- 30 files changed, 905 insertions(+), 734 deletions(-) diff --git a/packages/editor-ui/src/App.vue b/packages/editor-ui/src/App.vue index b5baefe067..2d1e09cf36 100644 --- a/packages/editor-ui/src/App.vue +++ b/packages/editor-ui/src/App.vue @@ -37,7 +37,6 @@ import { showMessage } from '@/mixins/showMessage'; import { userHelpers } from '@/mixins/userHelpers'; import { loadLanguage } from './plugins/i18n'; import useGlobalLinkActions from '@/composables/useGlobalLinkActions'; -import { restApi } from '@/mixins/restApi'; import { mapStores } from 'pinia'; import { useUIStore } from './stores/ui'; import { useSettingsStore } from './stores/settings'; @@ -49,7 +48,7 @@ import { useHistoryHelper } from '@/composables/useHistoryHelper'; import { newVersions } from '@/mixins/newVersions'; import { useRoute } from 'vue-router/composables'; -export default mixins(newVersions, showMessage, userHelpers, restApi).extend({ +export default mixins(newVersions, showMessage, userHelpers).extend({ name: 'App', components: { LoadingView, diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 9edcf0e76a..5bc452c578 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -139,43 +139,6 @@ export interface IExternalHooks { run(eventName: string, metadata?: IDataObject): Promise; } -/** - * @deprecated Do not add methods to this interface. - */ -export interface IRestApi { - getActiveWorkflows(): Promise; - getActivationError(id: string): Promise; - getCurrentExecutions(filter: ExecutionsQueryFilter): Promise; - getPastExecutions( - filter: ExecutionsQueryFilter, - limit: number, - lastId?: string, - firstId?: string, - ): Promise; - stopCurrentExecution(executionId: string): Promise; - makeRestApiRequest(method: string, endpoint: string, data?: any): Promise; - getCredentialTranslation(credentialType: string): Promise; - removeTestWebhook(workflowId: string): Promise; - runWorkflow(runData: IStartRunData): Promise; - createNewWorkflow(sendData: IWorkflowDataUpdate): Promise; - updateWorkflow(id: string, data: IWorkflowDataUpdate, forceSave?: boolean): Promise; - deleteWorkflow(name: string): Promise; - getWorkflow(id: string): Promise; - getWorkflows(filter?: object): Promise; - getWorkflowFromUrl(url: string): Promise; - getExecution(id: string): Promise; - deleteExecutions(sendData: IExecutionDeleteFilter): Promise; - retryExecution(id: string, loadWorkflow?: boolean): Promise; - getTimezones(): Promise; - getBinaryUrl( - dataPath: string, - mode: 'view' | 'download', - fileName?: string, - mimeType?: string, - ): string; - getExecutionEvents(id: string): Promise; -} - export interface INodeTranslationHeaders { data: { [key: string]: { diff --git a/packages/editor-ui/src/components/BinaryDataDisplay.vue b/packages/editor-ui/src/components/BinaryDataDisplay.vue index c1f5b71355..4129fbe580 100644 --- a/packages/editor-ui/src/components/BinaryDataDisplay.vue +++ b/packages/editor-ui/src/components/BinaryDataDisplay.vue @@ -26,11 +26,10 @@ import BinaryDataDisplayEmbed from '@/components/BinaryDataDisplayEmbed.vue'; import { nodeHelpers } from '@/mixins/nodeHelpers'; import mixins from 'vue-typed-mixins'; -import { restApi } from '@/mixins/restApi'; import { mapStores } from 'pinia'; import { useWorkflowsStore } from '@/stores/workflows'; -export default mixins(nodeHelpers, restApi).extend({ +export default mixins(nodeHelpers).extend({ name: 'BinaryDataDisplay', components: { BinaryDataDisplayEmbed, diff --git a/packages/editor-ui/src/components/BinaryDataDisplayEmbed.vue b/packages/editor-ui/src/components/BinaryDataDisplayEmbed.vue index 04fbde24a6..8bfc988974 100644 --- a/packages/editor-ui/src/components/BinaryDataDisplayEmbed.vue +++ b/packages/editor-ui/src/components/BinaryDataDisplayEmbed.vue @@ -19,13 +19,14 @@