Skip to content

Commit b40b2ff

Browse files
authored
docs: improvements and additions to admin customization chapters (medusajs#13049)
1 parent 9643769 commit b40b2ff

File tree

4 files changed

+538
-13
lines changed

4 files changed

+538
-13
lines changed

www/apps/book/app/learn/fundamentals/admin/page.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ export const metadata = {
66

77
In this chapter, you'll learn about the Medusa Admin dashboard and the possible ways to customize it.
88

9-
## What is the Medusa Admin?
10-
11-
The Medusa Admin is an intuitive dashboard that allows merchants to manage their ecommerce store. It provides management features related to products, orders, customers, and more.
12-
139
<Note title="Tip">
1410

15-
To explore more what you can do with the Medusa Admin, check out the [User Guide](!user-guide!). These user guides are designed for merchants and provide the steps to perform any task within the Medusa Admin.
11+
To explore the Medusa Admin's commerce features, check out the [User Guide](!user-guide!). These user guides are designed for merchants and provide the steps to perform any task within the Medusa Admin.
1612

1713
</Note>
1814

19-
The Medusa Admin is built with [Vite](https://vite.dev/). When you [install the Medusa application](../../installation/page.mdx), you also install the Medusa Admin. Then, when you start the Medusa application, you can access the Medusa Admin at `http://localhost:9000/app`.
15+
## What is the Medusa Admin?
16+
17+
The Medusa Admin is an intuitive dashboard that allows merchants to manage their ecommerce store. It provides management features related to products, orders, customers, and more.
18+
19+
The Medusa Admin is built with [Vite v5](https://v5.vite.dev/). When you [install the Medusa application](../../installation/page.mdx), you also install the Medusa Admin. Then, when you start the Medusa application, you can access the Medusa Admin at `http://localhost:9000/app`.
2020

2121
<Note title="Tip">
2222

@@ -37,7 +37,7 @@ The next chapters will cover these two topics in detail.
3737

3838
### What You Can't Customize in the Medusa Admin
3939

40-
You can't customize the admin dashboard's layout, design, or the content of the existing pages (aside from injecting widgets).
40+
You can't customize the admin dashboard's layout, design, or the content of the existing pages (aside from injecting widgets). You also can't customize the login page, the authentication flow, or change the Medusa logo used in the admin dashboard.
4141

4242
If your use case requires heavy customization of the admin dashboard, you can build a custom admin dashboard using Medusa's [Admin API routes](!api!/admin).
4343

www/apps/book/app/learn/fundamentals/admin/widgets/page.mdx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,48 @@ Refer to [this reference](!resources!/admin-widget-injection-zones) for the full
139139
## Admin Components List
140140

141141
To build admin customizations that match the Medusa Admin's designs and layouts, refer to [this guide](!resources!/admin-components) to find common components.
142+
143+
---
144+
145+
## Show Widgets Conditionally
146+
147+
In some cases, you may want to show a widget only if certain conditions are met. For example, you may want to show a widget only if the product has a brand.
148+
149+
To disable the widget from showing, return an empty fragment from the widget component:
150+
151+
```tsx title="src/admin/widgets/product-widget.tsx"
152+
import { defineWidgetConfig } from "@medusajs/admin-sdk"
153+
import { Container, Heading } from "@medusajs/ui"
154+
import {
155+
DetailWidgetProps,
156+
AdminProduct,
157+
} from "@medusajs/framework/types"
158+
159+
// The widget
160+
const ProductWidget = ({
161+
data,
162+
}: DetailWidgetProps<AdminProduct>) => {
163+
if (!data.metadata?.brand) {
164+
return <></> // Don't show the widget if the product has no brand
165+
}
166+
167+
return (
168+
<Container className="divide-y p-0">
169+
<div className="flex items-center justify-between px-6 py-4">
170+
<Heading level="h2">
171+
Brand: {data.metadata.brand}
172+
</Heading>
173+
</div>
174+
</Container>
175+
)
176+
}
177+
178+
// The widget's configurations
179+
export const config = defineWidgetConfig({
180+
zone: "product.details.before",
181+
})
182+
183+
export default ProductWidget
184+
```
185+
186+
In the above example, you return an empty fragment if the product has no brand. Otherwise, you show the brand name in the widget.

www/apps/book/generated/edit-dates.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const generatedEditDates = {
1919
"app/learn/fundamentals/modules/container/page.mdx": "2025-05-21T15:07:12.059Z",
2020
"app/learn/fundamentals/workflows/execute-another-workflow/page.mdx": "2024-12-09T15:56:22.895Z",
2121
"app/learn/fundamentals/modules/loaders/page.mdx": "2025-06-16T13:34:16.462Z",
22-
"app/learn/fundamentals/admin/widgets/page.mdx": "2024-12-09T16:43:24.260Z",
22+
"app/learn/fundamentals/admin/widgets/page.mdx": "2025-07-25T12:55:14.744Z",
2323
"app/learn/fundamentals/data-models/page.mdx": "2025-03-18T07:55:56.252Z",
2424
"app/learn/fundamentals/modules/remote-link/page.mdx": "2024-09-30T08:43:53.127Z",
2525
"app/learn/fundamentals/api-routes/protected-routes/page.mdx": "2025-06-19T16:04:36.064Z",
@@ -29,7 +29,7 @@ export const generatedEditDates = {
2929
"app/learn/fundamentals/events-and-subscribers/emit-event/page.mdx": "2025-06-02T14:47:54.394Z",
3030
"app/learn/fundamentals/workflows/conditions/page.mdx": "2025-01-27T08:45:19.027Z",
3131
"app/learn/fundamentals/modules/module-link-directions/page.mdx": "2024-07-24T09:16:01+02:00",
32-
"app/learn/fundamentals/admin/page.mdx": "2025-04-18T10:28:47.328Z",
32+
"app/learn/fundamentals/admin/page.mdx": "2025-07-25T12:46:15.466Z",
3333
"app/learn/fundamentals/workflows/long-running-workflow/page.mdx": "2025-07-14T10:32:21.640Z",
3434
"app/learn/fundamentals/workflows/constructor-constraints/page.mdx": "2025-04-24T13:18:24.184Z",
3535
"app/learn/fundamentals/data-models/write-migration/page.mdx": "2025-07-23T15:32:18.008Z",

0 commit comments

Comments
 (0)