@@ -10,28 +10,21 @@ import type { MessageDescriptor } from "@lingui/core";
1010import { msg } from "@lingui/core/macro" ;
1111import { useLingui as useLinguiContext } from "@lingui/react" ;
1212import { useLingui } from "@lingui/react/macro" ;
13- import {
14- SquaresFour ,
15- FileText ,
16- Image ,
17- Gear ,
18- PuzzlePiece ,
19- Upload ,
20- Database ,
21- List ,
22- GridFour ,
23- Users ,
24- Stack ,
25- MagnifyingGlass ,
26- } from "@phosphor-icons/react" ;
13+ import { Gear , Users , MagnifyingGlass } from "@phosphor-icons/react" ;
2714import { useQuery } from "@tanstack/react-query" ;
2815import { useNavigate } from "@tanstack/react-router" ;
2916import * as React from "react" ;
3017import { useHotkeys } from "react-hotkeys-hook" ;
3118
3219import { apiFetch , type AdminManifest } from "../lib/api/client.js" ;
3320import { useCurrentUser } from "../lib/api/current-user" ;
34- import { resolvePluginPageLabel } from "./Sidebar" ;
21+ import {
22+ ADMIN_NAV_ICONS ,
23+ getCollectionNavIcon ,
24+ getTaxonomyNavIcon ,
25+ resolveNavIcon ,
26+ } from "./admin-navigation-icons.js" ;
27+ import { resolvePluginPageLabel } from "./Sidebar.js" ;
3528
3629/** Subset of manifest fields used by the palette (matches `Shell` props shape). */
3730type CommandPaletteManifest = {
@@ -126,7 +119,7 @@ async function searchContent(query: string): Promise<SearchResponse> {
126119 return body . data ;
127120}
128121
129- function buildNavItems (
122+ export function buildNavItems (
130123 manifest : CommandPaletteManifest ,
131124 userRole : number ,
132125 translateLabel : ( id : string ) => string ,
@@ -136,7 +129,7 @@ function buildNavItems(
136129 id : "dashboard" ,
137130 title : msg `Dashboard` ,
138131 to : "/" ,
139- icon : SquaresFour ,
132+ icon : ADMIN_NAV_ICONS . dashboard ,
140133 keywords : [ "home" , "overview" ] ,
141134 } ,
142135 ] ;
@@ -148,7 +141,7 @@ function buildNavItems(
148141 title : config . label ,
149142 to : "/content/$collection" ,
150143 params : { collection : name } ,
151- icon : FileText ,
144+ icon : getCollectionNavIcon ( name ) ,
152145 keywords : [ "content" , name ] ,
153146 } ) ;
154147 }
@@ -159,38 +152,38 @@ function buildNavItems(
159152 id : "media" ,
160153 title : msg `Media Library` ,
161154 to : "/media" ,
162- icon : Image ,
155+ icon : ADMIN_NAV_ICONS . media ,
163156 keywords : [ "images" , "files" , "uploads" ] ,
164157 } ,
165158 {
166159 id : "menus" ,
167160 title : msg `Menus` ,
168161 to : "/menus" ,
169- icon : List ,
162+ icon : ADMIN_NAV_ICONS . menus ,
170163 minRole : ROLE_EDITOR ,
171164 keywords : [ "navigation" ] ,
172165 } ,
173166 {
174167 id : "widgets" ,
175168 title : msg `Widgets` ,
176169 to : "/widgets" ,
177- icon : GridFour ,
170+ icon : ADMIN_NAV_ICONS . widgets ,
178171 minRole : ROLE_EDITOR ,
179172 keywords : [ "sidebar" , "footer" ] ,
180173 } ,
181174 {
182175 id : "sections" ,
183176 title : msg `Sections` ,
184177 to : "/sections" ,
185- icon : Stack ,
178+ icon : ADMIN_NAV_ICONS . sections ,
186179 minRole : ROLE_EDITOR ,
187180 keywords : [ "page builder" , "blocks" ] ,
188181 } ,
189182 {
190183 id : "content-types" ,
191184 title : msg `Content Types` ,
192185 to : "/content-types" ,
193- icon : Database ,
186+ icon : ADMIN_NAV_ICONS . contentTypes ,
194187 minRole : ROLE_ADMIN ,
195188 keywords : [ "schema" , "collections" ] ,
196189 } ,
@@ -199,7 +192,7 @@ function buildNavItems(
199192 title : msg `Categories` ,
200193 to : "/taxonomies/$taxonomy" ,
201194 params : { taxonomy : "category" } ,
202- icon : FileText ,
195+ icon : getTaxonomyNavIcon ( "category" ) ,
203196 minRole : ROLE_EDITOR ,
204197 keywords : [ "taxonomy" ] ,
205198 } ,
@@ -208,7 +201,7 @@ function buildNavItems(
208201 title : msg `Tags` ,
209202 to : "/taxonomies/$taxonomy" ,
210203 params : { taxonomy : "tag" } ,
211- icon : FileText ,
204+ icon : getTaxonomyNavIcon ( "tag" ) ,
212205 minRole : ROLE_EDITOR ,
213206 keywords : [ "taxonomy" ] ,
214207 } ,
@@ -224,15 +217,15 @@ function buildNavItems(
224217 id : "plugins" ,
225218 title : msg `Plugins` ,
226219 to : "/plugins-manager" ,
227- icon : PuzzlePiece ,
220+ icon : ADMIN_NAV_ICONS . plugins ,
228221 minRole : ROLE_ADMIN ,
229222 keywords : [ "extensions" , "add-ons" ] ,
230223 } ,
231224 {
232225 id : "import" ,
233226 title : msg `Import` ,
234227 to : "/import/wordpress" ,
235- icon : Upload ,
228+ icon : ADMIN_NAV_ICONS . import ,
236229 minRole : ROLE_ADMIN ,
237230 keywords : [ "wordpress" , "migrate" ] ,
238231 } ,
@@ -267,7 +260,7 @@ function buildNavItems(
267260 id : `plugin-${ pluginId } -${ page . path } ` ,
268261 title : label ,
269262 to : `/plugins/${ pluginId } ${ page . path } ` ,
270- icon : PuzzlePiece ,
263+ icon : resolveNavIcon ( page . icon ) ,
271264 keywords : [ "plugin" , pluginId ] ,
272265 } ) ;
273266 }
@@ -350,7 +343,13 @@ export function AdminCommandPalette({ manifest }: AdminCommandPaletteProps) {
350343 title : typeof item . title === "string" ? item . title : t ( item . title ) ,
351344 to : item . to ,
352345 params : item . params ,
353- icon : < item . icon className = "h-4 w-4" /> ,
346+ icon : (
347+ < React . Suspense
348+ fallback = { < ADMIN_NAV_ICONS . plugins className = "h-4 w-4" aria-hidden = "true" /> }
349+ >
350+ < item . icon className = "h-4 w-4" />
351+ </ React . Suspense >
352+ ) ,
354353 } ) ) ,
355354 } ) ;
356355 }
@@ -366,7 +365,9 @@ export function AdminCommandPalette({ manifest }: AdminCommandPaletteProps) {
366365 title : result . title || result . slug ,
367366 to : "/content/$collection/$id" ,
368367 params : { collection : result . collection , id : result . id } ,
369- icon : < FileText className = "h-4 w-4" /> ,
368+ icon : React . createElement ( getCollectionNavIcon ( result . collection ) , {
369+ className : "h-4 w-4" ,
370+ } ) ,
370371 description : collectionLabel ,
371372 collection : result . collection ,
372373 } ;
0 commit comments