Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/cli/src/workflows/workflow.service.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,14 @@ export class EnterpriseWorkflowService {
destinationParentFolderId?: string,
) {
// 1. get workflow
const workflow = await this.workflowFinderService.findWorkflowForUser(workflowId, user, [
'workflow:move',
]);
const workflow = await this.workflowFinderService.findWorkflowForUser(
workflowId,
user,
['workflow:move'],
{
includeParentFolder: true,
},
);
NotFoundError.isDefinedAndNotNull(
workflow,
`Could not find workflow with the id "${workflowId}". Make sure you have the permission to move it.`,
Expand Down Expand Up @@ -309,9 +314,12 @@ export class EnterpriseWorkflowService {
);

// 5. checks
if (sourceProject.id === destinationProject.id) {
if (
sourceProject.id === destinationProject.id &&
destinationParentFolderId === workflow.parentFolder?.id
) {
throw new TransferWorkflowError(
"You can't transfer a workflow into the project that's already owning it.",
"You can't transfer a workflow into the same destination it already belongs to.",
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,35 +274,6 @@ describe('WorkflowCard', () => {
expect(actions).not.toHaveTextContent('Move');
});

it("should not show 'Move' action on the 'Workflows' page", async () => {
vi.spyOn(settingsStore, 'isFoldersFeatureEnabled', 'get').mockReturnValue(true);

const data = createWorkflow({
scopes: ['workflow:update'],
});

vi.spyOn(vueRouter, 'useRoute').mockReturnValueOnce({
name: VIEWS.WORKFLOWS,
} as vueRouter.RouteLocationNormalizedLoadedGeneric);

const { getByTestId } = renderComponent({ props: { data } });
const cardActions = getByTestId('workflow-card-actions');

expect(cardActions).toBeInTheDocument();

const cardActionsOpener = within(cardActions).getByRole('button');
expect(cardActionsOpener).toBeInTheDocument();

const controllingId = cardActionsOpener.getAttribute('aria-controls');

await userEvent.click(cardActions);
const actions = document.querySelector<HTMLElement>(`#${controllingId}`);
if (!actions) {
throw new Error('Actions menu not found');
}
expect(actions).not.toHaveTextContent('Move');
});

it("should not show 'Move' action on read only instance", async () => {
vi.spyOn(projectsStore, 'isTeamProjectFeatureEnabled', 'get').mockReturnValue(true);
vi.spyOn(settingsStore, 'isFoldersFeatureEnabled', 'get').mockReturnValue(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const emit = defineEmits<{
name: string;
parentFolderId?: string;
sharedWithProjects?: ProjectSharingData[];
homeProjectId?: string;
},
];
}>();
Expand Down Expand Up @@ -135,10 +136,6 @@ const canCreateWorkflow = computed(
() => globalPermissions.value.create ?? projectPermissions.value.create,
);

const showFolders = computed(() => {
return props.areFoldersEnabled && route.name !== VIEWS.WORKFLOWS;
});

const showCardBreadcrumbs = computed(() => {
return props.showOwnershipBadge && !isSomeoneElsesWorkflow.value && cardBreadcrumbs.value.length;
});
Expand Down Expand Up @@ -197,9 +194,9 @@ const actions = computed(() => {
// TODO: add test to verify that moving a readonly card is not possible
if (
!props.readOnly &&
props.areFoldersEnabled &&
(workflowPermissions.value.update ||
(workflowPermissions.value.move && projectsStore.isTeamProjectFeatureEnabled)) &&
showFolders.value &&
route.name !== VIEWS.SHARED_WORKFLOWS
) {
items.push({
Expand Down Expand Up @@ -346,6 +343,7 @@ async function onAction(action: string) {
name: props.data.name,
parentFolderId: props.data.parentFolder?.id,
sharedWithProjects: props.data.sharedWithProjects,
homeProjectId: props.data.homeProject?.id,
});
break;
case WORKFLOW_LIST_ITEM_ACTIONS.ENABLE_MCP_ACCESS:
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/editor-ui/src/app/stores/ui.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ export const useUIStore = defineStore(STORES.UI, () => {
name: string;
parentFolderId?: string;
sharedWithProjects?: ProjectSharingData[];
homeProjectId?: string;
},
workflowListEventBus: EventBus,
) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/editor-ui/src/app/views/WorkflowsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,7 @@ const moveWorkflowToFolder = async (payload: {
name: string;
parentFolderId?: string;
sharedWithProjects?: ProjectSharingData[];
homeProjectId?: string;
}) => {
if (showRegisteredCommunityCTA.value) {
uiStore.openModalWithData({
Expand All @@ -1613,6 +1614,7 @@ const moveWorkflowToFolder = async (payload: {
name: payload.name,
parentFolderId: payload.parentFolderId,
sharedWithProjects: payload.sharedWithProjects,
homeProjectId: payload.homeProjectId,
},
workflowListEventBus,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const homeProject = createProjectSharingData();
const enableSharing = {
enterprise: {
sharing: true,
projects: { team: { limit: -1 } },
},
} as FrontendSettings;

Expand Down Expand Up @@ -152,7 +153,9 @@ describe('MoveToFolderModal', () => {

settingsStore = mockedStore(useSettingsStore);
settingsStore.settings = {
enterprise: {},
enterprise: {
projects: { team: { limit: -1 } },
},
} as FrontendSettings;

credentialsStore = mockedStore(useCredentialsStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Props = {
name: string;
parentFolderId?: string;
sharedWithProjects?: ProjectSharingData[];
homeProjectId?: string;
};
workflowListEventBus: EventBus;
};
Expand Down Expand Up @@ -317,7 +318,15 @@ const isFolderSelectable = computed(() => {
return isOwnPersonalProject.value || !isPersonalProject.value;
});

// If there is not current project (e.g. on the Overview page), default to the resource's home project
const currentResourceProjectId = computed(() => {
return projectsStore.currentProject?.id ?? props.data.resource.homeProjectId;
});

onMounted(async () => {
if (!projectsStore.isTeamProjectFeatureEnabled) {
selectedProject.value = projectsStore.personalProject;
}
if (isResourceWorkflow.value) {
const [workflow, credentials] = await Promise.all([
workflowsStore.fetchWorkflow(props.data.resource.id),
Expand Down Expand Up @@ -407,7 +416,7 @@ onMounted(async () => {
ref="moveToFolderDropdown"
:selected-location="selectedFolder"
:selected-project-id="selectedProject.id"
:current-project-id="projectsStore.currentProject?.id"
:current-project-id="currentResourceProjectId"
:current-folder-id="currentFolder?.id"
:parent-folder-id="props.data.resource.parentFolderId"
:exclude-only-parent="props.data.resourceType === 'workflow'"
Expand Down
Loading