diff --git a/ui/src/lib/company-routes.test.ts b/ui/src/lib/company-routes.test.ts index 0c0b1be277..cce73805ea 100644 --- a/ui/src/lib/company-routes.test.ts +++ b/ui/src/lib/company-routes.test.ts @@ -36,6 +36,25 @@ describe("company routes", () => { expect(toCompanyRelativePath("/PAP/search?q=foo")).toBe("/search?q=foo"); }); + it("rewrites company package paths with the active prefix", () => { + expect(applyCompanyPrefix("/company/export", "NEU")).toBe("/NEU/company/export"); + expect(applyCompanyPrefix("/company/import", "NEU")).toBe("/NEU/company/import"); + expect(applyCompanyPrefix("/company/settings/cloud-upstream", "NEU")).toBe( + "/NEU/company/settings/cloud-upstream", + ); + expect(applyCompanyPrefix("/org", "NEU")).toBe("/NEU/org"); + }); + + it("does not double-apply the company prefix", () => { + expect(applyCompanyPrefix("/NEU/company/export", "NEU")).toBe("/NEU/company/export"); + }); + + it("normalizes prefixed company export file URLs for parsing", () => { + expect(toCompanyRelativePath("/NEU/company/export/files/agents/ceo/AGENTS.md")).toBe( + "/company/export/files/agents/ceo/AGENTS.md", + ); + }); + // Regression for PAP-10257: Team Catalog navigation (auto-select + row/file // clicks) produces company-relative `/teams-catalog/` paths. Without // `teams-catalog` in the board-route allowlist, `extractCompanyPrefixFromPath` diff --git a/ui/src/pages/CompanyExport.tsx b/ui/src/pages/CompanyExport.tsx index 7bca198761..bad6bc3dce 100644 --- a/ui/src/pages/CompanyExport.tsx +++ b/ui/src/pages/CompanyExport.tsx @@ -20,6 +20,7 @@ import { Button } from "@/components/ui/button"; import { EmptyState } from "../components/EmptyState"; import { PageSkeleton } from "../components/PageSkeleton"; import { MarkdownBody } from "../components/MarkdownBody"; +import { toCompanyRelativePath } from "@/lib/company-routes"; import { cn } from "../lib/utils"; import { queryKeys } from "../lib/queryKeys"; import { createZipArchive } from "../lib/zip"; @@ -559,9 +560,10 @@ function ExportPreviewPane({ /** Extract the file path from the current URL pathname (after /company/export/files/) */ function filePathFromLocation(pathname: string): string | null { const marker = "/company/export/files/"; - const idx = pathname.indexOf(marker); + const relativePathname = toCompanyRelativePath(pathname); + const idx = relativePathname.indexOf(marker); if (idx === -1) return null; - const filePath = decodeURIComponent(pathname.slice(idx + marker.length)); + const filePath = decodeURIComponent(relativePathname.slice(idx + marker.length)); return filePath || null; } diff --git a/ui/src/pages/CompanySettings.tsx b/ui/src/pages/CompanySettings.tsx index a174b63366..25862d5e8d 100644 --- a/ui/src/pages/CompanySettings.tsx +++ b/ui/src/pages/CompanySettings.tsx @@ -10,6 +10,7 @@ import { companiesApi } from "../api/companies"; import { assetsApi } from "../api/assets"; import { instanceSettingsApi } from "../api/instanceSettings"; import { queryKeys } from "../lib/queryKeys"; +import { Link } from "@/lib/router"; import { Button } from "@/components/ui/button"; import { Settings, CloudUpload, Download, Upload } from "lucide-react"; import { CompanyPatternIcon } from "../components/CompanyPatternIcon"; @@ -374,28 +375,28 @@ export function CompanySettings() {

Import and export have moved to dedicated pages accessible from the{" "} - Org Chart header. + Org Chart header.

{cloudSyncEnabled ? ( ) : null}