chore(dashboard): Remove feature flag and always load v2 admin (#7251)
This commit is contained in:
1 parent
309c04afe8
commit
9d0bfc2b39
5 files changed
+50
-341
No files matched your search
@@ -0,0 +1,16 @@
|
|||||||
|
import { RouteObject } from "react-router-dom"
|
||||||
|
|
||||||
|
import routes from "medusa-admin:routes/pages"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI Route extensions.
|
||||||
|
*/
|
||||||
|
export const RouteExtensions: RouteObject[] = routes.pages.map((ext) => {
|
||||||
|
return {
|
||||||
|
path: ext.path,
|
||||||
|
async lazy() {
|
||||||
|
const { default: Component } = await import(/* @vite-ignore */ ext.file)
|
||||||
|
return { Component }
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
+17
-16
@@ -1,3 +1,8 @@
|
|||||||
|
import {
|
||||||
|
AdminCollectionsRes,
|
||||||
|
AdminProductsRes,
|
||||||
|
AdminRegionsRes,
|
||||||
|
} from "@medusajs/medusa"
|
||||||
import {
|
import {
|
||||||
AdminApiKeyResponse,
|
AdminApiKeyResponse,
|
||||||
AdminCustomerGroupResponse,
|
AdminCustomerGroupResponse,
|
||||||
@@ -7,26 +12,18 @@ import {
|
|||||||
SalesChannelDTO,
|
SalesChannelDTO,
|
||||||
UserDTO,
|
UserDTO,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
|
||||||
AdminCollectionsRes,
|
|
||||||
AdminProductsRes,
|
|
||||||
AdminRegionsRes,
|
|
||||||
} from "@medusajs/medusa"
|
|
||||||
import { InventoryItemRes, PriceListRes } from "../../types/api-responses"
|
|
||||||
import { Outlet, RouteObject } from "react-router-dom"
|
import { Outlet, RouteObject } from "react-router-dom"
|
||||||
|
|
||||||
import { AdminCustomersRes } from "@medusajs/client-types"
|
import { ProtectedRoute } from "../../components/authentication/protected-route"
|
||||||
import { ErrorBoundary } from "../../components/error/error-boundary"
|
import { ErrorBoundary } from "../../components/error/error-boundary"
|
||||||
import { MainLayout } from "../../components/layout/main-layout"
|
import { MainLayout } from "../../components/layout/main-layout"
|
||||||
import { ProtectedRoute } from "../../components/authentication/protected-route"
|
|
||||||
import { SettingsLayout } from "../../components/layout/settings-layout"
|
import { SettingsLayout } from "../../components/layout/settings-layout"
|
||||||
|
import { InventoryItemRes, PriceListRes } from "../../types/api-responses"
|
||||||
|
|
||||||
/**
|
import { RouteExtensions } from "./route-extensions"
|
||||||
* Experimental V2 routes.
|
import { SettingsExtensions } from "./settings-extensions"
|
||||||
*
|
|
||||||
* These routes are only available if the `MEDUSA_V2` feature flag is enabled.
|
export const RouteMap: RouteObject[] = [
|
||||||
*/
|
|
||||||
export const v2Routes: RouteObject[] = [
|
|
||||||
{
|
{
|
||||||
path: "/login",
|
path: "/login",
|
||||||
lazy: () => import("../../v2-routes/login"),
|
lazy: () => import("../../v2-routes/login"),
|
||||||
@@ -181,7 +178,8 @@ export const v2Routes: RouteObject[] = [
|
|||||||
lazy: () =>
|
lazy: () =>
|
||||||
import("../../v2-routes/promotions/promotion-detail"),
|
import("../../v2-routes/promotions/promotion-detail"),
|
||||||
handle: {
|
handle: {
|
||||||
crumb: (data: AdminPromotionRes) => data.promotion?.code,
|
// TODO: Re-add type when it's available again
|
||||||
|
crumb: (data: any) => data.promotion?.code,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@@ -317,7 +315,8 @@ export const v2Routes: RouteObject[] = [
|
|||||||
path: ":id",
|
path: ":id",
|
||||||
lazy: () => import("../../v2-routes/customers/customer-detail"),
|
lazy: () => import("../../v2-routes/customers/customer-detail"),
|
||||||
handle: {
|
handle: {
|
||||||
crumb: (data: AdminCustomersRes) => data.customer.email,
|
// Re-add type when it's available again
|
||||||
|
crumb: (data: any) => data.customer.email,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@@ -488,6 +487,7 @@ export const v2Routes: RouteObject[] = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
...RouteExtensions,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -973,6 +973,7 @@ export const v2Routes: RouteObject[] = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
...SettingsExtensions,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -3,12 +3,9 @@ import {
|
|||||||
createBrowserRouter,
|
createBrowserRouter,
|
||||||
} from "react-router-dom"
|
} from "react-router-dom"
|
||||||
|
|
||||||
import { v1Routes } from "./v1"
|
import { RouteMap } from "./route-map"
|
||||||
import { v2Routes } from "./v2"
|
|
||||||
|
|
||||||
const V2_ENABLED = import.meta.env.VITE_MEDUSA_V2 === "true"
|
const router = createBrowserRouter(RouteMap)
|
||||||
|
|
||||||
const router = createBrowserRouter(V2_ENABLED ? v2Routes : v1Routes)
|
|
||||||
|
|
||||||
export const RouterProvider = () => {
|
export const RouterProvider = () => {
|
||||||
return <Provider router={router} />
|
return <Provider router={router} />
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import settings from "medusa-admin:settings/pages"
|
||||||
|
import { RouteObject } from "react-router-dom"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI Settings extensions.
|
||||||
|
*/
|
||||||
|
export const SettingsExtensions: RouteObject[] = settings.pages.map((ext) => {
|
||||||
|
return {
|
||||||
|
path: `/settings${ext.path}`,
|
||||||
|
async lazy() {
|
||||||
|
const { default: Component } = await import(/* @vite-ignore */ ext.file)
|
||||||
|
return { Component }
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,320 +0,0 @@
|
|||||||
import type {
|
|
||||||
AdminDiscountsRes,
|
|
||||||
AdminDraftOrdersRes,
|
|
||||||
AdminGiftCardsRes,
|
|
||||||
AdminOrdersRes,
|
|
||||||
} from "@medusajs/medusa"
|
|
||||||
import { Outlet, RouteObject } from "react-router-dom"
|
|
||||||
|
|
||||||
import { ProtectedRoute } from "../../components/authentication/require-auth"
|
|
||||||
import { ErrorBoundary } from "../../components/error/error-boundary"
|
|
||||||
import { MainLayout } from "../../components/layout/main-layout"
|
|
||||||
|
|
||||||
import routes from "medusa-admin:routes/pages"
|
|
||||||
import settings from "medusa-admin:settings/pages"
|
|
||||||
|
|
||||||
const routeExtensions: RouteObject[] = routes.pages.map((ext) => {
|
|
||||||
return {
|
|
||||||
path: ext.path,
|
|
||||||
async lazy() {
|
|
||||||
const { default: Component } = await import(/* @vite-ignore */ ext.file)
|
|
||||||
return { Component }
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const settingsExtensions: RouteObject[] = settings.pages.map((ext) => {
|
|
||||||
return {
|
|
||||||
path: `/settings${ext.path}`,
|
|
||||||
async lazy() {
|
|
||||||
const { default: Component } = await import(/* @vite-ignore */ ext.file)
|
|
||||||
return { Component }
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* V1 routes.
|
|
||||||
*
|
|
||||||
* These routes are loaded by default.
|
|
||||||
*/
|
|
||||||
export const v1Routes: RouteObject[] = [
|
|
||||||
{
|
|
||||||
path: "/login",
|
|
||||||
lazy: () => import("../../routes/login"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/reset-password",
|
|
||||||
element: <Outlet />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
index: true,
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/reset-password/reset-password-request"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ":token",
|
|
||||||
lazy: () => import("../../routes/reset-password/reset-password-token"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/invite",
|
|
||||||
lazy: () => import("../../routes/invite"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
element: <ProtectedRoute />,
|
|
||||||
errorElement: <ErrorBoundary />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
element: <MainLayout />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
index: true,
|
|
||||||
lazy: () => import("../../routes/home"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/orders",
|
|
||||||
handle: {
|
|
||||||
crumb: () => "Orders",
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "",
|
|
||||||
lazy: () => import("../../routes/orders/order-list"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ":id",
|
|
||||||
lazy: () => import("../../routes/orders/order-detail"),
|
|
||||||
handle: {
|
|
||||||
crumb: (data: AdminOrdersRes) =>
|
|
||||||
`Order #${data.order.display_id}`,
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "shipping-address",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/orders/order-shipping-address"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "billing-address",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/orders/order-billing-address"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "email",
|
|
||||||
lazy: () => import("../../routes/orders/order-email"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "transfer-ownership",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/orders/order-transfer-ownership"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "edit",
|
|
||||||
lazy: () => import("../../routes/orders/order-edit"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "returns",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/orders/order-create-return"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "refund",
|
|
||||||
lazy: () => import("../../routes/orders/order-refund"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/draft-orders",
|
|
||||||
handle: {
|
|
||||||
crumb: () => "Draft Orders",
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/draft-orders/draft-order-list"),
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "create",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/draft-orders/draft-order-create"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ":id",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/draft-orders/draft-order-detail"),
|
|
||||||
handle: {
|
|
||||||
crumb: (data: AdminDraftOrdersRes) =>
|
|
||||||
`Draft #${data.draft_order.display_id}`,
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "transfer-ownership",
|
|
||||||
lazy: () =>
|
|
||||||
import(
|
|
||||||
"../../routes/draft-orders/draft-order-transfer-ownership"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "shipping-address",
|
|
||||||
lazy: () =>
|
|
||||||
import(
|
|
||||||
"../../routes/draft-orders/draft-order-shipping-address"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "billing-address",
|
|
||||||
lazy: () =>
|
|
||||||
import(
|
|
||||||
"../../routes/draft-orders/draft-order-billing-address"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "email",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/draft-orders/draft-order-email"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/categories",
|
|
||||||
handle: {
|
|
||||||
crumb: () => "Categories",
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
index: true,
|
|
||||||
lazy: () => import("../../routes/categories/list"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ":id",
|
|
||||||
lazy: () => import("../../routes/categories/details"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/inventory",
|
|
||||||
handle: {
|
|
||||||
crumb: () => "Inventory",
|
|
||||||
},
|
|
||||||
lazy: () => import("../../routes/inventory/inventory-list"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/reservations",
|
|
||||||
handle: {
|
|
||||||
crumb: () => "Reservations",
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/reservations/reservation-list"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ":id",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/reservations/reservation-detail"),
|
|
||||||
// children: [
|
|
||||||
// {
|
|
||||||
// path: "edit",
|
|
||||||
// lazy: () =>
|
|
||||||
// import("../../routes/reservations/reservation-edit"),
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/gift-cards",
|
|
||||||
handle: {
|
|
||||||
crumb: () => "Gift Cards",
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "",
|
|
||||||
lazy: () => import("../../routes/gift-cards/gift-card-list"),
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "create",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/gift-cards/gift-card-create"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ":id",
|
|
||||||
lazy: () => import("../../routes/gift-cards/gift-card-detail"),
|
|
||||||
handle: {
|
|
||||||
crumb: (data: AdminGiftCardsRes) => data.gift_card.code,
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "edit",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/gift-cards/gift-card-edit"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/discounts",
|
|
||||||
handle: {
|
|
||||||
crumb: () => "Discounts",
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "",
|
|
||||||
lazy: () => import("../../routes/discounts/discount-list"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "create",
|
|
||||||
lazy: () => import("../../routes/discounts/discount-create"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ":id",
|
|
||||||
lazy: () => import("../../routes/discounts/discount-detail"),
|
|
||||||
handle: {
|
|
||||||
crumb: (data: AdminDiscountsRes) => data.discount.code,
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "edit",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/discounts/discount-edit-details"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "configuration",
|
|
||||||
lazy: () =>
|
|
||||||
import(
|
|
||||||
"../../routes/discounts/discount-edit-configuration"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "conditions",
|
|
||||||
lazy: () =>
|
|
||||||
import("../../routes/discounts/discount-edit-conditions"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
...routeExtensions,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "*",
|
|
||||||
lazy: () => import("../../routes/no-match"),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
Reference in new issue
Block a user