From 4c983557f9483cb5ace561974b27697911cee7cc Mon Sep 17 00:00:00 2001 From: Furman <72356359+Furman1331@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:01:53 +0100 Subject: [PATCH 1/9] feature: Add email to google provider-identity metadata (#10081) * feature: Add email to google provider-identity metadata * Include changeset. --------- Co-authored-by: Stevche Radevski --- .changeset/good-yaks-draw.md | 5 +++++ .../modules/providers/auth-google/src/services/google.ts | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/good-yaks-draw.md diff --git a/.changeset/good-yaks-draw.md b/.changeset/good-yaks-draw.md new file mode 100644 index 0000000000000..34c8d40e5cf16 --- /dev/null +++ b/.changeset/good-yaks-draw.md @@ -0,0 +1,5 @@ +--- +"@medusajs/auth-google": patch +--- + +feature: Add email to google provider-identity metadata diff --git a/packages/modules/providers/auth-google/src/services/google.ts b/packages/modules/providers/auth-google/src/services/google.ts index 1a2a323913a23..5f65f0b17c1b2 100644 --- a/packages/modules/providers/auth-google/src/services/google.ts +++ b/packages/modules/providers/auth-google/src/services/google.ts @@ -145,6 +145,7 @@ export class GoogleAuthService extends AbstractAuthModuleProvider { const entity_id = payload.sub const userMetadata = { name: payload.name, + email: payload.email, picture: payload.picture, given_name: payload.given_name, family_name: payload.family_name, From af66ac58cc4219fb1611aef57e41d25f9a7f1934 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 14 Nov 2024 16:41:14 +0200 Subject: [PATCH 2/9] docs: add missing import in digital product recipe (#10094) --- .../app/recipes/digital-products/examples/standard/page.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/www/apps/resources/app/recipes/digital-products/examples/standard/page.mdx b/www/apps/resources/app/recipes/digital-products/examples/standard/page.mdx index 9a706dbd82e1c..dc99e181672d8 100644 --- a/www/apps/resources/app/recipes/digital-products/examples/standard/page.mdx +++ b/www/apps/resources/app/recipes/digital-products/examples/standard/page.mdx @@ -1455,6 +1455,7 @@ Then, create the file `src/modules/digital-product-fulfillment/service.ts` with ```ts title="src/modules/digital-product-fulfillment/service.ts" import { AbstractFulfillmentProviderService } from "@medusajs/framework/utils" +import { FulfillmentOption } from "@medusajs/framework/types" class DigitalProductFulfillmentService extends AbstractFulfillmentProviderService { static identifier = "digital" From 2e5fd9fd71602749e76e054a548fdccd0fa22c3a Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Thu, 14 Nov 2024 15:51:30 +0100 Subject: [PATCH 3/9] fix(core-flows): Fix date usage accross workflows (#10100) FIXES CMRC-691 **What** `Date` is something that get executed, since workflows are meant to compose the definition of what will be executed, the date where always having the same value as they was executed once during composition. Instead wrap those into transformer that will be executed when needed and fix the Date issues --- .../workflows/claim/confirm-claim-request.ts | 21 ++++++++----- .../exchange/confirm-exchange-request.ts | 21 ++++++++----- .../order-edit/request-order-edit.ts | 30 ++++++++++++++----- .../return/confirm-return-request.ts | 22 +++++++++----- 4 files changed, 65 insertions(+), 29 deletions(-) diff --git a/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts b/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts index 7b7aa1e0a351f..6f8a2999780e6 100644 --- a/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts +++ b/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts @@ -47,6 +47,18 @@ export type ConfirmClaimRequestWorkflowInput = { confirmed_by?: string } +function getUpdateReturnData({ returnId }: { returnId: string }) { + return transform({ returnId }, ({ returnId }) => { + return [ + { + id: returnId, + status: ReturnStatus.REQUESTED, + requested_at: new Date(), + }, + ] + }) +} + /** * This step validates that a requested claim can be confirmed. */ @@ -306,13 +318,8 @@ export const confirmClaimRequestWorkflow = createWorkflow( when({ returnId }, ({ returnId }) => { return !!returnId }).then(() => { - updateReturnsStep([ - { - id: returnId, - status: ReturnStatus.REQUESTED, - requested_at: new Date(), - }, - ]) + const updateReturnDate = getUpdateReturnData({ returnId }) + updateReturnsStep(updateReturnDate) }) const claimId = transform( diff --git a/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts b/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts index ff2279fa03856..78fecca7fc838 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts @@ -203,6 +203,18 @@ function extractShippingOption({ orderPreview, orderExchange, returnId }) { } } +function getUpdateReturnData({ returnId }: { returnId: string }) { + return transform({ returnId }, ({ returnId }) => { + return [ + { + id: returnId, + status: ReturnStatus.REQUESTED, + requested_at: new Date(), + }, + ] + }) +} + export const confirmExchangeRequestWorkflowId = "confirm-exchange-request" /** * This workflow confirms an exchange request. @@ -294,13 +306,8 @@ export const confirmExchangeRequestWorkflow = createWorkflow( when({ returnId }, ({ returnId }) => { return !!returnId }).then(() => { - updateReturnsStep([ - { - id: returnId, - status: ReturnStatus.REQUESTED, - requested_at: new Date(), - }, - ]) + const updateReturnData = getUpdateReturnData({ returnId }) + updateReturnsStep(updateReturnData) }) const exchangeId = transform( diff --git a/packages/core/core-flows/src/order/workflows/order-edit/request-order-edit.ts b/packages/core/core-flows/src/order/workflows/order-edit/request-order-edit.ts index d66a924dc85f8..312c816615312 100644 --- a/packages/core/core-flows/src/order/workflows/order-edit/request-order-edit.ts +++ b/packages/core/core-flows/src/order/workflows/order-edit/request-order-edit.ts @@ -8,6 +8,7 @@ import { WorkflowResponse, createStep, createWorkflow, + transform, } from "@medusajs/framework/workflows-sdk" import { useRemoteQueryStep } from "../../../common" import { previewOrderChangeStep } from "../../steps" @@ -23,6 +24,25 @@ export type OrderEditRequestWorkflowInput = { requested_by?: string } +function getOrderChangesData({ + input, + orderChange, +}: { + input: { requested_by?: string } + orderChange: { id: string } +}) { + return transform({ input, orderChange }, ({ input, orderChange }) => { + return [ + { + id: orderChange.id, + status: OrderChangeStatus.REQUESTED, + requested_at: new Date(), + requested_by: input.requested_by, + }, + ] + }) +} + /** * This step validates that a order edit can be requested. */ @@ -74,14 +94,8 @@ export const requestOrderEditRequestWorkflow = createWorkflow( orderChange, }) - updateOrderChangesStep([ - { - id: orderChange.id, - status: OrderChangeStatus.REQUESTED, - requested_at: new Date(), - requested_by: input.requested_by, - }, - ]) + const updateOrderChangesData = getOrderChangesData({ input, orderChange }) + updateOrderChangesStep(updateOrderChangesData) createOrUpdateOrderPaymentCollectionWorkflow.runAsStep({ input: { diff --git a/packages/core/core-flows/src/order/workflows/return/confirm-return-request.ts b/packages/core/core-flows/src/order/workflows/return/confirm-return-request.ts index 3e0d476d77cc9..3ee2aa1345afd 100644 --- a/packages/core/core-flows/src/order/workflows/return/confirm-return-request.ts +++ b/packages/core/core-flows/src/order/workflows/return/confirm-return-request.ts @@ -158,6 +158,18 @@ function extractReturnShippingOptionId({ orderPreview, orderReturn }) { return returnShippingMethod.shipping_option_id } +function getUpdateReturnData({ orderReturn }: { orderReturn: { id: string } }) { + return transform({ orderReturn }, ({ orderReturn }) => { + return [ + { + id: orderReturn.id, + status: ReturnStatus.REQUESTED, + requested_at: new Date(), + }, + ] + }) +} + export const confirmReturnRequestWorkflowId = "confirm-return-request" /** * This workflow confirms a return request. @@ -277,14 +289,10 @@ export const confirmReturnRequestWorkflow = createWorkflow( createRemoteLinkStep(link) }) + const updateReturnData = getUpdateReturnData({ orderReturn }) + parallelize( - updateReturnsStep([ - { - id: orderReturn.id, - status: ReturnStatus.REQUESTED, - requested_at: new Date(), - }, - ]), + updateReturnsStep(updateReturnData), confirmOrderChanges({ changes: [orderChange], orderId: order.id, From 273960f6e32c3adda8779824dcb3026e945ea500 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 14 Nov 2024 16:53:24 +0200 Subject: [PATCH 4/9] docs: fix client error for learning path (#10102) --- .../Homepage/LinksSection/index.tsx | 7 +- www/apps/book/providers/index.tsx | 2 +- .../components/Card/Layout/Default/index.tsx | 1 + .../components/Card/Layout/Large/index.tsx | 1 + .../src/components/Card/Layout/Mini/index.tsx | 6 +- .../components/Notification/Item/index.tsx | 107 ++++++++++-------- .../src/components/Notification/index.tsx | 41 ++----- 7 files changed, 83 insertions(+), 82 deletions(-) diff --git a/www/apps/book/components/Homepage/LinksSection/index.tsx b/www/apps/book/components/Homepage/LinksSection/index.tsx index 34700fd27e2bc..dc0dce5f561e3 100644 --- a/www/apps/book/components/Homepage/LinksSection/index.tsx +++ b/www/apps/book/components/Homepage/LinksSection/index.tsx @@ -84,7 +84,12 @@ const Section = ({ title, links }: SectionProps) => {

{title}

{links.map((link, index) => ( - + {link.text} ))} diff --git a/www/apps/book/providers/index.tsx b/www/apps/book/providers/index.tsx index e157fd811d9c9..17bdd196e2cca 100644 --- a/www/apps/book/providers/index.tsx +++ b/www/apps/book/providers/index.tsx @@ -32,7 +32,7 @@ const Providers = ({ children }: ProvidersProps) => { {children} diff --git a/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx b/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx index c84b95d82b1d0..02d0842934836 100644 --- a/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx +++ b/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx @@ -68,6 +68,7 @@ export const CardDefaultLayout = ({ )}
diff --git a/www/packages/docs-ui/src/components/Card/Layout/Large/index.tsx b/www/packages/docs-ui/src/components/Card/Layout/Large/index.tsx index c06759a202a07..eb0b3ef8d8d25 100644 --- a/www/packages/docs-ui/src/components/Card/Layout/Large/index.tsx +++ b/www/packages/docs-ui/src/components/Card/Layout/Large/index.tsx @@ -61,6 +61,7 @@ export const CardLargeLayout = ({ )} diff --git a/www/packages/docs-ui/src/components/Card/Layout/Mini/index.tsx b/www/packages/docs-ui/src/components/Card/Layout/Mini/index.tsx index 28a7384f6ece5..0a9be2c11c450 100644 --- a/www/packages/docs-ui/src/components/Card/Layout/Mini/index.tsx +++ b/www/packages/docs-ui/src/components/Card/Layout/Mini/index.tsx @@ -89,7 +89,11 @@ export const CardLayoutMini = ({ {isExternal ? : } {href && ( - + )} diff --git a/www/packages/docs-ui/src/components/Notification/Item/index.tsx b/www/packages/docs-ui/src/components/Notification/Item/index.tsx index 4e328319aae1d..78a8c0a6c7d22 100644 --- a/www/packages/docs-ui/src/components/Notification/Item/index.tsx +++ b/www/packages/docs-ui/src/components/Notification/Item/index.tsx @@ -1,6 +1,10 @@ +"use client" + import clsx from "clsx" -import React, { Children, ReactElement } from "react" +import React, { Children, ReactElement, useRef } from "react" import { NotificationItemLayoutDefault } from "./Layout/Default" +// @ts-expect-error can't install the types package because it doesn't support React v19 +import { CSSTransition } from "react-transition-group" export type NotificationItemProps = { layout?: "default" | "empty" @@ -16,65 +20,70 @@ export type NotificationItemProps = { setShow?: (value: boolean) => void onClose?: () => void closeButtonText?: string + passRef?: React.RefObject } & React.HTMLAttributes type EmptyLayoutProps = { onClose?: () => void } -export const NotificationItem = React.forwardRef< - HTMLDivElement, - NotificationItemProps ->(function NotificationItem( - { - className = "", - placement = "bottom", - show = true, - layout = "default", - setShow, - onClose, - children, - ...rest - }, - ref -) { +export const NotificationItem = ({ + className = "", + placement = "bottom", + show = true, + layout = "default", + setShow, + onClose, + children, + ...rest +}: NotificationItemProps) => { + const ref = useRef(null) const handleClose = () => { setShow?.(false) onClose?.() } return ( -
- {layout === "default" && ( - - {children} - - )} - {layout === "empty" && - Children.map(children, (child) => { - if (child) { - return React.cloneElement( - child as React.ReactElement< - EmptyLayoutProps, - React.FunctionComponent - >, - { - onClose: handleClose, - } - ) - } - })} -
+
+ {layout === "default" && ( + + {children} + + )} + {layout === "empty" && + Children.map(children, (child) => { + if (child) { + return React.cloneElement( + child as React.ReactElement< + EmptyLayoutProps, + React.FunctionComponent + >, + { + onClose: handleClose, + } + ) + } + })} +
+ ) -}) +} diff --git a/www/packages/docs-ui/src/components/Notification/index.tsx b/www/packages/docs-ui/src/components/Notification/index.tsx index 509a60af4c7b0..6f3770dedd4e3 100644 --- a/www/packages/docs-ui/src/components/Notification/index.tsx +++ b/www/packages/docs-ui/src/components/Notification/index.tsx @@ -5,25 +5,16 @@ import { NotificationItemType, useNotifications, } from "@/providers" -import React, { useEffect, useRef } from "react" +import React from "react" import { NotificationItem } from "./Item" // @ts-expect-error can't install the types package because it doesn't support React v19 -import { CSSTransition, TransitionGroup } from "react-transition-group" +import { TransitionGroup } from "react-transition-group" import clsx from "clsx" export const NotificationContainer = () => { const { notifications, removeNotification } = useNotifications() as NotificationContextType - const notificationRefs = useRef([]) - - useEffect(() => { - notificationRefs.current = notificationRefs.current.slice( - 0, - notifications.length - ) - }, [notifications]) - const handleClose = (notification: NotificationItemType) => { notification.onClose?.() if (notification.id) { @@ -45,26 +36,16 @@ export const NotificationContainer = () => { className )} > - {notifications.filter(condition).map((notification, index) => ( - ( + handleClose(notification)} + className={clsx( + notification.className, + "!relative !top-0 !bottom-0 !right-0" + )} key={notification.id} - timeout={200} - classNames={{ - enter: "animate-slideInRight animate-fast", - exit: "animate-slideOutRight animate-fast", - }} - nodeRef={notificationRefs.current[index]} - > - handleClose(notification)} - ref={notificationRefs.current[index]} - className={clsx( - notification.className, - "!relative !top-0 !bottom-0 !right-0" - )} - /> - + /> ))} ) From 06ce16c90ba1cc20daa8c10fadab067d9381a7d1 Mon Sep 17 00:00:00 2001 From: "Carlos R. L. Rodrigues" <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:11:37 -0300 Subject: [PATCH 5/9] chore(local-file): throw error if file exist (#10087) --- .changeset/rich-pumpkins-lie.md | 5 +++++ .../providers/file-local/src/services/local-file.ts | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/rich-pumpkins-lie.md diff --git a/.changeset/rich-pumpkins-lie.md b/.changeset/rich-pumpkins-lie.md new file mode 100644 index 0000000000000..49ae17a49a420 --- /dev/null +++ b/.changeset/rich-pumpkins-lie.md @@ -0,0 +1,5 @@ +--- +"@medusajs/file-local": patch +--- + +Throw error from local file provider diff --git a/packages/modules/providers/file-local/src/services/local-file.ts b/packages/modules/providers/file-local/src/services/local-file.ts index b5001a6256155..b03fe5d7c5006 100644 --- a/packages/modules/providers/file-local/src/services/local-file.ts +++ b/packages/modules/providers/file-local/src/services/local-file.ts @@ -71,10 +71,13 @@ export class LocalFileService extends AbstractFileProviderService { const filePath = this.getUploadFilePath(baseDir, file.fileKey) try { - await fs.access(filePath, fs.constants.F_OK) + await fs.access(filePath, fs.constants.W_OK) await fs.unlink(filePath) } catch (e) { - // The file does not exist, so it's a noop. + // The file does not exist, we don't do anything + if (e.code !== "ENOENT") { + throw e + } } return From 9c39cf69fb0e40cd215856189d3621320dba7ad7 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 14 Nov 2024 17:17:01 +0200 Subject: [PATCH 6/9] docs: add guide on how to translate admin (#10095) * docs: add guide on how to translate admin * added a link from the main docs --- .../advanced-development/admin/tips/page.mdx | 10 +- .../_admin-translations/page.mdx | 49 -------- .../admin-translations/page.mdx | 107 ++++++++++++++++++ www/apps/resources/generated/edit-dates.mjs | 4 +- www/apps/resources/generated/files-map.mjs | 4 +- www/apps/resources/generated/sidebar.mjs | 8 ++ www/apps/resources/sidebar.mjs | 13 ++- 7 files changed, 135 insertions(+), 60 deletions(-) delete mode 100644 www/apps/resources/app/contribution-guidelines/_admin-translations/page.mdx create mode 100644 www/apps/resources/app/contribution-guidelines/admin-translations/page.mdx diff --git a/www/apps/book/app/learn/advanced-development/admin/tips/page.mdx b/www/apps/book/app/learn/advanced-development/admin/tips/page.mdx index e1bf3f817cef4..c1e22bd4fd392 100644 --- a/www/apps/book/app/learn/advanced-development/admin/tips/page.mdx +++ b/www/apps/book/app/learn/advanced-development/admin/tips/page.mdx @@ -167,4 +167,12 @@ This adds a widget in a product's details page with a link to the Orders page. T Refer to [react-router-dom’s documentation](https://reactrouter.com/en/main) for other available components and hooks. - \ No newline at end of file + + +--- + +## Admin Translations + +The Medusa Admin dashboard can be displayed in languages other than English, which is the default. Other languages are added through community contributions. + +Learn how to add a new language translation for the Medusa Admin in [this guide](!resources!/contribution-guidelines/admin-translations). diff --git a/www/apps/resources/app/contribution-guidelines/_admin-translations/page.mdx b/www/apps/resources/app/contribution-guidelines/_admin-translations/page.mdx deleted file mode 100644 index 5f53281f25455..0000000000000 --- a/www/apps/resources/app/contribution-guidelines/_admin-translations/page.mdx +++ /dev/null @@ -1,49 +0,0 @@ -export const metadata = { - title: `Contribute by Translating Admins`, -} - -# {metadata.title} - -The Medusa Admin supports multiple languages, with the default being English. We highly appreciate your contribution by translation to other languages you're fluent with, as it ensures a wider support of languages. - -This type of contribution is a no-code contribution, meaning you don't need advanced technical skills to contribute. - ---- - -## How to Contribute Translation - -1. Clone the [Medusa monorepository](https://github.com/medusajs/medusa) to your local machine: - -```bash -git clone https://github.com/medusajs/medusa.git -``` - -If you already have it cloned, make sure to pull the latest changes from the `develop` branch. - -2. Create a branch that'll be used to open the pull request later: - -```bash -git check -b feat/translate- -``` - -Where `` is your language name. For example, `feat/translate-da`. - -3. Create a new directory under `packages/admin-ui/ui/public/locales` with its name being the [ISO 2 character code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) of your language. For example, `da`. In the new directory, create the file `translation.json`. - -4. Copy the content of the English translation file located at `packages/admin-ui/ui/public/locales/en/translation.json` and paste it in your new `translation.json` file. - -5. In the file, leave the key names as-is, and only translate the values. - -7. In the file `packages/admin-ui/ui/src/i18n/index.ts`, add the new language to the `supportedLanguages` array as an object. The object accepts two properties: `locale` for the ISO 2 character code, and `name` for the name of the language. The name of the language should be the translated name, not the English name. For example: - -```ts title="packages/admin-ui/ui/src/i18n/index.ts" -export const supportedLanguages = [ - // other languages... - { - locale: "da", - name: "Dansk", - }, -] -``` - -8. Once you're done, push the changes into your branch and open a pull request on GitHub. diff --git a/www/apps/resources/app/contribution-guidelines/admin-translations/page.mdx b/www/apps/resources/app/contribution-guidelines/admin-translations/page.mdx new file mode 100644 index 0000000000000..f207ba836df9f --- /dev/null +++ b/www/apps/resources/app/contribution-guidelines/admin-translations/page.mdx @@ -0,0 +1,107 @@ +export const metadata = { + title: `Translate Medusa Admin`, +} + +# {metadata.title} + +The Medusa Admin supports multiple languages, with the default being English. In this documentation, you'll learn how to contribute to the community by translating the Medusa Admin to a language you're fluent in. + +{/* vale docs.We = NO */} + +You can contribute either by translating the admin to a new language, or fixing translations for existing languages. As we can't validate every language's translations, some translations may be incorrect. Your contribution is welcome to fix any translation errors you find. + +{/* vale docs.We = YES */} + + + +Check out the translated languages either in the admin dashboard's settings or on [GitHub](https://github.com/medusajs/medusa/blob/develop/packages/admin/dashboard/src/i18n/languages.ts). + + + +--- + +## How to Contribute Translation + +1. Clone the [Medusa monorepository](https://github.com/medusajs/medusa) to your local machine: + +```bash +git clone https://github.com/medusajs/medusa.git +``` + +If you already have it cloned, make sure to pull the latest changes from the `develop` branch. + +2. Install the monorepository's dependencies. Since it's a Yarn workspace, it's highly recommended to use yarn: + +```bash +yarn install +``` + +3. Create a branch that you'll use to open the pull request later: + +```bash +git check -b feat/translate- +``` + +Where `` is your language name. For example, `feat/translate-da`. + +4. Translation files are under `packages/admin/dashboard/src/i18n/translations` as JSON files whose names are the ISO-2 name of the language. + - If you're adding a new language, copy the file `packages/admin/dashboard/src/i18n/translations/en.json` and paste it with the ISO-2 name for your language. For example, if you're adding Danish translations, copy the `en.json` file and paste it as `packages/admin/dashboard/src/i18n/translations/de.json`. + - If you're fixing a translation, find the JSON file of the language under `packages/admin/dashboard/src/i18n/translations`. + +5. Start translating the keys in the JSON file (or updating the targeted ones). All keys in the JSON file must be translated, and your PR tests will fail otherwise. + - You can check whether the JSON file is valid by running the following command in `packages/admin/dashboard`, replacing `da.json` with the JSON file's name: + +```bash title="packages/admin/dashboard" +yarn i18n:validate da.json +``` + +6. After finishing the translation, if you're adding a new language, import its JSON file in `packages/admin/dashboard/src/i18n/translations/index.ts` and add it to the exported object: + +```ts title="packages/admin/dashboard/src/i18n/translations/index.ts" highlights={[["2"], ["6"], ["7"], ["8"]]} +// other imports... +import da from "./da.json" + +export default { + // other languages... + da: { + translation: da, + }, +} +``` + +The language's key in the object is the ISO-2 name of the language. + +7. If you're adding a new language, add it to the file `packages/admin/dashboard/src/i18n/languages.ts`: + +export const languageHighlights = [ + ["7", "code", "The ISO-2 name of the language."], + ["8", "display_name", "The language's name to be displayed in the admin."], + ["9", "ltr", "Whether the language supports a left-to-right layout."], + ["10", "date_locale", "An instance of the locale imported from the [date-fns/locale](https://date-fns.org/) package."] +] + +```ts title="packages/admin/dashboard/src/i18n/languages.ts" highlights={languageHighlights} +import { da } from "date-fns/locale" +// other imports... + +export const languages: Language[] = [ + // other languages... + { + code: "da", + display_name: "Danish", + ltr: true, + date_locale: da + } +] +``` + +`languages` is an array having the following properties: + +- `code`: The ISO-2 name of the language. For example, `da` for Danish. +- `display_name`: The language's name to be displayed in the admin. +- `ltr`: Whether the language supports a left-to-right layout. For example, set this to `false` for languages like Arabic. +- `date_locale`: An instance of the locale imported from the [date-fns/locale](https://date-fns.org/) package. + +8. Once you're done, push the changes into your branch and open a pull request on GitHub. + +Our team will perform a general review on your PR and merge it if no issues are found. The translation will be available in the admin after the next release. diff --git a/www/apps/resources/generated/edit-dates.mjs b/www/apps/resources/generated/edit-dates.mjs index f87fcc1468389..f790a68300902 100644 --- a/www/apps/resources/generated/edit-dates.mjs +++ b/www/apps/resources/generated/edit-dates.mjs @@ -113,7 +113,6 @@ export const generatedEditDates = { "app/commerce-modules/user/user-creation-flows/page.mdx": "2024-10-15T14:51:37.311Z", "app/commerce-modules/user/page.mdx": "2024-10-15T14:44:19.628Z", "app/commerce-modules/page.mdx": "2024-10-07T13:55:08.014Z", - "app/contribution-guidelines/_admin-translations/page.mdx": "2024-05-13T18:55:11+03:00", "app/contribution-guidelines/docs/page.mdx": "2024-10-16T15:48:04.071Z", "app/create-medusa-app/page.mdx": "2024-08-05T11:10:55+03:00", "app/deployment/admin/vercel/page.mdx": "2024-10-16T08:10:29.377Z", @@ -3251,5 +3250,6 @@ export const generatedEditDates = { "references/types/types/types.UncountableRules/page.mdx": "2024-11-12T09:36:21.340Z", "references/product/interfaces/product.FilterableProductProps/page.mdx": "2024-11-12T09:36:53.124Z", "references/types/HttpTypes/interfaces/types.HttpTypes.AdminBatchProductVariantRequest/page.mdx": "2024-11-12T09:36:22.780Z", - "references/types/WorkflowTypes/ProductWorkflow/interfaces/types.WorkflowTypes.ProductWorkflow.ExportProductsDTO/page.mdx": "2024-11-12T09:36:24.232Z" + "references/types/WorkflowTypes/ProductWorkflow/interfaces/types.WorkflowTypes.ProductWorkflow.ExportProductsDTO/page.mdx": "2024-11-12T09:36:24.232Z", + "app/contribution-guidelines/admin-translations/page.mdx": "2024-11-14T08:54:15.369Z" } \ No newline at end of file diff --git a/www/apps/resources/generated/files-map.mjs b/www/apps/resources/generated/files-map.mjs index d2f3c75df6e32..dcfcb7bb91aa4 100644 --- a/www/apps/resources/generated/files-map.mjs +++ b/www/apps/resources/generated/files-map.mjs @@ -556,8 +556,8 @@ export const filesMap = [ "pathname": "/commerce-modules/user/user-creation-flows" }, { - "filePath": "/www/apps/resources/app/contribution-guidelines/_admin-translations/page.mdx", - "pathname": "/contribution-guidelines/_admin-translations" + "filePath": "/www/apps/resources/app/contribution-guidelines/admin-translations/page.mdx", + "pathname": "/contribution-guidelines/admin-translations" }, { "filePath": "/www/apps/resources/app/contribution-guidelines/docs/page.mdx", diff --git a/www/apps/resources/generated/sidebar.mjs b/www/apps/resources/generated/sidebar.mjs index 39f95c46ad034..abd94d31dd52b 100644 --- a/www/apps/resources/generated/sidebar.mjs +++ b/www/apps/resources/generated/sidebar.mjs @@ -14925,6 +14925,14 @@ export const generatedSidebar = [ "path": "/contribution-guidelines/docs", "title": "Docs", "children": [] + }, + { + "loaded": true, + "isPathHref": true, + "type": "link", + "path": "/contribution-guidelines/admin-translations", + "title": "Admin Translations", + "children": [] } ] }, diff --git a/www/apps/resources/sidebar.mjs b/www/apps/resources/sidebar.mjs index f5b8ade77214d..278e09b51b04e 100644 --- a/www/apps/resources/sidebar.mjs +++ b/www/apps/resources/sidebar.mjs @@ -2104,12 +2104,12 @@ export const sidebar = sidebarAttachHrefCommonOptions([ { type: "link", path: "https://docs.medusajs.com/learn/deployment/general", - title: "General" + title: "General", }, { type: "link", path: "/deployment/medusa-application/railway", - title: "Railway" + title: "Railway", }, ], }, @@ -2393,10 +2393,11 @@ export const sidebar = sidebarAttachHrefCommonOptions([ path: "/contribution-guidelines/docs", title: "Docs", }, - // { - // path: "/contribution-guidelines/admin-translations", - // title: "Admin Translations", - // }, + { + type: "link", + path: "/contribution-guidelines/admin-translations", + title: "Admin Translations", + }, ], }, { From 79a3dc1e822220b20514f9e3b6f19f6a036ebc7d Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 14 Nov 2024 18:14:16 +0200 Subject: [PATCH 7/9] docs: update admin injection zones list (#10103) --- .../app/admin-widget-injection-zones/page.mdx | 944 +++++++++++------- www/apps/resources/generated/edit-dates.mjs | 2 +- www/apps/resources/providers/index.tsx | 2 +- 3 files changed, 597 insertions(+), 351 deletions(-) diff --git a/www/apps/resources/app/admin-widget-injection-zones/page.mdx b/www/apps/resources/app/admin-widget-injection-zones/page.mdx index 4d61b618f85a9..78768abb3197c 100644 --- a/www/apps/resources/app/admin-widget-injection-zones/page.mdx +++ b/www/apps/resources/app/admin-widget-injection-zones/page.mdx @@ -8,55 +8,7 @@ export const metadata = { This documentation page includes the list of injection zones you can add Admin Widgets to. -## Login Page - - - - - Injection Zone Name - Description - Additional Props - - - - - - - `login.before` - - - - - Added before the login form. - - - - - \- - - - - - - - `login.after` - - - - - Added after the login form. - - - - - \- - - - - -
- -## Order Pages +## Campaign Pages @@ -70,12 +22,12 @@ This documentation page includes the list of injection zones you can add Admin W - `order.list.before` + `campaign.list.before` - Added at the top of the orders list page. + Added at the top of the campaigns list page. @@ -87,12 +39,12 @@ This documentation page includes the list of injection zones you can add Admin W - `order.list.after` + `campaign.list.after` - Added at the bottom of the order list page. + Added at the bottom of the campaigns list page. @@ -104,21 +56,21 @@ This documentation page includes the list of injection zones you can add Admin W - `order.details.before` + `campaign.details.before` - Added at the top of the order details page + Added at the top of a campaign's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminOrder object + data, // AdminCampaign object } ``` @@ -127,21 +79,21 @@ This documentation page includes the list of injection zones you can add Admin W - `order.details.after` + `campaign.details.after` - Added at the end of the order details page. + Added at the bottom of a campaign's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminOrder object + data, // AdminCampaign object } ``` @@ -150,21 +102,21 @@ This documentation page includes the list of injection zones you can add Admin W - `order.details.side.before` + `campaign.details.side.before` - Added at the top of the second column in the order details page. + Added at the top of the second column in the campaign details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminOrder object + data, // AdminCampaign object } ``` @@ -173,21 +125,21 @@ This documentation page includes the list of injection zones you can add Admin W - `order.details.side.before` + `campaign.details.side.after` - Added at the end of the second column in the order details page. + Added at the bottom of the second column in the campaign details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminOrder object + data, // AdminCampaign object } ``` @@ -287,6 +239,20 @@ This documentation page includes the list of injection zones you can add Admin W + +
+ +## Customer Group Pages + + + + + Injection Zone Name + Description + Additional Props + + + @@ -370,7 +336,7 @@ This documentation page includes the list of injection zones you can add Admin W
-## Product Pages +## Inventory Pages @@ -384,12 +350,12 @@ This documentation page includes the list of injection zones you can add Admin W - `product.list.before` + `inventory_item.list.before` - Added at the top of the product list page. + Added at the top of the inventory list page. @@ -401,12 +367,12 @@ This documentation page includes the list of injection zones you can add Admin W - `product.list.after` + `inventory_item.list.after` - Added at the bottom of the products list page. + Added at the bottom of the inventory list page. @@ -418,21 +384,21 @@ This documentation page includes the list of injection zones you can add Admin W - `product.details.before` + `inventory_item.details.before` - Added at the top of the product details page. + Added at the top of the inventory item details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProduct object + data, // AdminInventoryItem object } ``` @@ -441,21 +407,21 @@ This documentation page includes the list of injection zones you can add Admin W - `product.details.after` + `inventory_item.details.after` - Added at the bottom of the product details page + Added at the bottom of the inventory item details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProduct object + data, // AdminInventoryItem object } ``` @@ -464,21 +430,21 @@ This documentation page includes the list of injection zones you can add Admin W - `product.details.side.before` + `inventory_item.details.side.before` - Added at the top of the second column in the product details page. + Added at the top of the second column in the inventory item details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProduct object + data, // AdminInventoryItem object } ``` @@ -487,52 +453,49 @@ This documentation page includes the list of injection zones you can add Admin W - `product.details.side.after` + `inventory_item.details.side.after` - Added at the bottom of the second column in the product details page. + Added at the end of the second column in the inventory item details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProduct object + data, // AdminInventoryItem object } ``` - - - - `product_collection.list.before` - - - - - Added at the top of the product collections list page. - - - + +
- \- +## Login Page - + + + + Injection Zone Name + Description + Additional Props + + - `product_collection.list.after` + `login.before` - Added at the bottom of the product collections list page. + Added before the login form. @@ -544,58 +507,43 @@ This documentation page includes the list of injection zones you can add Admin W - `product_collection.details.before` + `login.after` - Added at the top of the product collection details page. + Added after the login form. - - Type `DetailWidgetProps` imported from `@medusajs/framework/types` - ```ts blockStyle="inline" - { - data, // AdminProductCollection object - } - ``` + \- - - - - `product_collection.details.after` - - - - - Added at the bottom of the product collection details page. - - - - - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + +
- ```ts blockStyle="inline" - { - data, // AdminProductCollection object - } - ``` +## Order Pages - + + + + Injection Zone Name + Description + Additional Props + + - `product_category.list.before` + `order.list.before` - Added at the top of the product categories list page. + Added at the top of the orders list page. @@ -607,12 +555,12 @@ This documentation page includes the list of injection zones you can add Admin W - `product_category.list.after` + `order.list.after` - Added at the bottom of the product categories list page. + Added at the bottom of the order list page. @@ -624,21 +572,21 @@ This documentation page includes the list of injection zones you can add Admin W - `product_category.details.before` + `order.details.before` - Added at the top of the product category details page. + Added at the top of the order details page - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProductCategory object + data, // AdminOrder object } ``` @@ -647,21 +595,21 @@ This documentation page includes the list of injection zones you can add Admin W - `product_category.details.after` + `order.details.after` - Added at the bottom of the product category details page. + Added at the end of the order details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProductCategory object + data, // AdminOrder object } ``` @@ -670,21 +618,21 @@ This documentation page includes the list of injection zones you can add Admin W - `product_category.details.side.before` + `order.details.side.before` - Added at the top of the second column in the product category details page. + Added at the top of the second column in the order details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProductCategory object + data, // AdminOrder object } ``` @@ -693,21 +641,21 @@ This documentation page includes the list of injection zones you can add Admin W - `product_category.details.side.after` + `order.details.side.after` - Added at the bottom of the second column in the product category details page. + Added at the end of the second column in the order details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminProductCategory object + data, // AdminOrder object } ``` @@ -716,7 +664,7 @@ This documentation page includes the list of injection zones you can add Admin W
-## Pricing Pages +## Price List Pages @@ -856,7 +804,7 @@ This documentation page includes the list of injection zones you can add Admin W
-## Promotion Pages +## Product Pages @@ -870,12 +818,12 @@ This documentation page includes the list of injection zones you can add Admin W - `promotion.list.before` + `product.list.before` - Added at the top of the promotions list page. + Added at the top of the product list page. @@ -887,12 +835,12 @@ This documentation page includes the list of injection zones you can add Admin W - `promotion.list.after` + `product.list.after` - Added at the bottom of the promotions list page. + Added at the bottom of the products list page. @@ -904,21 +852,21 @@ This documentation page includes the list of injection zones you can add Admin W - `promotion.details.before` + `product.details.before` - Added at the top of a promotion's details page. + Added at the top of the product details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminPromotion object + data, // AdminProduct object } ``` @@ -927,21 +875,21 @@ This documentation page includes the list of injection zones you can add Admin W - `promotion.details.after` + `product.details.after` - Added at the bottom of a promotion's details page. + Added at the bottom of the product details page - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminPromotion object + data, // AdminProduct object } ``` @@ -950,21 +898,21 @@ This documentation page includes the list of injection zones you can add Admin W - `promotion.details.side.before` + `product.details.side.before` - Added at the top of the second column in the promotion details page. + Added at the top of the second column in the product details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminPromotion object + data, // AdminProduct object } ``` @@ -973,35 +921,49 @@ This documentation page includes the list of injection zones you can add Admin W - `promotion.details.side.after` + `product.details.side.after` - Added at the bottom of the second column in the promotion details page. + Added at the bottom of the second column in the product details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminPromotion object + data, // AdminProduct object } ``` + +
+ +## Product Collection Pages + + + + + Injection Zone Name + Description + Additional Props + + + - `campaign.list.before` + `product_collection.list.before` - Added at the top of the campaigns list page. + Added at the top of the product collections list page. @@ -1013,12 +975,12 @@ This documentation page includes the list of injection zones you can add Admin W - `campaign.list.after` + `product_collection.list.after` - Added at the bottom of the campaigns list page. + Added at the bottom of the product collections list page. @@ -1030,21 +992,21 @@ This documentation page includes the list of injection zones you can add Admin W - `campaign.details.before` + `product_collection.details.before` - Added at the top of a campaign's details page. + Added at the top of the product collection details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminCampaign object + data, // AdminProductCollection object } ``` @@ -1053,44 +1015,92 @@ This documentation page includes the list of injection zones you can add Admin W - `campaign.details.after` + `product_collection.details.after` - Added at the bottom of a campaign's details page. + Added at the bottom of the product collection details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminCampaign object + data, // AdminProductCollection object } ``` + +
+ +## Product Category Pages + + + + + Injection Zone Name + Description + Additional Props + + + - `campaign.details.side.before` + `product_category.list.before` - Added at the top of the second column in the campaign details page. + Added at the top of the product categories list page. + + + + + \- + + + + + + + `product_category.list.after` + + + + + Added at the bottom of the product categories list page. + + + + + \- + + + + + + + `product_category.details.before` + + + + + Added at the top of the product category details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminCampaign object + data, // AdminProductCategory object } ``` @@ -1099,21 +1109,67 @@ This documentation page includes the list of injection zones you can add Admin W - `campaign.details.side.after` + `product_category.details.after` - Added at the bottom of the second column in the campaign details page. + Added at the bottom of the product category details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminCampaign object + data, // AdminProductCategory object + } + ``` + + + + + + + `product_category.details.side.before` + + + + + Added at the top of the second column in the product category details page. + + + + + Type `DetailWidgetProps` imported from `@medusajs/framework/types` + + ```ts blockStyle="inline" + { + data, // AdminProductCategory object + } + ``` + + + + + + + `product_category.details.side.after` + + + + + Added at the bottom of the second column in the product category details page. + + + + + Type `DetailWidgetProps` imported from `@medusajs/framework/types` + + ```ts blockStyle="inline" + { + data, // AdminProductCategory object } ``` @@ -1122,9 +1178,9 @@ This documentation page includes the list of injection zones you can add Admin W
-## Setting Pages -### User Pages + +## Promotion Pages @@ -1138,12 +1194,12 @@ This documentation page includes the list of injection zones you can add Admin W - `user.list.before` + `promotion.list.before` - Added at the top of the users list page. + Added at the top of the promotions list page. @@ -1155,12 +1211,12 @@ This documentation page includes the list of injection zones you can add Admin W - `user.list.after` + `promotion.list.after` - Added at the bottom of the users list page. + Added at the bottom of the promotions list page. @@ -1172,21 +1228,21 @@ This documentation page includes the list of injection zones you can add Admin W - `user.details.before` + `promotion.details.before` - Added at the top of a user's details page. + Added at the top of a promotion's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminUser object + data, // AdminPromotion object } ``` @@ -1195,58 +1251,44 @@ This documentation page includes the list of injection zones you can add Admin W - `user.details.after` + `promotion.details.after` - Added at the bottom of a user's details page. + Added at the bottom of a promotion's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminUser object + data, // AdminPromotion object } ``` - -
- -### Store Pages - - - - - Injection Zone Name - Description - Additional Props - - - - `store.details.before` + `promotion.details.side.before` - Added at the top of a store's details page. + Added at the top of the second column in the promotion details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminStore object + data, // AdminPromotion object } ``` @@ -1255,21 +1297,21 @@ This documentation page includes the list of injection zones you can add Admin W - `store.details.after` + `promotion.details.side.after` - Added at the bottom of a store's details page. + Added at the bottom of the second column in the promotion details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminStore object + data, // AdminPromotion object } ``` @@ -1278,7 +1320,9 @@ This documentation page includes the list of injection zones you can add Admin W
-### Profile Pages +## Setting Pages + +### API Key Pages @@ -1292,21 +1336,55 @@ This documentation page includes the list of injection zones you can add Admin W - `profile.details.before` + `api_key.list.before` - Added at the top of a profile's details page. + Added at the top of the API keys list page. + + + + + \- + + + + + + + `api_key.list.after` + + + + + Added at the bottom of the API keys list page. + + + + + \- + + + + + + + `api_key.details.before` + + + + + Added at the top of a API key's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminUser object + data, // AdminApiKey object } ``` @@ -1315,21 +1393,21 @@ This documentation page includes the list of injection zones you can add Admin W - `profile.details.after` + `api_key.details.after` - Added at the bottom of a profile's details page. + Added at the bottom of a API key's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminUser object + data, // AdminApiKey object } ``` @@ -1338,7 +1416,7 @@ This documentation page includes the list of injection zones you can add Admin W
-### Region Pages +### Location Pages @@ -1352,12 +1430,12 @@ This documentation page includes the list of injection zones you can add Admin W - `region.list.before` + `location.list.before` - Added at the top of the regions list page. + Added at the top of the locations list page. @@ -1369,12 +1447,12 @@ This documentation page includes the list of injection zones you can add Admin W - `region.list.after` + `location.list.after` - Added at the bottom of the regions list page. + Added at the bottom of the locations list page. @@ -1386,21 +1464,127 @@ This documentation page includes the list of injection zones you can add Admin W - `region.details.before` + `location.details.before` - Added at the top of a region's details page. + Added at the top of a location's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` + + ```ts blockStyle="inline" + { + data, // AdminStockLocation object + } + ``` + + + + + + + `location.details.after` + + + + + Added at the bottom of a location's details page. + + + + + Type `DetailWidgetProps` imported from `@medusajs/framework/types` + + ```ts blockStyle="inline" + { + data, // AdminStockLocation object + } + ``` + + + + + + + `location.details.side.before` + + + + + Added at the top of the second column in the location details page. + + + + + Type `DetailWidgetProps` imported from `@medusajs/framework/types` + + ```ts blockStyle="inline" + { + data, // AdminStockLocation object + } + ``` + + + + + + + `location.details.side.after` + + + + + Added at the bottom of the second column in the location details page. + + + + + Type `DetailWidgetProps` imported from `@medusajs/framework/types` + + ```ts blockStyle="inline" + { + data, // AdminStockLocation object + } + ``` + + + + +
+ +### Profile Pages + + + + + Injection Zone Name + Description + Additional Props + + + + + + + `profile.details.before` + + + + + Added at the top of a profile's details page. + + + + + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminRegion object + data, // AdminUser object } ``` @@ -1409,21 +1593,21 @@ This documentation page includes the list of injection zones you can add Admin W - `region.details.after` + `profile.details.after` - Added at the bottom of a region's details page. + Added at the bottom of a profile's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminRegion object + data, // AdminUser object } ``` @@ -1432,7 +1616,7 @@ This documentation page includes the list of injection zones you can add Admin W
-### Shipping Profile Pages +### Region Pages @@ -1446,12 +1630,12 @@ This documentation page includes the list of injection zones you can add Admin W - `shipping_profile.list.before` + `region.list.before` - Added at the top of the shipping profiles list page. + Added at the top of the regions list page. @@ -1463,12 +1647,12 @@ This documentation page includes the list of injection zones you can add Admin W - `shipping_profile.list.after` + `region.list.after` - Added at the bottom of the shipping profiles list page. + Added at the bottom of the regions list page. @@ -1480,21 +1664,21 @@ This documentation page includes the list of injection zones you can add Admin W - `shipping_profile.details.before` + `region.details.before` - Added at the top of a shipping profile's details page. + Added at the top of a region's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminShippingProfile object + data, // AdminRegion object } ``` @@ -1503,21 +1687,21 @@ This documentation page includes the list of injection zones you can add Admin W - `shipping_profile.details.after` + `region.details.after` - Added at the bottom of a shipping profile's details page. + Added at the bottom of a region's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminShippingProfile object + data, // AdminRegion object } ``` @@ -1526,7 +1710,7 @@ This documentation page includes the list of injection zones you can add Admin W
-### Location Pages +### Reservation Pages @@ -1540,12 +1724,12 @@ This documentation page includes the list of injection zones you can add Admin W - `location.list.before` + `reservation.list.before` - Added at the top of the locations list page. + Added at the top of the reservations list page. @@ -1557,12 +1741,12 @@ This documentation page includes the list of injection zones you can add Admin W - `location.list.after` + `reservation.list.after` - Added at the bottom of the locations list page. + Added at the bottom of the reservations list page. @@ -1574,21 +1758,21 @@ This documentation page includes the list of injection zones you can add Admin W - `location.details.before` + `reservation.details.before` - Added at the top of a location's details page. + Added at the top of a reservation item's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminStockLocation object + data, // AdminReservation object } ``` @@ -1597,21 +1781,21 @@ This documentation page includes the list of injection zones you can add Admin W - `location.details.after` + `reservation.details.after` - Added at the bottom of a location's details page. + Added at the bottom of a reservation item's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminStockLocation object + data, // AdminReservation object } ``` @@ -1620,21 +1804,21 @@ This documentation page includes the list of injection zones you can add Admin W - `location.details.side.before` + `reservation.details.side.before` - Added at the top of the second column in the location details page. + Added at the top of the second column in the reservation item details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminStockLocation object + data, // AdminReservation object } ``` @@ -1643,21 +1827,21 @@ This documentation page includes the list of injection zones you can add Admin W - `location.details.side.after` + `reservation.details.side.after` - Added at the bottom of the second column in the location details page. + Added at the bottom of the second column in the reservation item details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminStockLocation object + data, // AdminReservation object } ``` @@ -1666,6 +1850,54 @@ This documentation page includes the list of injection zones you can add Admin W
+### Return Reason Pages + + + + + Injection Zone Name + Description + Additional Props + + + + + + + `return_reason.list.before` + + + + + Added at the top of the return reasons list page. + + + + + \- + + + + + + + `return_reason.list.after` + + + + + Added at the bottom of the return reasons list page. + + + + + \- + + + + +
+ ### Sales Channel Pages @@ -1760,7 +1992,7 @@ This documentation page includes the list of injection zones you can add Admin W
-### Reservation Pages +### Shipping Profile Pages @@ -1774,12 +2006,12 @@ This documentation page includes the list of injection zones you can add Admin W - `reservation.list.before` + `shipping_profile.list.before` - Added at the top of the reservations list page. + Added at the top of the shipping profiles list page. @@ -1791,12 +2023,12 @@ This documentation page includes the list of injection zones you can add Admin W - `reservation.list.after` + `shipping_profile.list.after` - Added at the bottom of the reservations list page. + Added at the bottom of the shipping profiles list page. @@ -1808,21 +2040,21 @@ This documentation page includes the list of injection zones you can add Admin W - `reservation.details.before` + `shipping_profile.details.before` - Added at the top of a reservation item's details page. + Added at the top of a shipping profile's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminReservation object + data, // AdminShippingProfile object } ``` @@ -1831,44 +2063,58 @@ This documentation page includes the list of injection zones you can add Admin W - `reservation.details.after` + `shipping_profile.details.after` - Added at the bottom of a reservation item's details page. + Added at the bottom of a shipping profile's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminReservation object + data, // AdminShippingProfile object } ``` + +
+ +### Store Pages + + + + + Injection Zone Name + Description + Additional Props + + + - `reservation.details.side.before` + `store.details.before` - Added at the top of the second column in the reservation item details page. + Added at the top of a store's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminReservation object + data, // AdminStore object } ``` @@ -1877,21 +2123,21 @@ This documentation page includes the list of injection zones you can add Admin W - `reservation.details.side.after` + `store.details.after` - Added at the bottom of the second column in the reservation item details page. + Added at the bottom of a store's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminReservation object + data, // AdminStore object } ``` @@ -1900,7 +2146,7 @@ This documentation page includes the list of injection zones you can add Admin W
-### API Key Pages +### Tax Pages @@ -1914,12 +2160,12 @@ This documentation page includes the list of injection zones you can add Admin W - `api_key.list.before` + `tax.list.before` - Added at the top of the API keys list page. + Added at the top of the tax regions list page. @@ -1931,12 +2177,12 @@ This documentation page includes the list of injection zones you can add Admin W - `api_key.list.after` + `tax.list.after` - Added at the bottom of the API keys list page. + Added at the bottom of the tax regions list page. @@ -1948,21 +2194,21 @@ This documentation page includes the list of injection zones you can add Admin W - `api_key.details.before` + `tax.details.before` - Added at the top of a API key's details page. + Added at the top of a tax region's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminApiKey object + data, // AdminTaxRegion object } ``` @@ -1971,21 +2217,21 @@ This documentation page includes the list of injection zones you can add Admin W - `api_key.details.after` + `tax.details.after` - Added at the bottom of a API key's details page. + Added at the bottom of a tax region's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminApiKey object + data, // AdminTaxRegion object } ``` @@ -1994,7 +2240,7 @@ This documentation page includes the list of injection zones you can add Admin W
-### Workflow Pages +### User Pages @@ -2008,12 +2254,12 @@ This documentation page includes the list of injection zones you can add Admin W - `workflow.list.before` + `user.list.before` - Added at the top of the workflows list page. + Added at the top of the users list page. @@ -2025,12 +2271,12 @@ This documentation page includes the list of injection zones you can add Admin W - `workflow.list.after` + `user.list.after` - Added at the bottom of the workflows list page. + Added at the bottom of the users list page. @@ -2042,21 +2288,21 @@ This documentation page includes the list of injection zones you can add Admin W - `workflow.details.before` + `user.details.before` - Added at the top of a workflow execution's details page. + Added at the top of a user's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminWorkflowExecution object + data, // AdminUser object } ``` @@ -2065,21 +2311,21 @@ This documentation page includes the list of injection zones you can add Admin W - `workflow.details.after` + `user.details.after` - Added at the bottom of a workflow execution's details page. + Added at the bottom of a user's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminWorkflowExecution object + data, // AdminUser object } ``` @@ -2088,7 +2334,7 @@ This documentation page includes the list of injection zones you can add Admin W
-### Tax Pages +### Workflow Pages @@ -2102,12 +2348,12 @@ This documentation page includes the list of injection zones you can add Admin W - `tax.list.before` + `workflow.list.before` - Added at the top of the tax regions list page. + Added at the top of the workflows list page. @@ -2119,12 +2365,12 @@ This documentation page includes the list of injection zones you can add Admin W - `tax.list.after` + `workflow.list.after` - Added at the bottom of the tax regions list page. + Added at the bottom of the workflows list page. @@ -2136,21 +2382,21 @@ This documentation page includes the list of injection zones you can add Admin W - `tax.details.before` + `workflow.details.before` - Added at the top of a tax region's details page. + Added at the top of a workflow execution's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminTaxRegion object + data, // AdminWorkflowExecution object } ``` @@ -2159,21 +2405,21 @@ This documentation page includes the list of injection zones you can add Admin W - `tax.details.after` + `workflow.details.after` - Added at the bottom of a tax region's details page. + Added at the bottom of a workflow execution's details page. - Type `DetailWidgetProps` imported from `@medusajs/framework/types` + Type `DetailWidgetProps` imported from `@medusajs/framework/types` ```ts blockStyle="inline" { - data, // AdminTaxRegion object + data, // AdminWorkflowExecution object } ``` diff --git a/www/apps/resources/generated/edit-dates.mjs b/www/apps/resources/generated/edit-dates.mjs index f790a68300902..15e13414f6590 100644 --- a/www/apps/resources/generated/edit-dates.mjs +++ b/www/apps/resources/generated/edit-dates.mjs @@ -233,7 +233,7 @@ export const generatedEditDates = { "app/architectural-modules/file/page.mdx": "2024-07-01T10:21:19+03:00", "app/architectural-modules/event/page.mdx": "2024-05-28T13:25:03+03:00", "app/architectural-modules/cache/create/page.mdx": "2024-10-16T08:51:35.074Z", - "app/admin-widget-injection-zones/page.mdx": "2024-09-30T08:43:53.147Z", + "app/admin-widget-injection-zones/page.mdx": "2024-11-14T15:10:36.495Z", "app/architectural-modules/notification/page.mdx": "2024-10-15T12:51:28.735Z", "app/architectural-modules/event/create/page.mdx": "2024-11-12T11:54:51.583Z", "references/core_flows/Order/functions/core_flows.Order.orderEditUpdateItemQuantityValidationStep/page.mdx": "2024-08-20T00:10:58.913Z", diff --git a/www/apps/resources/providers/index.tsx b/www/apps/resources/providers/index.tsx index ae55b911c5fc1..79bd672a1fb5e 100644 --- a/www/apps/resources/providers/index.tsx +++ b/www/apps/resources/providers/index.tsx @@ -34,7 +34,7 @@ const Providers = ({ children }: ProvidersProps) => { {children} From a153bc477c421cd3cfc6f2cb7e30f2f3661f5922 Mon Sep 17 00:00:00 2001 From: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:32:36 +0100 Subject: [PATCH 8/9] fix(admin-shared,dashboard): Add missing injection zones (#10098) **What** - Adds missing InjectionZones for ProductVariant details page. - Removes v1 related zones, such as GiftCard and DraftOrder. --- .changeset/mean-rice-cough.md | 6 ++++ .../src/extensions/widgets/constants.ts | 32 ++++++------------- .../product-variant-detail.tsx | 12 ++++--- 3 files changed, 23 insertions(+), 27 deletions(-) create mode 100644 .changeset/mean-rice-cough.md diff --git a/.changeset/mean-rice-cough.md b/.changeset/mean-rice-cough.md new file mode 100644 index 0000000000000..511e96c69f030 --- /dev/null +++ b/.changeset/mean-rice-cough.md @@ -0,0 +1,6 @@ +--- +"@medusajs/admin-shared": patch +"@medusajs/dashboard": patch +--- + +fix(admin-shared,dashboard): Add missing Injection Zones and remove unused zones" diff --git a/packages/admin/admin-shared/src/extensions/widgets/constants.ts b/packages/admin/admin-shared/src/extensions/widgets/constants.ts index 9a3a4ab313b25..b4a83fc1a97cc 100644 --- a/packages/admin/admin-shared/src/extensions/widgets/constants.ts +++ b/packages/admin/admin-shared/src/extensions/widgets/constants.ts @@ -7,15 +7,6 @@ const ORDER_INJECTION_ZONES = [ "order.list.after", ] as const -const DRAFT_ORDER_INJECTION_ZONES = [ - "draft_order.list.before", - "draft_order.list.after", - "draft_order.details.side.before", - "draft_order.details.side.after", - "draft_order.details.before", - "draft_order.details.after", -] as const - const CUSTOMER_INJECTION_ZONES = [ "customer.details.before", "customer.details.after", @@ -39,6 +30,13 @@ const PRODUCT_INJECTION_ZONES = [ "product.details.side.after", ] as const +const PRODUCT_VARIANT_INJECTION_ZONES = [ + "product_variant.details.before", + "product_variant.details.after", + "product_variant.details.side.before", + "product_variant.details.side.after", +] as const + const PRODUCT_COLLECTION_INJECTION_ZONES = [ "product_collection.details.before", "product_collection.details.after", @@ -96,15 +94,6 @@ const CAMPAIGN_INJECTION_ZONES = [ "campaign.list.after", ] as const -const GIFT_CARD_INJECTION_ZONES = [ - "gift_card.details.before", - "gift_card.details.after", - "gift_card.list.before", - "gift_card.list.after", - "custom_gift_card.before", - "custom_gift_card.after", -] as const - const USER_INJECTION_ZONES = [ "user.details.before", "user.details.after", @@ -204,15 +193,16 @@ const INVENTORY_ITEM_INJECTION_ZONES = [ */ export const INJECTION_ZONES = [ ...ORDER_INJECTION_ZONES, - ...DRAFT_ORDER_INJECTION_ZONES, ...CUSTOMER_INJECTION_ZONES, ...CUSTOMER_GROUP_INJECTION_ZONES, ...PRODUCT_INJECTION_ZONES, + ...PRODUCT_VARIANT_INJECTION_ZONES, ...PRODUCT_COLLECTION_INJECTION_ZONES, ...PRODUCT_CATEGORY_INJECTION_ZONES, + ...PRODUCT_TYPE_INJECTION_ZONES, + ...PRODUCT_TAG_INJECTION_ZONES, ...PRICE_LIST_INJECTION_ZONES, ...PROMOTION_INJECTION_ZONES, - ...GIFT_CARD_INJECTION_ZONES, ...USER_INJECTION_ZONES, ...STORE_INJECTION_ZONES, ...PROFILE_INJECTION_ZONES, @@ -226,8 +216,6 @@ export const INJECTION_ZONES = [ ...WORKFLOW_INJECTION_ZONES, ...CAMPAIGN_INJECTION_ZONES, ...TAX_INJECTION_ZONES, - ...PRODUCT_TYPE_INJECTION_ZONES, - ...PRODUCT_TAG_INJECTION_ZONES, ...RETURN_REASON_INJECTION_ZONES, ...INVENTORY_ITEM_INJECTION_ZONES, ] as const diff --git a/packages/admin/dashboard/src/routes/product-variants/product-variant-detail/product-variant-detail.tsx b/packages/admin/dashboard/src/routes/product-variants/product-variant-detail/product-variant-detail.tsx index 95fcb802b209e..d7e4c116d4fd6 100644 --- a/packages/admin/dashboard/src/routes/product-variants/product-variant-detail/product-variant-detail.tsx +++ b/packages/admin/dashboard/src/routes/product-variants/product-variant-detail/product-variant-detail.tsx @@ -4,6 +4,7 @@ import { useProductVariant } from "../../../hooks/api/products" import { TwoColumnPageSkeleton } from "../../../components/common/skeleton" import { TwoColumnPage } from "../../../components/layout/pages" +import { useDashboardExtension } from "../../../extensions" import { VariantGeneralSection } from "./components/variant-general-section" import { InventorySectionPlaceholder, @@ -28,6 +29,8 @@ export const ProductVariantDetail = () => { } ) + const { getWidgets } = useDashboardExtension() + if (isLoading || !variant) { return ( { hasOutlet showJSON showMetadata - // TODO: Add widgets zones for variant detail page widgets={{ - after: [], - before: [], - sideAfter: [], - sideBefore: [], + after: getWidgets("product_variant.details.after"), + before: getWidgets("product_variant.details.before"), + sideAfter: getWidgets("product_variant.details.side.after"), + sideBefore: getWidgets("product_variant.details.side.before"), }} > From dea86d8c8774d5badadefbc92352d5145245a22f Mon Sep 17 00:00:00 2001 From: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:32:52 +0100 Subject: [PATCH 9/9] fix(dashboard): Fix active nav link styling for built-in routes (#10082) **What** - Ensures that NavLinks are correctly styled for both built-in and extension routes. --- .changeset/rude-cooks-knock.md | 5 +++ .../components/layout/nav-item/nav-item.tsx | 43 +++++++++++-------- 2 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 .changeset/rude-cooks-knock.md diff --git a/.changeset/rude-cooks-knock.md b/.changeset/rude-cooks-knock.md new file mode 100644 index 0000000000000..a436f56e49681 --- /dev/null +++ b/.changeset/rude-cooks-knock.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): Fix active nav link styling for built-in routes diff --git a/packages/admin/dashboard/src/components/layout/nav-item/nav-item.tsx b/packages/admin/dashboard/src/components/layout/nav-item/nav-item.tsx index 562ff1be3c9d3..89ddc174b5b5e 100644 --- a/packages/admin/dashboard/src/components/layout/nav-item/nav-item.tsx +++ b/packages/admin/dashboard/src/components/layout/nav-item/nav-item.tsx @@ -99,20 +99,27 @@ export const NavItem = ({ const navLinkClassNames = useCallback( ({ + to, isActive, isNested = false, isSetting = false, }: { + to: string isActive: boolean isNested?: boolean isSetting?: boolean - }) => - clx(BASE_NAV_LINK_CLASSES, { + }) => { + if (["core", "setting"].includes(type)) { + isActive = pathname.startsWith(to) + } + + return clx(BASE_NAV_LINK_CLASSES, { [NESTED_NAV_LINK_CLASSES]: isNested, [ACTIVE_NAV_LINK_CLASSES]: isActive, [SETTING_NAV_LINK_CLASSES]: isSetting, - }), - [] + }) + }, + [type, pathname] ) const isSetting = type === "setting" @@ -130,11 +137,11 @@ export const NavItem = ({ } : undefined } - className={(props) => - clx(navLinkClassNames({ ...props, isSetting }), { + className={({ isActive }) => { + return clx(navLinkClassNames({ isActive, isSetting, to }), { "max-lg:hidden": !!items?.length, }) - } + }} > {type !== "setting" && (
@@ -169,15 +176,16 @@ export const NavItem = ({ - clx( + className={({ isActive }) => { + return clx( navLinkClassNames({ - ...props, - isNested: true, + to, + isActive, isSetting, + isNested: true, }) ) - } + }} > {label} @@ -192,15 +200,16 @@ export const NavItem = ({ - clx( + className={({ isActive }) => { + return clx( navLinkClassNames({ - ...props, - isNested: true, + to: item.to, + isActive, isSetting, + isNested: true, }) ) - } + }} > {item.label}