mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
Merge pull request #2951 from Lempkey/fix/company-prefix-export-import-links
fix: use prefix-aware Link for export/import on Company Settings page
This commit is contained in:
commit
3e0ab97b12
2 changed files with 30 additions and 4 deletions
|
|
@ -20,4 +20,29 @@ describe("company routes", () => {
|
|||
"/execution-workspaces/workspace-123",
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Regression tests for https://github.com/paperclipai/paperclip/issues/2910
|
||||
*
|
||||
* The Export and Import links on the Company Settings page used plain
|
||||
* `<a href="/company/export">` anchors which bypass the router's Link
|
||||
* wrapper. Without the wrapper, the company prefix is never applied and
|
||||
* the links resolve to `/company/export` instead of `/:prefix/company/export`,
|
||||
* producing a "Company not found" error.
|
||||
*
|
||||
* The fix replaces the `<a>` elements with the prefix-aware `<Link>` from
|
||||
* `@/lib/router`. These tests assert that the underlying `applyCompanyPrefix`
|
||||
* utility (used by that Link) correctly rewrites the export/import paths.
|
||||
*/
|
||||
it("applies company prefix to /company/export", () => {
|
||||
expect(applyCompanyPrefix("/company/export", "PAP")).toBe("/PAP/company/export");
|
||||
});
|
||||
|
||||
it("applies company prefix to /company/import", () => {
|
||||
expect(applyCompanyPrefix("/company/import", "PAP")).toBe("/PAP/company/import");
|
||||
});
|
||||
|
||||
it("does not double-apply the prefix if already present", () => {
|
||||
expect(applyCompanyPrefix("/PAP/company/export", "PAP")).toBe("/PAP/company/export");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ChangeEvent, useEffect, useState } from "react";
|
||||
import { Link } from "@/lib/router";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION } from "@paperclipai/shared";
|
||||
import { useCompany } from "../context/CompanyContext";
|
||||
|
|
@ -548,16 +549,16 @@ export function CompanySettings() {
|
|||
</p>
|
||||
<div className="mt-3 flex items-center gap-2">
|
||||
<Button size="sm" variant="outline" asChild>
|
||||
<a href="/company/export">
|
||||
<Link to="/company/export">
|
||||
<Download className="mr-1.5 h-3.5 w-3.5" />
|
||||
Export
|
||||
</a>
|
||||
</Link>
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" asChild>
|
||||
<a href="/company/import">
|
||||
<Link to="/company/import">
|
||||
<Upload className="mr-1.5 h-3.5 w-3.5" />
|
||||
Import
|
||||
</a>
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue