mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(editor): Fix new, unsaved workflow sharing (#16740)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, watch, onMounted, ref } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { createEventBus } from '@n8n/utils/event-bus';
|
||||
|
||||
import Modal from './Modal.vue';
|
||||
import {
|
||||
EnterpriseEditionFeature,
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
import { getResourcePermissions } from '@n8n/permissions';
|
||||
import { useMessage } from '@/composables/useMessage';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { nodeViewEventBus } from '@/event-bus';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
@@ -28,6 +27,7 @@ import { useRolesStore } from '@/stores/roles.store';
|
||||
import { usePageRedirectionHelper } from '@/composables/usePageRedirectionHelper';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { telemetry } from '@/plugins/telemetry';
|
||||
import { useWorkflowSaving } from '@/composables/useWorkflowSaving';
|
||||
|
||||
const props = defineProps<{
|
||||
data: {
|
||||
@@ -49,6 +49,9 @@ const toast = useToast();
|
||||
const message = useMessage();
|
||||
const pageRedirectionHelper = usePageRedirectionHelper();
|
||||
const i18n = useI18n();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const workflowSaving = useWorkflowSaving({ router });
|
||||
|
||||
const workflow = ref(
|
||||
data.id === PLACEHOLDER_EMPTY_WORKFLOW_ID
|
||||
@@ -141,15 +144,16 @@ const onSave = async () => {
|
||||
loading.value = true;
|
||||
|
||||
const saveWorkflowPromise = async () => {
|
||||
return await new Promise<string>((resolve) => {
|
||||
if (workflow.value.id === PLACEHOLDER_EMPTY_WORKFLOW_ID) {
|
||||
nodeViewEventBus.emit('saveWorkflow', () => {
|
||||
resolve(workflow.value.id);
|
||||
});
|
||||
} else {
|
||||
resolve(workflow.value.id);
|
||||
if (workflow.value.id === PLACEHOLDER_EMPTY_WORKFLOW_ID) {
|
||||
const parentFolderId = route.query.folderId as string | undefined;
|
||||
const workflowId = await workflowSaving.saveAsNewWorkflow({ parentFolderId });
|
||||
if (!workflowId) {
|
||||
throw new Error(i18n.baseText('workflows.shareModal.onSave.error.title'));
|
||||
}
|
||||
});
|
||||
return workflowId;
|
||||
} else {
|
||||
return workflow.value.id;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user