feat(editor): Implement folder move functionality (no-changelog) (#13922)

This commit is contained in:
Milorad FIlipović
2025-03-17 12:46:21 +01:00
committed by GitHub
parent 042aa39024
commit 1c17d12209
16 changed files with 733 additions and 97 deletions

View File

@@ -20,7 +20,7 @@ import TimeAgo from '@/components/TimeAgo.vue';
import { useProjectsStore } from '@/stores/projects.store';
import ProjectCardBadge from '@/components/Projects/ProjectCardBadge.vue';
import { useI18n } from '@/composables/useI18n';
import { useRouter } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { useTelemetry } from '@/composables/useTelemetry';
import { ResourceType } from '@/utils/projects.utils';
import type { EventBus } from '@n8n/utils/event-bus';
@@ -33,6 +33,7 @@ const WORKFLOW_LIST_ITEM_ACTIONS = {
DUPLICATE: 'duplicate',
DELETE: 'delete',
MOVE: 'move',
MOVE_TO_FOLDER: 'moveToFolder',
};
const props = withDefaults(
@@ -52,12 +53,14 @@ const emit = defineEmits<{
'click:tag': [tagId: string, e: PointerEvent];
'workflow:deleted': [];
'workflow:active-toggle': [value: { id: string; active: boolean }];
'action:move-to-folder': [value: { id: string; name: string; parentFolderId?: string }];
}>();
const toast = useToast();
const message = useMessage();
const locale = useI18n();
const router = useRouter();
const route = useRoute();
const telemetry = useTelemetry();
const settingsStore = useSettingsStore();
@@ -69,6 +72,11 @@ const projectsStore = useProjectsStore();
const resourceTypeLabel = computed(() => locale.baseText('generic.workflow').toLowerCase());
const currentUser = computed(() => usersStore.currentUser ?? ({} as IUser));
const workflowPermissions = computed(() => getResourcePermissions(props.data.scopes).workflow);
const showFolders = computed(() => {
return settingsStore.isFoldersFeatureEnabled && route.name !== VIEWS.WORKFLOWS;
});
const actions = computed(() => {
const items = [
{
@@ -88,6 +96,13 @@ const actions = computed(() => {
});
}
if (workflowPermissions.value.update && !props.readOnly && showFolders.value) {
items.push({
label: locale.baseText('folders.actions.moveToFolder'),
value: WORKFLOW_LIST_ITEM_ACTIONS.MOVE_TO_FOLDER,
});
}
if (workflowPermissions.value.move && projectsStore.isTeamProjectFeatureEnabled) {
items.push({
label: locale.baseText('workflows.item.changeOwner'),
@@ -175,6 +190,13 @@ async function onAction(action: string) {
case WORKFLOW_LIST_ITEM_ACTIONS.MOVE:
moveResource();
break;
case WORKFLOW_LIST_ITEM_ACTIONS.MOVE_TO_FOLDER:
emit('action:move-to-folder', {
id: props.data.id,
name: props.data.name,
parentFolderId: props.data.parentFolder?.id,
});
break;
}
}