@mantajs/dashboard 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -205,6 +205,92 @@ import type { MenuConfig, MenuItem, MenuNestedItem } from "@mantajs/dashboard/vi
|
|
|
205
205
|
|
|
206
206
|
When no `menu.config.ts` is found, the dashboard falls back to its built-in sidebar menu.
|
|
207
207
|
|
|
208
|
+
### Menu, Nested Routes, and Modules: How They Interact
|
|
209
|
+
|
|
210
|
+
Understanding how the sidebar menu is built is critical to avoid duplicate or missing entries. There are **three sources** that can add items to the sidebar:
|
|
211
|
+
|
|
212
|
+
1. **Your `menu.config.tsx`** — the custom menu you define
|
|
213
|
+
2. **Route configs with `nested`** — pages that declare `nested: "/parent"` in `defineRouteConfig()`
|
|
214
|
+
3. **Plugin modules** — modules like `@medusajs/draft-order` that register their own routes and menu entries
|
|
215
|
+
|
|
216
|
+
#### How `nested` works
|
|
217
|
+
|
|
218
|
+
When a route page exports a config with `nested`, Medusa **automatically injects** it as a sub-item under the specified parent in the sidebar:
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
// src/admin/routes/draft-orders/page.tsx
|
|
222
|
+
export const config = defineRouteConfig({
|
|
223
|
+
label: "Drafts",
|
|
224
|
+
nested: "/orders", // ← auto-injected under Orders in the sidebar
|
|
225
|
+
})
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This happens **regardless** of your `menu.config.tsx`. Even if you define a custom menu, any route with `nested` will still be injected as a child of its parent entry.
|
|
229
|
+
|
|
230
|
+
**To prevent a route from appearing in the sidebar**, remove the `nested` property:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
export const config = defineRouteConfig({
|
|
234
|
+
label: "Drafts Test",
|
|
235
|
+
// no `nested` → not auto-injected in the menu
|
|
236
|
+
})
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The page remains accessible via its URL (`/app/draft-orders`) but won't appear in the sidebar unless you explicitly add it to your menu config.
|
|
240
|
+
|
|
241
|
+
#### Controlling sub-items via `menu.config.tsx`
|
|
242
|
+
|
|
243
|
+
If you want full control over which sub-items appear under a menu entry, define them explicitly in `items`:
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
{
|
|
247
|
+
icon: <ShoppingCart />,
|
|
248
|
+
label: "orders.domain",
|
|
249
|
+
useTranslation: true,
|
|
250
|
+
to: "/orders",
|
|
251
|
+
items: [
|
|
252
|
+
{ label: "Draft Orders", to: "/draft-orders" },
|
|
253
|
+
],
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Important:** Nested routes (`nested: "/orders"`) are still injected even if you define `items` manually. To avoid duplicates, either:
|
|
258
|
+
- Remove `nested` from the route config, **or**
|
|
259
|
+
- Don't list the route in `items` (let `nested` handle it)
|
|
260
|
+
|
|
261
|
+
Never do both — you'll get a duplicate entry.
|
|
262
|
+
|
|
263
|
+
#### Plugin modules and the Extensions section
|
|
264
|
+
|
|
265
|
+
Medusa plugin modules (e.g., `@medusajs/draft-order`) register their own sidebar entries. By default, these appear in the **Extensions** section at the bottom of the sidebar.
|
|
266
|
+
|
|
267
|
+
When you include a module's route in your `menu.config.tsx`, the module's entry is **absorbed** into your custom menu and no longer appears separately in Extensions:
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
// Including /draft-orders in the custom menu prevents it from
|
|
271
|
+
// appearing again under Extensions
|
|
272
|
+
{
|
|
273
|
+
icon: <ShoppingCart />,
|
|
274
|
+
label: "Orders",
|
|
275
|
+
to: "/orders",
|
|
276
|
+
items: [
|
|
277
|
+
{ label: "Draft Orders", to: "/draft-orders" }, // ← module route
|
|
278
|
+
],
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
If you **don't** include a module's route in your menu config, it will appear in the Extensions section as usual.
|
|
283
|
+
|
|
284
|
+
#### Summary
|
|
285
|
+
|
|
286
|
+
| Scenario | Result |
|
|
287
|
+
|----------|--------|
|
|
288
|
+
| Route has `nested: "/orders"` | Auto-injected under Orders in sidebar |
|
|
289
|
+
| Route has no `nested` | Not in sidebar (unless in `menu.config.tsx`) |
|
|
290
|
+
| Module route listed in `menu.config.tsx` | Appears in your menu, not in Extensions |
|
|
291
|
+
| Module route **not** in `menu.config.tsx` | Appears in Extensions section |
|
|
292
|
+
| Route has `nested` **and** listed in `items` | Duplicate entry (avoid this!) |
|
|
293
|
+
|
|
208
294
|
## Exports
|
|
209
295
|
|
|
210
296
|
| Import | Description |
|