refactor(admin): remove sidebar favorites
This commit is contained in:
1 parent
a070004e7b
commit
96234075f8
7 files changed
+1
-152
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { ADMIN_NAV_GROUPS } from "@/lib/admin-nav";
|
||||
import { parseFavoritePages, visibleAdminNavigation } from "./admin-navigation";
|
||||
import { visibleAdminNavigation } from "./admin-navigation";
|
||||
|
||||
const access = { isSuperAdmin: true, allowedPermissions: [], navConfig: {} };
|
||||
it("retains each route and its permission definition once after regrouping", () => {
|
||||
@@ -36,11 +36,3 @@ it("respects hidden groups, owner order and ACL in every consumer", () => {
|
||||
}).flatMap((g) => g.items);
|
||||
expect(limited.every((i) => !i.permission)).toBe(true);
|
||||
});
|
||||
it("rejects malformed favorites, external links and duplicates", () => {
|
||||
expect(parseFavoritePages("{")).toEqual([]);
|
||||
expect(
|
||||
parseFavoritePages(
|
||||
'["/admin/users","https://evil.test","/admin/users",null,"/admin?token=x"]',
|
||||
),
|
||||
).toEqual(["/admin/users"]);
|
||||
});
|
||||
@@ -159,22 +159,3 @@ export function visibleAdminNavigation(
|
||||
});
|
||||
return organized;
|
||||
}
|
||||
|
||||
export function parseFavoritePages(raw: string | null): string[] {
|
||||
try {
|
||||
const value: unknown = JSON.parse(raw ?? "[]");
|
||||
return Array.isArray(value)
|
||||
? [
|
||||
...new Set(
|
||||
value.filter(
|
||||
(entry): entry is string =>
|
||||
typeof entry === "string" &&
|
||||
/^\/admin(?:\/[^?#]*)?$/.test(entry),
|
||||
),
|
||||
),
|
||||
].slice(0, 6)
|
||||
: [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user