Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
099390c5c6 | ||
|
|
e3efc67c26 | ||
|
|
75e243f3bb | ||
|
|
2c663f4ad5 | ||
|
|
89eb9b4aae | ||
|
|
1f96548d92 | ||
|
|
1ebbffb808 | ||
|
|
a3944ea1f9 | ||
|
|
93f9e07a6c |
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# Sidebar categories
|
||||
|
||||
Date: 2026-12-01. Owner approved the grouping below on 2026-12-01.
|
||||
|
||||
## Intent
|
||||
|
||||
The sidebar is a flat list of work pages with one "Administration" section. The owner wants the modules grouped into clear categories and the menu cleaned up before go-live, and the WhatsApp inbox will need a home in it next.
|
||||
|
||||
## Decisions (owner-approved)
|
||||
|
||||
- Always-open labelled sections, not collapsible groups: 12 items do not need extra clicks.
|
||||
- Categories and order:
|
||||
- Dashboard (no label, first)
|
||||
- **Events:** Events, Event leads
|
||||
- **Leads:** Leads, Interests (the WhatsApp inbox joins here later)
|
||||
- **Access:** Users, Roles, Login security
|
||||
- **System:** Companies, Emails, Audit log
|
||||
- Each section has the existing thin divider and small muted label. The collapsed rail shows dividers only.
|
||||
- A section with nothing the user may open does not show.
|
||||
- Within a section, items follow the order above, not the server's order. A module missing from the map goes into a final unlabelled section at the end, so nothing disappears.
|
||||
- Every item has a distinct icon: Login security moves from `Shield` (too close to Roles' `ShieldCheck`) to `LockKeyhole`.
|
||||
|
||||
## Approach (my call)
|
||||
|
||||
The server's menu tree is flat, so the grouping stays in the portal as one fixed category map. It replaces the single admin list. The icon override for Login security lives in the same map, so no database change is needed. The portal icon map, which still carries babyboo icons for inventory, POS and catalogue modules Co-Lite does not have, is trimmed to the icons Co-Lite seeds plus the fallback.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Renaming modules, changing permissions or the server menu.
|
||||
- Collapsible groups.
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-01
|
||||
@@ -0,0 +1,20 @@
|
||||
## Context
|
||||
|
||||
See `docs/superpowers/specs/2026-12-01-sidebar-categories-design.md`. Task 1.2 of `refine-visitor-pages-and-shell` introduced `ADMIN_MODULES` and a two-way split in `SidebarNav`, with a visible label naming each list (`aria-labelledby`, plus `aria-label` in the rail).
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:** fixed categories and order, a distinct icon for every item, and a trimmed icon map.
|
||||
|
||||
**Non-Goals:** server menu changes, collapsible groups, renames.
|
||||
|
||||
## Decisions
|
||||
|
||||
- **The category map replaces `ADMIN_MODULES`.** `SIDEBAR_SECTIONS` in `aclSidebar.ts` is an ordered list of `{ label?: string; modules: string[] }`, with Dashboard as the first entry without a label. A helper `groupSidebar(links)` returns the sections in map order, each with its links in map order. Links not in the map go into a trailing section without a label. Empty sections are dropped. `SidebarNav` renders each section with the existing divider, label and list pattern; the first section has no divider.
|
||||
- **Icon override in the portal.** `SIDEBAR_ICONS: Record<string, string>` (module name to lucide name), holding `BO_LOGIN_SECURITY: "LockKeyhole"`, is applied in `groupSidebar` over the server's `iconName`. No SQL change.
|
||||
- **Icon map trim.** Keep only the icon names Co-Lite seeds (`local/seed/03-colite.sql` and the archived change SQL), `Store` (Companies, added by `useAclSidebar`), `LockKeyhole`, and the fallback. Check `icon-map` tests before removing anything; an existing test asserting a babyboo icon is a conflict to report.
|
||||
- **Labels** are new keys in `defaultMessages.ts` (`SidebarSectionEvents`, `SidebarSectionLeads`, `SidebarSectionAccess`, `SidebarSectionSystem`). `SidebarAdministration` is removed.
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- A new server module shows in the trailing section until it is added to the map. That is visible and harmless. Keep the `ponytail:` note.
|
||||
@@ -0,0 +1,27 @@
|
||||
## Why
|
||||
|
||||
The sidebar lists work pages and then one "Administration" section. The owner asked for the modules to be grouped into categories and cleaned up before go-live. The WhatsApp inbox, which comes next, needs a clear place in the menu.
|
||||
|
||||
## What Changes
|
||||
|
||||
- The sidebar shows labelled sections: Dashboard on its own, then Events, Leads, Access and System.
|
||||
- Items follow a fixed order within each section. A module missing from the map goes into a final section, so nothing disappears.
|
||||
- Login security gets its own icon (`LockKeyhole`).
|
||||
- The portal icon map drops babyboo icons for modules Co-Lite does not have.
|
||||
- The "Administration" label is replaced by the new section labels.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `admin-visual-design`: the Sidebar Sections requirement now describes the categories.
|
||||
|
||||
## Impact
|
||||
|
||||
- Portal only: `app/lib/aclSidebar.ts`, `app/components/app/Sidebar.tsx`, the icon map, `defaultMessages.ts` (section labels), and DESIGN.md (Navigation).
|
||||
- No server, database or API change.
|
||||
- Design: `docs/superpowers/specs/2026-12-01-sidebar-categories-design.md`.
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Sidebar Sections
|
||||
|
||||
The sidebar SHALL show Dashboard first, then the labelled sections Events, Leads, Access and System, each with a fixed set and order of pages. A page not in any section SHALL appear in a final section without a label. A section SHALL be marked by a divider and a small muted label, with only the divider in the collapsed rail, and SHALL NOT show when it has no page the user may open. Every page SHALL have a distinct icon.
|
||||
|
||||
#### Scenario: Super admin sidebar
|
||||
|
||||
- **WHEN** a super admin opens the portal
|
||||
- **THEN** the sidebar shows Dashboard, then "Events" with Events and Event leads, "Leads" with Leads and Interests, "Access" with Users, Roles and Login security, and "System" with Companies, Emails and Audit log
|
||||
|
||||
#### Scenario: Staff without admin pages
|
||||
|
||||
- **WHEN** a staff user who can open only Events and Event leads opens the portal
|
||||
- **THEN** the sidebar shows only the "Events" section
|
||||
- **AND** no "Leads", "Access" or "System" label
|
||||
|
||||
#### Scenario: Unknown page
|
||||
|
||||
- **WHEN** the server menu has a page that is not in the category map
|
||||
- **THEN** it is listed after the System section, without a label
|
||||
|
||||
#### Scenario: Collapsed rail
|
||||
|
||||
- **WHEN** an admin collapses the sidebar to the icon rail
|
||||
- **THEN** the sections are separated by dividers and no section label shows
|
||||
@@ -0,0 +1,14 @@
|
||||
# Tasks: group-sidebar-categories
|
||||
|
||||
Portal only. TDD, then the review gate. Verify: `cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint` (check the vitest exit code).
|
||||
|
||||
- [x] 1.1 Category map, `groupSidebar`, the icon override, section rendering in `SidebarNav` (full, drawer and rail), and the label keys. The "Administration" label and `ADMIN_MODULES` go.
|
||||
- Scope: `solvway-admin-portal/app/lib/aclSidebar*`, `solvway-admin-portal/app/components/app/Sidebar*`, `solvway-admin-portal/app/lib/i18n/defaultMessages.ts`
|
||||
- [x] 1.2 Trim the icon map to the icons Co-Lite uses.
|
||||
- Scope: the icon map file and its tests
|
||||
- [x] 1.3 DESIGN.md Navigation updated, and a Playwright check at 1280 px (full and rail) and 360 px (drawer) as a super admin, plus a staff user with event pages only.
|
||||
- Done 2026-12-02 on the local stack:
|
||||
- Playwright as super admin: the full sidebar at 1280 px (Dashboard, then Events, Leads, Access and System with labels and dividers), the collapsed rail (dividers only, Login security with its lock icon), and the drawer at 360 px.
|
||||
- The staff-only scenario (event pages only) is covered by `Sidebar.sections.test.tsx`. No browser sign-in was done for it, because no local staff user has only those modules.
|
||||
- Icon map trimmed to Co-Lite's 12 icons. The babyboo-only icon tests were removed, and the Activity-group test file was deleted.
|
||||
- Portal verify: vitest 1572 passed (exit 0), tsc 0, lint 0 errors.
|
||||
@@ -79,3 +79,73 @@ Every dropdown in the admin portal SHALL open a styled option menu that matches
|
||||
|
||||
- **WHEN** an admin focuses a dropdown and presses Enter or Space, then the arrow keys and Enter
|
||||
- **THEN** the menu opens, moves between options, and chooses one
|
||||
|
||||
### Requirement: Visitor Page Look
|
||||
|
||||
The public visitor pages (registration, invitation and check-in) SHALL show their content in one card on the page ground. The card SHALL be headed by the company name as a small label, the event name as the main heading, and the event dates and location. The pages SHALL use only the portal's theme tokens and SHALL NOT show a per-company logo or colour. The privacy notice SHALL be shown in full in English and Bahasa Malaysia as smaller, muted text that keeps at least 4.5:1 contrast.
|
||||
|
||||
#### Scenario: Visitor opens a registration code
|
||||
|
||||
- **WHEN** a visitor opens the registration page of an INS event
|
||||
- **THEN** the card shows "INS" as a label above the event name, then the event dates and location
|
||||
- **AND** the full privacy notice appears in both languages above the consent box
|
||||
|
||||
#### Scenario: Visitor needs a contact
|
||||
|
||||
- **WHEN** a visitor sees the mobile field on the registration form
|
||||
- **THEN** a hint under it says that a mobile number or an email is required
|
||||
|
||||
#### Scenario: Visitor reaches an end state
|
||||
|
||||
- **WHEN** a visitor's registration is accepted, or the code is inactive, or check-in has not opened yet
|
||||
- **THEN** the same card shows an icon and a heading for that state
|
||||
|
||||
### Requirement: Header Trail Without Repeats
|
||||
|
||||
The admin header SHALL NOT repeat the page title. On a page reached directly from the sidebar it SHALL show no trail. On a page below one, it SHALL show the parent page as a link back.
|
||||
|
||||
#### Scenario: Top-level page
|
||||
|
||||
- **WHEN** an admin opens the Events list
|
||||
- **THEN** the header shows no trail text
|
||||
|
||||
#### Scenario: Sub-page
|
||||
|
||||
- **WHEN** an admin opens the new event page
|
||||
- **THEN** the header shows "Events" as a link to the Events list
|
||||
|
||||
### Requirement: Table Scroll Cue
|
||||
|
||||
A table wider than its container SHALL show a fade on each edge where more columns can be scrolled into view. The fade SHALL disappear at that end of the scroll. Where a data table pins its first column, the pinned column covers the left fade and SHALL instead show a divider on its right edge.
|
||||
|
||||
#### Scenario: Users list on a phone
|
||||
|
||||
- **WHEN** an admin opens the Users list at 360 px wide
|
||||
- **THEN** a fade shows on the right edge of the table
|
||||
- **AND** after scrolling to the last column the right fade is gone
|
||||
- **AND** the pinned username column shows a divider on its right edge
|
||||
|
||||
### Requirement: Sidebar Sections
|
||||
|
||||
The sidebar SHALL show Dashboard first, then the labelled sections Events, Leads, Access and System, each with a fixed set and order of pages. A page not in any section SHALL appear in a final section without a label. A section SHALL be marked by a divider and a small muted label, with only the divider in the collapsed rail, and SHALL NOT show when it has no page the user may open. Every page SHALL have a distinct icon.
|
||||
|
||||
#### Scenario: Super admin sidebar
|
||||
|
||||
- **WHEN** a super admin opens the portal
|
||||
- **THEN** the sidebar shows Dashboard, then "Events" with Events and Event leads, "Leads" with Leads and Interests, "Access" with Users, Roles and Login security, and "System" with Companies, Emails and Audit log
|
||||
|
||||
#### Scenario: Staff without admin pages
|
||||
|
||||
- **WHEN** a staff user who can open only Events and Event leads opens the portal
|
||||
- **THEN** the sidebar shows only the "Events" section
|
||||
- **AND** no "Leads", "Access" or "System" label
|
||||
|
||||
#### Scenario: Unknown page
|
||||
|
||||
- **WHEN** the server menu has a page that is not in the category map
|
||||
- **THEN** it is listed after the System section, without a label
|
||||
|
||||
#### Scenario: Collapsed rail
|
||||
|
||||
- **WHEN** an admin collapses the sidebar to the icon rail
|
||||
- **THEN** the sections are separated by dividers and no section label shows
|
||||
@@ -183,7 +183,7 @@ The footer credit "Powered by Containerverse Sdn. Bhd." sits at the foot of the
|
||||
|
||||
**Public visitor pages** (`/r`, `/i`, `/c`) have no shell. One white card sits on the slate ground, full width with a 16px gutter on phones and at most 448px wide, with the footer credit under it. The card opens with the event header: the company name as a 12px semibold uppercase label in Action Blue, the event name as the 24px h1, then dates and location on their own muted lines with 16px icons. The privacy notice is fine print: 12px muted text on a slate-tint panel, both languages in full. Every end state (loading, thank you, welcome, not yet, inactive) is a centred 40px round icon (blue tint, or 10% red for errors) over a balanced semibold heading. The look is neutral: no company logo or colour.
|
||||
|
||||
**Signed-out pages** (login, reset password) share one frame: from the lg breakpoint a blue-tint panel on the left with the "Back office" pill, a headline and three feature lines, and the form column on the ground at right; below lg the panel folds into a short band above the form.
|
||||
**Signed-out pages** (login, forgot password, reset password) share one frame: from the lg breakpoint a blue-tint panel on the left with the "Back office" pill, a headline and three feature lines, and the form column on the ground at right; below lg the panel folds into a short band above the form.
|
||||
|
||||
**My QR codes** shows one card per code in a grid (one column on phones, two from 768px, three from 1280px): the event name as the card title, dates and location under it, the warning pill in the header when switched off, then the QR above its link and a wrapping row of outline buttons.
|
||||
|
||||
@@ -237,7 +237,7 @@ Quiet, compact, unmistakable.
|
||||
- Live inside a card or an 8px framed container. Header row in slate tint, 40px tall, 12px semibold uppercase muted labels with sort chevrons; cells 14px with 8px padding; rows separated by hairlines, hovering at 50% slate tint. The pager below reads "1-7 of 7" left and outline Previous / Next right.
|
||||
|
||||
### Navigation
|
||||
- **Sidebar:** white, right hairline. Items are 44px tall, 8px radius, 20px outline icon plus 14px medium label. Idle: muted slate, hover slate tint with ink. Active: blue tint with deep blue ink, `aria-current="page"`. Groups expand with a rotating chevron and indent children behind a left hairline. The collapsed rail shows icons only, with groups opening as a side popover. Admin pages (Users, Roles, Emails, Login security, Audit log, Companies) sit below a hairline divider and a 12px semibold muted "Administration" label; the rail keeps the divider only, and a section with nothing to open is not drawn.
|
||||
- **Sidebar:** white, right hairline. Items are 44px tall, 8px radius, 20px outline icon plus 14px medium label. Idle: muted slate, hover slate tint with ink. Active: blue tint with deep blue ink, `aria-current="page"`. Groups expand with a rotating chevron and indent children behind a left hairline. The collapsed rail shows icons only, with groups opening as a side popover. Pages are grouped into always-open sections: Dashboard alone, then Events (Events, Event leads), Leads (Leads, Interests), Access (Users, Roles, Login security) and System (Companies, Emails, Audit log). Each later section starts with a hairline divider and a 12px semibold muted label; the rail keeps the dividers only, a section with nothing to open is not drawn, and a page the map does not know trails in a last unlabelled section. Every page has its own icon.
|
||||
- **Header:** white, bottom hairline, 56px; the link back to the parent page left (sub-pages only); company picker (a styled select), locale switcher, theme toggle and user menu (blue avatar initial) right.
|
||||
|
||||
### Data States
|
||||
|
||||
@@ -12,9 +12,9 @@ const PANEL_POINTS = [
|
||||
{ icon: ListChecks, code: "BackOfficePanelFollowUps" },
|
||||
] as const;
|
||||
|
||||
// Two-column frame shared by the signed-out pages (login, forced password change): an accent panel
|
||||
// on the left from lg, the page's own content on the right. Below lg the
|
||||
// panel folds into a compact brand row above the content.
|
||||
// Two-column frame shared by the signed-out pages (login, forgot password, forced password
|
||||
// change): an accent panel on the left from lg, the page's own content on the right. Below lg
|
||||
// the panel folds into a compact brand row above the content.
|
||||
export default function AuthFrame({ children }: { children: ReactNode }) {
|
||||
const t = useT();
|
||||
return (
|
||||
|
||||
@@ -9,46 +9,70 @@ vi.mock("@/app/lib/useAclSidebar", () => ({ useAclSidebar: () => state.links }))
|
||||
|
||||
import { SidebarNav } from "./Sidebar";
|
||||
|
||||
const link = (name: string): SidebarLink => ({ name, url: `/${name}`, children: [] });
|
||||
const link = (name: string): SidebarLink => ({ name, url: `/${name}`, iconName: "Users", children: [] });
|
||||
const names = (...n: string[]) => n.map(link);
|
||||
|
||||
const ALL = names(
|
||||
"BO_DASHBOARD", "BO_EVENTS", "BO_EVENT_LEADS", "BO_INTERESTS", "BO_LEADS",
|
||||
"BO_USERS", "BO_ROLES", "BO_EMAILS", "BO_LOGIN_SECURITY", "BO_AUDIT_LOG", "BO_COMPANIES",
|
||||
);
|
||||
const linkNames = (list: HTMLElement) => within(list).getAllByRole("link").map((a) => a.getAttribute("href")?.slice(1));
|
||||
|
||||
describe("Sidebar sections", () => {
|
||||
it("lists work pages above the Administration label and admin pages below it", () => {
|
||||
state.links = ALL;
|
||||
it("lists Dashboard, then Events, Leads, Access and System sections in order", () => {
|
||||
state.links = [...ALL].reverse();
|
||||
render(<SidebarNav />);
|
||||
const label = screen.getByText("Administration");
|
||||
const before = (el: HTMLElement) => label.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING;
|
||||
const after = (el: HTMLElement) => label.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING;
|
||||
const hrefs = (re: RegExp) => screen.getAllByRole("link").filter((a) => re.test(a.getAttribute("href") ?? ""));
|
||||
for (const a of hrefs(/DASHBOARD|EVENTS|EVENT_LEADS|INTERESTS|LEADS/)) expect(before(a)).toBeTruthy();
|
||||
for (const a of hrefs(/USERS|ROLES|EMAILS|LOGIN_SECURITY|AUDIT_LOG|COMPANIES/)) expect(after(a)).toBeTruthy();
|
||||
const lists = screen.getAllByRole("list");
|
||||
expect(lists).toHaveLength(5);
|
||||
expect(linkNames(lists[0])).toEqual(["BO_DASHBOARD"]);
|
||||
expect(linkNames(screen.getByRole("list", { name: "Events" }))).toEqual(["BO_EVENTS", "BO_EVENT_LEADS"]);
|
||||
expect(linkNames(screen.getByRole("list", { name: "Leads" }))).toEqual(["BO_LEADS", "BO_INTERESTS"]);
|
||||
expect(linkNames(screen.getByRole("list", { name: "Access" }))).toEqual(["BO_USERS", "BO_ROLES", "BO_LOGIN_SECURITY"]);
|
||||
expect(linkNames(screen.getByRole("list", { name: "System" }))).toEqual(["BO_COMPANIES", "BO_EMAILS", "BO_AUDIT_LOG"]);
|
||||
expect(screen.getAllByRole("link")).toHaveLength(11);
|
||||
});
|
||||
|
||||
it("names the admin list by the label", () => {
|
||||
state.links = ALL;
|
||||
render(<SidebarNav />);
|
||||
const list = screen.getByRole("list", { name: "Administration" });
|
||||
expect(within(list).getAllByRole("link")).toHaveLength(6);
|
||||
});
|
||||
|
||||
it("shows no Administration label or divider when no admin module is available", () => {
|
||||
it("shows only the sections the user has pages in", () => {
|
||||
state.links = names("BO_EVENTS", "BO_EVENT_LEADS");
|
||||
const { container } = render(<SidebarNav />);
|
||||
expect(screen.queryByText("Administration")).toBeNull();
|
||||
expect(screen.getByRole("list", { name: "Events" })).toBeTruthy();
|
||||
for (const label of ["Leads", "Access", "System"]) expect(screen.queryByText(label)).toBeNull();
|
||||
expect(container.querySelector("[data-slot='sidebar-divider']")).toBeNull();
|
||||
});
|
||||
|
||||
it("shows only the divider in the collapsed rail", () => {
|
||||
it("puts a divider between sections but not above the first", () => {
|
||||
state.links = ALL;
|
||||
const { container } = render(<SidebarNav />);
|
||||
expect(container.querySelectorAll("[data-slot='sidebar-divider']")).toHaveLength(4);
|
||||
expect(container.querySelector("nav")!.firstElementChild!.tagName).toBe("UL");
|
||||
});
|
||||
|
||||
it("lists an unknown page after System without a label", () => {
|
||||
state.links = [...ALL, link("BO_NEW_THING")];
|
||||
const { container } = render(<SidebarNav />);
|
||||
const lists = screen.getAllByRole("list");
|
||||
expect(lists).toHaveLength(6);
|
||||
const last = lists[5];
|
||||
expect(linkNames(last)).toEqual(["BO_NEW_THING"]);
|
||||
expect(last.getAttribute("aria-labelledby")).toBeNull();
|
||||
expect(last.getAttribute("aria-label")).toBeNull();
|
||||
expect(container.querySelectorAll("[data-slot='sidebar-divider']")).toHaveLength(5);
|
||||
});
|
||||
|
||||
it("shows dividers and no labels in the collapsed rail", () => {
|
||||
state.links = ALL;
|
||||
const { container } = render(<SidebarNav collapsed />);
|
||||
expect(screen.queryByText("Administration")).toBeNull();
|
||||
expect(container.querySelector("[data-slot='sidebar-divider']")).not.toBeNull();
|
||||
for (const label of ["Events", "Leads", "Access", "System"]) expect(screen.queryByText(label)).toBeNull();
|
||||
expect(container.querySelectorAll("[data-slot='sidebar-divider']")).toHaveLength(4);
|
||||
expect(screen.getByRole("list", { name: "Access" })).toBeTruthy();
|
||||
expect(screen.getAllByRole("link")).toHaveLength(11);
|
||||
});
|
||||
|
||||
it("renders Login security with a different icon than Roles", () => {
|
||||
state.links = [{ ...link("BO_ROLES"), iconName: "Shield" }, { ...link("BO_LOGIN_SECURITY"), iconName: "Shield" }];
|
||||
render(<SidebarNav />);
|
||||
const icon = (name: string) => document.querySelector(`a[href='/${name}'] svg`)!.getAttribute("class");
|
||||
expect(icon("BO_ROLES")).toContain("lucide-shield");
|
||||
expect(icon("BO_LOGIN_SECURITY")).toContain("lucide-lock-keyhole");
|
||||
});
|
||||
});
|
||||
@@ -24,12 +24,13 @@ vi.mock("@/app/lib/useAclSidebar", () => ({
|
||||
|
||||
import Sidebar from "./Sidebar";
|
||||
|
||||
// Icons are Co-Lite seed icons (group-sidebar-categories trimmed the babyboo-only ones).
|
||||
const BO_FIXTURE: SidebarLink[] = [
|
||||
{ name: "Dashboard", url: "/", iconName: "LayoutDashboard", children: [] },
|
||||
{ name: "Members", url: "/members", iconName: "Users", children: [] },
|
||||
{ name: "Reports", url: "/reports", iconName: "FileText", children: [] },
|
||||
{ name: "Network", url: "/network", iconName: "Network", children: [] },
|
||||
{ name: "Messages", url: "/messages", iconName: "Languages", children: [] },
|
||||
{ name: "Reports", url: "/reports", iconName: "Mail", children: [] },
|
||||
{ name: "Network", url: "/network", iconName: "ScrollText", children: [] },
|
||||
{ name: "Messages", url: "/messages", iconName: "Tags", children: [] },
|
||||
];
|
||||
|
||||
describe("Sidebar icon rendering", () => {
|
||||
@@ -41,9 +42,9 @@ describe("Sidebar icon rendering", () => {
|
||||
expect(screen.getByText("Messages")).toBeInTheDocument();
|
||||
expect(container.querySelector("svg.lucide-layout-dashboard")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-users")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-file-text")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-network")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-languages")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-mail")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-scroll-text")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-tags")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("renders the neutral fallback icon, and does not throw, for an unknown or absent iconName", () => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useId, useState } from "react";
|
||||
import { Fragment, useEffect, useId, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { ChevronDown, PanelLeftClose, PanelLeftOpen } from "lucide-react";
|
||||
import { useAclSidebar } from "@/app/lib/useAclSidebar";
|
||||
import { ADMIN_MODULES, currentTrail, type SidebarLink } from "@/app/lib/aclSidebar";
|
||||
import { currentTrail, groupSidebar, type SidebarLink } from "@/app/lib/aclSidebar";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
import { iconFor } from "./icon-map";
|
||||
import { cn } from "@/app/lib/utils";
|
||||
@@ -215,39 +215,48 @@ function RailGroup({
|
||||
export function SidebarNav({ onNavigate, collapsed = false }: { onNavigate?: () => void; collapsed?: boolean }) {
|
||||
const t = useT();
|
||||
const links = useAclSidebar();
|
||||
const trail = currentTrail(links, usePathname());
|
||||
const adminLabelId = useId();
|
||||
|
||||
const work = links.filter((l) => !ADMIN_MODULES.includes(l.name));
|
||||
const admin = links.filter((l) => ADMIN_MODULES.includes(l.name));
|
||||
const sections = groupSidebar(links);
|
||||
// Trail from the grouped links: groupSidebar copies them, and active matching is by identity.
|
||||
const trail = currentTrail(sections.flatMap((s) => s.links), usePathname());
|
||||
const idBase = useId();
|
||||
const render = (link: SidebarLink) =>
|
||||
collapsed ? (
|
||||
<RailNode key={link.url || link.name} link={link} trail={trail} />
|
||||
) : (
|
||||
<NavNode key={link.url || link.name} link={link} depth={0} trail={trail} onNavigate={onNavigate} />
|
||||
);
|
||||
const listClass = cn("space-y-1", collapsed ? "px-2 py-3" : "p-3");
|
||||
|
||||
return (
|
||||
<nav aria-label={t("SidebarMainNav")} className="scrollable flex-1 overflow-x-hidden overflow-y-auto">
|
||||
{work.length > 0 && <ul className={cn(listClass, admin.length > 0 && "pb-0")}>{work.map(render)}</ul>}
|
||||
{admin.length > 0 && (
|
||||
<>
|
||||
<div data-slot="sidebar-divider" className={cn("mt-3 border-t border-border", collapsed ? "mx-3" : "mx-4")} />
|
||||
{/* The visible label names the list; the rail has no label, so the list carries the name itself. */}
|
||||
{!collapsed && (
|
||||
<p id={adminLabelId} className="px-6 pt-3 text-xs font-semibold text-muted-foreground">
|
||||
{t("SidebarAdministration")}
|
||||
</p>
|
||||
)}
|
||||
<ul
|
||||
aria-labelledby={collapsed ? undefined : adminLabelId}
|
||||
aria-label={collapsed ? t("SidebarAdministration") : undefined}
|
||||
className={cn(listClass, collapsed ? "pt-3" : "pt-2")}>
|
||||
{admin.map(render)}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{sections.map(({ label, links: items }, i) => {
|
||||
const labelId = `${idBase}-${i}`;
|
||||
const name = label ? t(label) : undefined;
|
||||
return (
|
||||
<Fragment key={label ?? `section-${i}`}>
|
||||
{i > 0 && (
|
||||
<div data-slot="sidebar-divider" className={cn("mt-3 border-t border-border", collapsed ? "mx-3" : "mx-4")} />
|
||||
)}
|
||||
{/* The visible label names the list; the rail has no label, so the list carries the name itself. */}
|
||||
{name && !collapsed && (
|
||||
<p id={labelId} className="px-6 pt-3 text-xs font-semibold text-muted-foreground">
|
||||
{name}
|
||||
</p>
|
||||
)}
|
||||
<ul
|
||||
aria-labelledby={name && !collapsed ? labelId : undefined}
|
||||
aria-label={name && collapsed ? name : undefined}
|
||||
className={cn(
|
||||
"space-y-1",
|
||||
collapsed ? "px-2 py-3" : "p-3",
|
||||
i < sections.length - 1 && "pb-0",
|
||||
i > 0 && (collapsed || !name ? "pt-3" : "pt-2"),
|
||||
)}
|
||||
>
|
||||
{items.map(render)}
|
||||
</ul>
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { iconFor } from "./icon-map";
|
||||
|
||||
// add-online-users: the Activity group (BO_NAV_ACTIVITY), Online users and Audit log seed icons.
|
||||
describe("iconFor — Activity group", () => {
|
||||
it.each(["Activity", "UserCheck", "ScrollText"])("resolves %s to a real (non-fallback) icon", (name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -3,8 +3,9 @@ import { describe, it, expect } from "vitest";
|
||||
import { iconFor } from "./icon-map";
|
||||
|
||||
// Covers spec "The Sidebar Renders Lucide Icons From icon_name":
|
||||
// - a seeded icon name renders as a lucide icon
|
||||
// - every icon Co-Lite seeds (or overrides in the sidebar) renders as a real lucide icon
|
||||
// - an unknown/absent icon name falls back safely (no throw)
|
||||
// group-sidebar-categories: the map holds only Co-Lite's icons; babyboo-only entries were removed.
|
||||
|
||||
describe("iconFor", () => {
|
||||
it("resolves a seeded lucide icon name (LayoutDashboard) to a component that renders", () => {
|
||||
@@ -13,55 +14,21 @@ describe("iconFor", () => {
|
||||
expect(container.querySelector("svg.lucide-layout-dashboard")).not.toBeNull();
|
||||
});
|
||||
|
||||
it.each(["Users", "FileText", "Network", "Languages", "Shield", "Settings", "Bell"])(
|
||||
"resolves seeded icon name %s to its matching lucide component",
|
||||
(name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
},
|
||||
);
|
||||
it.each([
|
||||
"LayoutDashboard", "CalendarDays", "ClipboardList", "Tags", "Users", "UserCog",
|
||||
"ShieldCheck", "Shield", "LockKeyhole", "Mail", "ScrollText", "Store",
|
||||
])("resolves Co-Lite icon name %s to a real (non-fallback) lucide component", (name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
});
|
||||
|
||||
it.each(["Calendar"])(
|
||||
"resolves Events sidebar seed icon %s to a real (non-fallback) lucide component",
|
||||
(name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["ShoppingCart"])(
|
||||
"resolves POS counter-sales sidebar seed icon %s to a real (non-fallback) lucide component",
|
||||
(name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["Store"])(
|
||||
"resolves Branch Counter sidebar seed icon %s to a real (non-fallback) lucide component",
|
||||
(name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["ArrowDownToLine", "BarChart2", "ArrowLeftRight", "History", "SlidersHorizontal"])(
|
||||
"resolves Inventory sidebar seed icon %s to a real (non-fallback) lucide component",
|
||||
(name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
},
|
||||
);
|
||||
it("no longer maps babyboo-only icons such as ShoppingCart (they fall back)", () => {
|
||||
const Icon = iconFor("ShoppingCart");
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg.lucide-circle")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("falls back to a neutral icon, without throwing, for an unknown name", () => {
|
||||
expect(() => iconFor("NotARealLucideIconName")).not.toThrow();
|
||||
@@ -81,22 +48,4 @@ describe("iconFor", () => {
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg.lucide-circle")).not.toBeNull();
|
||||
});
|
||||
|
||||
// fix-admin-sidebar-groups-icons: icon_name values on live BO module rows that used to
|
||||
// render the fallback circle.
|
||||
it.each(["ShieldCheck", "Wallet", "Mail", "Coins", "Megaphone", "Warehouse", "UserCog", "GalleryHorizontalEnd", "MessagesSquare", "Wrench"])(
|
||||
"resolves live BO module icon name %s to a real (non-fallback) lucide component",
|
||||
(name) => {
|
||||
const Icon = iconFor(name);
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg")).not.toBeNull();
|
||||
expect(container.querySelector("svg.lucide-circle")).toBeNull();
|
||||
},
|
||||
);
|
||||
|
||||
it("resolves the Collections seed icon Layers to a real lucide component (add-storefront-collections)", () => {
|
||||
const Icon = iconFor("Layers");
|
||||
const { container } = render(<Icon aria-hidden="true" />);
|
||||
expect(container.querySelector("svg.lucide-layers")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Activity, ArrowDownToLine, ArrowLeftRight, BarChart2, Bell, Box, Calendar, CalendarDays, Circle, ClipboardList, Coins, CreditCard, FileText, GalleryHorizontalEnd, Gift, History, LayoutDashboard, Languages, Layers, Mail, Megaphone, Menu, MessagesSquare, Network, Package, Settings, Shield, ShieldCheck, ShoppingCart, SlidersHorizontal, Star, Store, Tags, ScrollText, Undo2, UserCheck, UserCog, Users, Wallet, Warehouse, Wrench } from "lucide-react";
|
||||
import { CalendarDays, Circle, ClipboardList, LayoutDashboard, LockKeyhole, Mail, ScrollText, Shield, ShieldCheck, Store, Tags, UserCog, Users } from "lucide-react";
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
|
||||
// Maps the aclMenu tree's `iconName` (a plain string served by
|
||||
@@ -6,78 +6,23 @@ import type { LucideIcon } from "lucide-react";
|
||||
// component. A curated map, not `import * as Icons from "lucide-react"`: the
|
||||
// old src/components/app/nav-config.ts imported icon components directly, and
|
||||
// pulling in the whole icon set here would ship every lucide icon to the
|
||||
// browser for a handful of nav entries. Extend this map as more modules are
|
||||
// seeded with new iconName values.
|
||||
// browser for a handful of nav entries. Add an entry when a module is seeded
|
||||
// with a new iconName value.
|
||||
const ICONS: Record<string, LucideIcon> = {
|
||||
// Icons Co-Lite seeds (local/seed/03-colite.sql and the archived change SQL), plus Companies (Store)
|
||||
// and Login security (LockKeyhole, a sidebar override).
|
||||
LayoutDashboard,
|
||||
// Activity group (add-online-users): BO_NAV_ACTIVITY, Online users and Audit log seed icons.
|
||||
Activity,
|
||||
UserCheck,
|
||||
ScrollText,
|
||||
Users,
|
||||
FileText,
|
||||
Network,
|
||||
Languages,
|
||||
// Collapsible nav group headers (add-admin-portal-nav-groups).
|
||||
Shield,
|
||||
Settings,
|
||||
// Notifications module (add-admin-internal-notifications, seed id 41300000).
|
||||
Bell,
|
||||
// Catalogue Setup module (add-admin-catalog-setup): BO_CATALOG nav group and
|
||||
// BO_CATALOG_SETUP page.
|
||||
Package,
|
||||
Tags,
|
||||
Layers,
|
||||
// Product Setup module (add-admin-product-setup): BO_PRODUCTS page seed icon.
|
||||
Box,
|
||||
// Inventory module (add-inventory-stock-in): Stock In and Stock on Hand seed icons.
|
||||
ArrowDownToLine,
|
||||
BarChart2,
|
||||
// Inventory transfers + movement history (add-inventory-transfers-movement-history, I3):
|
||||
// Transfers and Movement History seed icons.
|
||||
ArrowLeftRight,
|
||||
History,
|
||||
// Inventory adjustments (add-inventory-adjustments, I4):
|
||||
// Adjustments seed icon.
|
||||
SlidersHorizontal,
|
||||
// Events module (add-event-module-pickup-e1, E1):
|
||||
// Events page seed icon.
|
||||
Calendar,
|
||||
// add-admin-events: BO_EVENTS seed icon_name = 'CalendarDays'.
|
||||
CalendarDays,
|
||||
// POS counter-sales module (add-event-pos-counter-sales):
|
||||
// POS page seed icon (sql/02-seed-bo-module-pos.sql icon_name = 'ShoppingCart').
|
||||
ShoppingCart,
|
||||
// Payment Methods module (add-payment-method-config, 2a):
|
||||
// seed icon_name = 'CreditCard'.
|
||||
CreditCard,
|
||||
// Branch Counter POS module (add-branch-counter-sale):
|
||||
// seed icon_name = 'Store'.
|
||||
Store,
|
||||
// Refund Requests (add-refund-requests, seed id 44300000).
|
||||
Undo2,
|
||||
// Gift Cards (add-gift-card-core, seed id 45000000, icon_name 'Gift').
|
||||
Gift,
|
||||
// Live BO module icon_name values that rendered the fallback circle
|
||||
// (fix-admin-sidebar-groups-icons).
|
||||
ShieldCheck,
|
||||
Wallet,
|
||||
Mail,
|
||||
Coins,
|
||||
Megaphone,
|
||||
Warehouse,
|
||||
UserCog,
|
||||
GalleryHorizontalEnd,
|
||||
// add-member-messaging: BO_MEMBER_MESSAGES seed icon_name = 'MessagesSquare'.
|
||||
MessagesSquare,
|
||||
// BO_RANK_REFERRAL seed icon_name = 'Wrench'.
|
||||
Wrench,
|
||||
// Product reviews (add-product-reviews, seed id 44800000).
|
||||
Star,
|
||||
// Forms (add-cms-forms, seed id 45200000).
|
||||
ClipboardList,
|
||||
// Menus (add-storefront-menus, seed id 45300000).
|
||||
Menu,
|
||||
Tags,
|
||||
Users,
|
||||
UserCog,
|
||||
ShieldCheck,
|
||||
Shield,
|
||||
LockKeyhole,
|
||||
Mail,
|
||||
ScrollText,
|
||||
Store,
|
||||
};
|
||||
|
||||
/** Neutral fallback for an absent or unrecognised `iconName` (spec: "The
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
|
||||
vi.mock("@/app/lib/clientApi", () => ({ apiPost: vi.fn() }));
|
||||
|
||||
import ForgotPasswordPage from "./page";
|
||||
|
||||
// Every signed-out page shares the login frame (DESIGN.md, Layout).
|
||||
describe("ForgotPasswordPage frame", () => {
|
||||
it("uses the login two-column frame with its title as the page heading", () => {
|
||||
render(<ForgotPasswordPage />);
|
||||
expect(screen.getByText("Everything behind Co-Lite, in one place.")).toBeInTheDocument();
|
||||
expect(screen.getAllByRole("link", { name: "Containerverse Sdn. Bhd." })).toHaveLength(1);
|
||||
expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("Forgot password");
|
||||
});
|
||||
});
|
||||
@@ -4,13 +4,12 @@ import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/app/components/ui/card";
|
||||
import { Input } from "@/app/components/ui/input";
|
||||
import { Label } from "@/app/components/ui/label";
|
||||
import { ErrorState } from "@/app/components/ui/states";
|
||||
import { apiPost } from "@/app/lib/clientApi";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
import PoweredBy from "@/app/components/app/PoweredBy";
|
||||
import AuthFrame from "@/app/components/app/AuthFrame";
|
||||
|
||||
// Public "email me a temporary password" form. Whatever happens (match, no match, server or network
|
||||
// failure) the visitor sees the same message, so the page never reveals whether an account exists.
|
||||
@@ -41,49 +40,44 @@ export default function ForgotPasswordPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-svh flex-col items-center justify-center gap-4 bg-background p-4">
|
||||
<Card className="w-full max-w-sm">
|
||||
<CardHeader className="gap-2">
|
||||
<CardTitle className="text-lg">{t("ForgotTitle")}</CardTitle>
|
||||
<CardDescription>{t("ForgotIntro")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{sent ? (
|
||||
<p role="status" className="text-sm">{t("ForgotSent")}</p>
|
||||
) : (
|
||||
<>
|
||||
{required && <ErrorState message={t("ForgotRequired")} />}
|
||||
<form onSubmit={handleSubmit} className="space-y-4" noValidate>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="company">{t("Company")}</Label>
|
||||
<Input id="company" autoComplete="organization" placeholder={t("CompanyBlankForSuper")} value={company}
|
||||
onChange={(e) => setCompany(e.target.value)} disabled={submitting} />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="username">{t("Username")}</Label>
|
||||
<Input id="username" autoComplete="username" required value={username}
|
||||
onChange={(e) => setUsername(e.target.value)} disabled={submitting} />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="email">{t("Email")}</Label>
|
||||
<Input id="email" type="email" autoComplete="email" required value={email}
|
||||
onChange={(e) => setEmail(e.target.value)} disabled={submitting} />
|
||||
</div>
|
||||
<Button type="submit" className="w-full" disabled={submitting}>
|
||||
{submitting && <Loader2 aria-hidden="true" className="size-4 animate-spin" />}
|
||||
{t("ForgotSubmit")}
|
||||
</Button>
|
||||
</form>
|
||||
</>
|
||||
)}
|
||||
<Link href="/login" className="block text-sm text-muted-foreground underline-offset-4 hover:underline">
|
||||
{t("ForgotBack")}
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div className="text-center">
|
||||
<PoweredBy />
|
||||
<AuthFrame>
|
||||
<div className="space-y-2">
|
||||
<h1 className="font-heading text-3xl font-semibold tracking-tight">{t("ForgotTitle")}</h1>
|
||||
<p className="text-muted-foreground">{t("ForgotIntro")}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-5">
|
||||
{sent ? (
|
||||
<p role="status" className="text-sm">{t("ForgotSent")}</p>
|
||||
) : (
|
||||
<>
|
||||
{required && <ErrorState message={t("ForgotRequired")} />}
|
||||
<form onSubmit={handleSubmit} className="space-y-5" noValidate>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="company">{t("Company")}</Label>
|
||||
<Input id="company" autoComplete="organization" placeholder={t("CompanyBlankForSuper")} value={company}
|
||||
onChange={(e) => setCompany(e.target.value)} disabled={submitting} className="h-11 bg-card" />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="username">{t("Username")}</Label>
|
||||
<Input id="username" autoComplete="username" required value={username}
|
||||
onChange={(e) => setUsername(e.target.value)} disabled={submitting} className="h-11 bg-card" />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="email">{t("Email")}</Label>
|
||||
<Input id="email" type="email" autoComplete="email" required value={email}
|
||||
onChange={(e) => setEmail(e.target.value)} disabled={submitting} className="h-11 bg-card" />
|
||||
</div>
|
||||
<Button type="submit" className="h-11 w-full text-base shadow-md" disabled={submitting}>
|
||||
{submitting && <Loader2 aria-hidden="true" className="size-4 animate-spin" />}
|
||||
{t("ForgotSubmit")}
|
||||
</Button>
|
||||
</form>
|
||||
</>
|
||||
)}
|
||||
<Link href="/login" className="block text-sm text-muted-foreground underline-offset-4 hover:underline">
|
||||
{t("ForgotBack")}
|
||||
</Link>
|
||||
</div>
|
||||
</AuthFrame>
|
||||
);
|
||||
}
|
||||
@@ -12,8 +12,32 @@ export interface SidebarLink {
|
||||
children: SidebarLink[];
|
||||
}
|
||||
|
||||
// ponytail: fixed list; a new admin module falls into the work section until added here.
|
||||
export const ADMIN_MODULES = ["BO_USERS", "BO_ROLES", "BO_EMAILS", "BO_LOGIN_SECURITY", "BO_AUDIT_LOG", "BO_COMPANIES"];
|
||||
// ponytail: fixed map; a new module lands in the trailing unlabelled section until added here.
|
||||
// `label` is an i18n key; the first section has none (Dashboard stands alone).
|
||||
export const SIDEBAR_SECTIONS: { label?: string; modules: string[] }[] = [
|
||||
{ modules: ["BO_DASHBOARD"] },
|
||||
{ label: "SidebarSectionEvents", modules: ["BO_EVENTS", "BO_EVENT_LEADS"] },
|
||||
{ label: "SidebarSectionLeads", modules: ["BO_LEADS", "BO_INTERESTS"] },
|
||||
{ label: "SidebarSectionAccess", modules: ["BO_USERS", "BO_ROLES", "BO_LOGIN_SECURITY"] },
|
||||
{ label: "SidebarSectionSystem", modules: ["BO_COMPANIES", "BO_EMAILS", "BO_AUDIT_LOG"] },
|
||||
];
|
||||
|
||||
// Icon overrides by module name, so a shared seed icon can differ in the sidebar.
|
||||
export const SIDEBAR_ICONS: Record<string, string> = { BO_LOGIN_SECURITY: "LockKeyhole" };
|
||||
|
||||
/** Splits links into the SIDEBAR_SECTIONS order; unknown links trail in an unlabelled section; empty sections drop. */
|
||||
export function groupSidebar(links: SidebarLink[]): { label?: string; links: SidebarLink[] }[] {
|
||||
const known = SIDEBAR_SECTIONS.flatMap((s) => s.modules);
|
||||
const withIcon = (l: SidebarLink) => ({ ...l, iconName: SIDEBAR_ICONS[l.name] ?? l.iconName });
|
||||
const sections = [
|
||||
...SIDEBAR_SECTIONS.map(({ label, modules }) => ({
|
||||
label,
|
||||
links: modules.flatMap((m) => links.filter((l) => l.name === m)).map(withIcon),
|
||||
})),
|
||||
{ label: undefined, links: links.filter((l) => !known.includes(l.name)).map(withIcon) },
|
||||
];
|
||||
return sections.filter((s) => s.links.length > 0);
|
||||
}
|
||||
|
||||
const byId = (nodes: AdminModule[] | undefined) => [...(nodes ?? [])].sort((a, b) => (a.id ?? 0) - (b.id ?? 0));
|
||||
|
||||
|
||||
@@ -86,7 +86,10 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
|
||||
HeaderSwitchToDark: "Switch to dark theme",
|
||||
LocaleSwitcherChange: "Change language",
|
||||
SidebarMainNav: "Main",
|
||||
SidebarAdministration: "Administration",
|
||||
SidebarSectionEvents: "Events",
|
||||
SidebarSectionLeads: "Leads",
|
||||
SidebarSectionAccess: "Access",
|
||||
SidebarSectionSystem: "System",
|
||||
UiBreadcrumb: "breadcrumb",
|
||||
UiMore: "More",
|
||||
UiColumns: "Columns",
|
||||
|
||||
Reference in new issue
Block a user