docs: update admin extension docs (#4778)

* docs: update admin extension docs

* eslint fixes

* fix broken links

* fix broken link

* added admin upgrade guide

* fix lint errors
This commit is contained in:
Shahed Nasser
2023-08-17 20:04:13 +03:00
committed by GitHub
parent 75881a2cfe
commit 80b1bff8cb
21 changed files with 234 additions and 146 deletions
+7 -10
View File
@@ -2,9 +2,6 @@
title: 'How to Create an Admin Setting Page'
description: 'Learn how to create a new setting page in the admin dashboard.'
addHowToData: true
badge:
variant: orange
text: beta
---
In this document, youll learn how to create a setting page in the admin.
@@ -25,12 +22,6 @@ This guide explains how to create a new setting page in the admin dashboard with
Its assumed you already have a Medusa backend with the admin plugin installed before you move forward with this guide. If not, you can follow [this documentation page](../create-medusa-app.mdx) to install a Medusa project.
Furthermore, custom Admin Setting Pages are currently available as a beta feature. So, you must install the `beta` version of the `@medusajs/admin` and `@medusajs/medusa` packages:
```bash npm2yarn
npm install @medusajs/admin@beta @medusajs/medusa@beta
```
### (Optional) TypeScript Preparations
Since setting pages are React components, they should be written in `.tsx` or `.jsx` files. If youre using Typescript, you need to make some adjustments to avoid Typescript errors in your Admin files.
@@ -128,6 +119,12 @@ All setting page paths are prefixed with `/a/settings`.
For example, if you want the setting page to be available in the admin dashboard under the path `/a/settings/custom` you should create your setting page under the file path `src/admin/settings/custom/page.tsx`.
:::note
Only one-level deep files are accepted. So, for example, you can create the page `src/admin/settings/custom/page.tsx`, but not `src/admin/settings/custom/nested/page.tsx`.
:::
### Step 2: Create React Component in File
For a setting page to be valid, it must default export a React component. There are no restrictions on the content of the React component. It must also export a configuration object that indicates how the tab is shown on the Setting page.
@@ -189,7 +186,7 @@ For example:
```tsx title=src/admin/settings/custom/page.tsx
import type { SettingConfig } from "@medusajs/admin"
import type { SettingProps } from "@medusajs/admin-ui"
import type { SettingProps } from "@medusajs/admin"
const CustomSettingPage = ({
notify,