diff --git a/packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.move.tsx b/packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.move.tsx index f70dd75393..8fa3bffd5b 100644 --- a/packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.move.tsx +++ b/packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.move.tsx @@ -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)), diff --git a/packages/insomnia/src/ui/components/modals/workspace-duplicate-modal.tsx b/packages/insomnia/src/ui/components/modals/workspace-duplicate-modal.tsx index 863954df37..7569605c70 100644 --- a/packages/insomnia/src/ui/components/modals/workspace-duplicate-modal.tsx +++ b/packages/insomnia/src/ui/components/modals/workspace-duplicate-modal.tsx @@ -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 = ({ work const [projectOptions, setProjectOptions] = useState([]); const [selectedProjectId, setSelectedProjectId] = useState(''); const [newWorkspaceName, setNewWorkspaceName] = useState(workspace.name); + const navigate = useNavigate(); + useEffect(() => { (async () => { const organizationProjects = await database.find(models.project.type, { @@ -48,6 +50,27 @@ export const WorkspaceDuplicateModal: FC = ({ 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 ( diff --git a/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/project-navigation-sidebar.tsx b/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/project-navigation-sidebar.tsx index a0596e3980..add1803e71 100644 --- a/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/project-navigation-sidebar.tsx +++ b/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/project-navigation-sidebar.tsx @@ -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