fix move and unnecessary pin node issue

This commit is contained in:
Kent Wang
2026-05-13 10:39:55 +08:00
parent 3817df41c4
commit 268d26eb56
3 changed files with 33 additions and 12 deletions

View File

@@ -51,14 +51,12 @@ export async function clientAction({ request }: Route.ClientActionArgs) {
},
syncNewWorkspaceIfNeeded,
});
return redirect(
`${href('/organization/:organizationId/project/:projectId/workspace/:workspaceId', {
organizationId: newOrgId,
projectId: newProjectId,
workspaceId: newWorkspace._id,
})}/${models.workspace.scopeToActivity(newWorkspace.scope)}`,
);
return {
organizationId: newOrgId,
projectId: newProjectId,
workspaceId: newWorkspace._id,
workspaceScope: newWorkspace.scope,
};
} catch (error) {
return {
error: 'Failed to duplicate workspace: ' + (error instanceof Error ? error.message : String(error)),

View File

@@ -1,6 +1,6 @@
import React, { type FC, type MouseEventHandler, useEffect, useRef, useState } from 'react';
import { OverlayContainer } from 'react-aria';
import { href, useParams } from 'react-router';
import { href, useNavigate, useParams } from 'react-router';
import type { BaseModel, Project, Workspace } from '~/insomnia-data';
import { models } from '~/insomnia-data';
@@ -32,6 +32,8 @@ export const WorkspaceDuplicateModal: FC<WorkspaceDuplicateModalProps> = ({ work
const [projectOptions, setProjectOptions] = useState<BaseModel[]>([]);
const [selectedProjectId, setSelectedProjectId] = useState('');
const [newWorkspaceName, setNewWorkspaceName] = useState(workspace.name);
const navigate = useNavigate();
useEffect(() => {
(async () => {
const organizationProjects = await database.find<Project>(models.project.type, {
@@ -48,6 +50,27 @@ export const WorkspaceDuplicateModal: FC<WorkspaceDuplicateModalProps> = ({ work
modalRef.current?.show();
}, []);
useEffect(() => {
const fetcherResult = fetcher.data;
if (
fetcherResult &&
!('error' in fetcherResult) &&
fetcherResult.workspaceId &&
fetcherResult.projectId &&
fetcherResult.organizationId &&
fetcherResult.workspaceScope
) {
navigate(
`${href('/organization/:organizationId/project/:projectId/workspace/:workspaceId', {
organizationId: fetcherResult.organizationId,
projectId: fetcherResult.projectId,
workspaceId: fetcherResult.workspaceId,
})}/${models.workspace.scopeToActivity(fetcherResult.workspaceScope)}`,
);
onHide();
}
}, [fetcher.data, navigate, onHide]);
const isBtnDisabled = fetcher.state !== 'idle' || !selectedProjectId || !newWorkspaceName;
return (

View File

@@ -350,8 +350,8 @@ export const ProjectNavigationSidebar = ({ storageRules, konnectSyncEnabled }: P
? getUnsyncedRemoteWorkspaces(unsyncedFilesByProjectId.get(projectId) || [], sortedWorkspaces)
: [];
const allWorkspaces = [...sortedWorkspaces, ...unsyncedWorkspaces];
// If there is no workspace under the project, show an empty workspace node
if (allWorkspaces.length === 0) {
// If there is no workspace under the project, show an empty workspace if no active filter
if (allWorkspaces.length === 0 && !projectNavigationSidebarFilter) {
items.push({
kind: 'emptyProject',
organizationId,
@@ -404,7 +404,7 @@ export const ProjectNavigationSidebar = ({ storageRules, konnectSyncEnabled }: P
collectionSortOrders[workspaceId] || 'type-manual',
)
: [];
const pinnedCollectionChildren = collectionChildren.filter(child => child.pinned);
const pinnedCollectionChildren = collectionChildren.filter(child => child.pinned && !child.hidden);
if (projectNavigationSidebarFilter) {
// apply filter to collection children first