From b4a02413e20a181fa60a73f561ed86c73e801f75 Mon Sep 17 00:00:00 2001
From: Kasper Fabricius Kristensen
<45367945+kasperkristensen@users.noreply.github.com>
Date: Sun, 26 May 2024 20:30:20 +0200
Subject: [PATCH] feat(dashboard,admin-shared): Add more injection zones
(orders, collections, categories) (#7447)
* add more injection zones
* fix position
---
.../src/extensions/widgets/constants.ts | 6 ++
.../category-detail/category-detail.tsx | 41 ++++++++++--
.../category-list/category-list.tsx | 19 ++++++
.../collection-detail/collection-detail.tsx | 18 ++++++
.../collection-list/collection-list.tsx | 18 ++++++
.../orders/order-detail/order-detail.tsx | 63 ++++++++++++++-----
.../routes/orders/order-list/order-list.tsx | 17 +++++
.../product-detail/product-detail.tsx | 10 +--
8 files changed, 169 insertions(+), 23 deletions(-)
diff --git a/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts b/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts
index d2fe06699b..8be91408da 100644
--- a/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts
+++ b/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts
@@ -1,6 +1,8 @@
const ORDER_INJECTION_ZONES = [
"order.details.before",
"order.details.after",
+ "order.details.side.before",
+ "order.details.side.after",
"order.list.before",
"order.list.after",
] as const
@@ -8,6 +10,8 @@ const ORDER_INJECTION_ZONES = [
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
@@ -45,6 +49,8 @@ const PRODUCT_COLLECTION_INJECTION_ZONES = [
const PRODUCT_CATEGORY_INJECTION_ZONES = [
"product_category.details.before",
"product_category.details.after",
+ "product_category.details.side.before",
+ "product_category.details.side.after",
"product_category.list.before",
"product_category.list.after",
] as const
diff --git a/packages/admin-next/dashboard/src/routes/categories/category-detail/category-detail.tsx b/packages/admin-next/dashboard/src/routes/categories/category-detail/category-detail.tsx
index 434694ea2a..e7d30bb708 100644
--- a/packages/admin-next/dashboard/src/routes/categories/category-detail/category-detail.tsx
+++ b/packages/admin-next/dashboard/src/routes/categories/category-detail/category-detail.tsx
@@ -6,6 +6,11 @@ import { CategoryOrganizationSection } from "./components/category-organization-
import { CategoryProductSection } from "./components/category-product-section"
import { categoryLoader } from "./loader"
+import after from "virtual:medusa/widgets/product_category/details/after"
+import before from "virtual:medusa/widgets/product_category/details/before"
+import sideAfter from "virtual:medusa/widgets/product_category/details/side/after"
+import sideBefore from "virtual:medusa/widgets/product_category/details/side/before"
+
export const CategoryDetail = () => {
const { id } = useParams()
@@ -31,17 +36,45 @@ export const CategoryDetail = () => {
return (
-
+ {before.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+
-
+ {after.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+
-
+
+ {sideBefore.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
-
+ {sideAfter.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+
diff --git a/packages/admin-next/dashboard/src/routes/categories/category-list/category-list.tsx b/packages/admin-next/dashboard/src/routes/categories/category-list/category-list.tsx
index 01ee589e2b..99d5b7f35c 100644
--- a/packages/admin-next/dashboard/src/routes/categories/category-list/category-list.tsx
+++ b/packages/admin-next/dashboard/src/routes/categories/category-list/category-list.tsx
@@ -1,9 +1,28 @@
+import { Outlet } from "react-router-dom"
import { CategoryListTable } from "./components/category-list-table"
+import after from "virtual:medusa/widgets/product_category/list/after"
+import before from "virtual:medusa/widgets/product_category/list/before"
+
export const CategoryList = () => {
return (
+ {before.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+ {after.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+
)
}
diff --git a/packages/admin-next/dashboard/src/routes/collections/collection-detail/collection-detail.tsx b/packages/admin-next/dashboard/src/routes/collections/collection-detail/collection-detail.tsx
index 3f433d127c..c75fa8482b 100644
--- a/packages/admin-next/dashboard/src/routes/collections/collection-detail/collection-detail.tsx
+++ b/packages/admin-next/dashboard/src/routes/collections/collection-detail/collection-detail.tsx
@@ -1,10 +1,14 @@
import { Outlet, json, useLoaderData, useParams } from "react-router-dom"
+
import { JsonViewSection } from "../../../components/common/json-view-section"
import { useCollection } from "../../../hooks/api/collections"
import { CollectionGeneralSection } from "./components/collection-general-section"
import { CollectionProductSection } from "./components/collection-product-section"
import { collectionLoader } from "./loader"
+import after from "virtual:medusa/widgets/product_collection/details/after"
+import before from "virtual:medusa/widgets/product_collection/details/before"
+
export const CollectionDetail = () => {
const initialData = useLoaderData() as Awaited<
ReturnType
@@ -29,8 +33,22 @@ export const CollectionDetail = () => {
return (
+ {before.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+ {after.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
diff --git a/packages/admin-next/dashboard/src/routes/collections/collection-list/collection-list.tsx b/packages/admin-next/dashboard/src/routes/collections/collection-list/collection-list.tsx
index fa50d1e886..e9ef1cb4df 100644
--- a/packages/admin-next/dashboard/src/routes/collections/collection-list/collection-list.tsx
+++ b/packages/admin-next/dashboard/src/routes/collections/collection-list/collection-list.tsx
@@ -1,10 +1,28 @@
import { Outlet } from "react-router-dom"
+
import { CollectionListTable } from "./components/collection-list-table"
+import after from "virtual:medusa/widgets/product_collection/list/after"
+import before from "virtual:medusa/widgets/product_collection/list/before"
+
export const CollectionList = () => {
return (
+ {before.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+ {after.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
)
diff --git a/packages/admin-next/dashboard/src/routes/orders/order-detail/order-detail.tsx b/packages/admin-next/dashboard/src/routes/orders/order-detail/order-detail.tsx
index d7b7f03011..5f8dd965e4 100644
--- a/packages/admin-next/dashboard/src/routes/orders/order-detail/order-detail.tsx
+++ b/packages/admin-next/dashboard/src/routes/orders/order-detail/order-detail.tsx
@@ -1,15 +1,19 @@
import { Outlet, useLoaderData, useParams } from "react-router-dom"
import { JsonViewSection } from "../../../components/common/json-view-section"
+import { useOrder } from "../../../hooks/api/orders"
import { OrderActivitySection } from "./components/order-activity-section"
import { OrderCustomerSection } from "./components/order-customer-section"
import { OrderFulfillmentSection } from "./components/order-fulfillment-section"
import { OrderGeneralSection } from "./components/order-general-section"
-import { OrderPaymentSection } from "./components/order-payment-section"
import { OrderSummarySection } from "./components/order-summary-section"
import { DEFAULT_FIELDS } from "./constants"
import { orderLoader } from "./loader"
-import { useOrder } from "../../../hooks/api/orders"
+
+import after from "virtual:medusa/widgets/order/details/after"
+import before from "virtual:medusa/widgets/order/details/before"
+import sideAfter from "virtual:medusa/widgets/order/details/side/after"
+import sideBefore from "virtual:medusa/widgets/order/details/side/before"
export const OrderDetail = () => {
const initialData = useLoaderData() as Awaited>
@@ -35,21 +39,52 @@ export const OrderDetail = () => {
}
return (
-
-
-
-
- {/*
*/}
-
-
+
+ {before.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+
+
+
+
+ {/*
*/}
+
+ {after.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+
+
+
+
+
+ {sideBefore.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+ {sideAfter.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+
+
+
-
-
-
-
-
diff --git a/packages/admin-next/dashboard/src/routes/orders/order-list/order-list.tsx b/packages/admin-next/dashboard/src/routes/orders/order-list/order-list.tsx
index 587cb88bf5..033ed23345 100644
--- a/packages/admin-next/dashboard/src/routes/orders/order-list/order-list.tsx
+++ b/packages/admin-next/dashboard/src/routes/orders/order-list/order-list.tsx
@@ -1,9 +1,26 @@
import { OrderListTable } from "./components/order-list-table"
+import after from "virtual:medusa/widgets/order/list/after"
+import before from "virtual:medusa/widgets/order/list/before"
+
export const OrderList = () => {
return (
+ {before.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
+ {after.widgets.map((w, i) => {
+ return (
+
+
+
+ )
+ })}
)
}
diff --git a/packages/admin-next/dashboard/src/routes/products/product-detail/product-detail.tsx b/packages/admin-next/dashboard/src/routes/products/product-detail/product-detail.tsx
index 781cd3d088..eff4a3be34 100644
--- a/packages/admin-next/dashboard/src/routes/products/product-detail/product-detail.tsx
+++ b/packages/admin-next/dashboard/src/routes/products/product-detail/product-detail.tsx
@@ -44,7 +44,7 @@ export const ProductDetail = () => {
)
})}
-
+
@@ -57,11 +57,11 @@ export const ProductDetail = () => {
)
})}
-
-
+
{sideBefore.widgets.map((w, i) => {
return (
@@ -79,8 +79,8 @@ export const ProductDetail = () => {
)
})}
-