feat(dashboard,admin-shared): Last injection zones (#7478)

* add reservations

* add final injection zones
This commit is contained in:
Kasper Fabricius Kristensen
2024-05-27 19:38:26 +02:00
committed by GitHub
parent d2b5768c02
commit 2efa016c6e
12 changed files with 248 additions and 8 deletions
@@ -73,6 +73,15 @@ const PROMOTION_INJECTION_ZONES = [
"promotion.list.after", "promotion.list.after",
] as const ] as const
const CAMPAIGN_INJECTION_ZONES = [
"campaign.details.before",
"campaign.details.after",
"campaign.details.side.before",
"campaign.details.side.after",
"campaign.list.before",
"campaign.list.after",
] as const
const GIFT_CARD_INJECTION_ZONES = [ const GIFT_CARD_INJECTION_ZONES = [
"gift_card.details.before", "gift_card.details.before",
"gift_card.details.after", "gift_card.details.after",
@@ -124,6 +133,43 @@ const LOCATION_INJECTION_ZONES = [
const LOGIN_INJECTION_ZONES = ["login.before", "login.after"] as const const LOGIN_INJECTION_ZONES = ["login.before", "login.after"] as const
const SALES_CHANNEL_INJECTION_ZONES = [
"sales_channel.details.before",
"sales_channel.details.after",
"sales_channel.list.before",
"sales_channel.list.after",
] as const
const RESERVATION_INJECTION_ZONES = [
"reservation.details.before",
"reservation.details.after",
"reservation.details.side.before",
"reservation.details.side.after",
"reservation.list.before",
"reservation.list.after",
] as const
const API_KEY_INJECTION_ZONES = [
"api_key.details.before",
"api_key.details.after",
"api_key.list.before",
"api_key.list.after",
]
const WORKFLOW_INJECTION_ZONES = [
"workflow.details.before",
"workflow.details.after",
"workflow.list.before",
"workflow.list.after",
] as const
const TAX_INJECTION_ZONES = [
"tax.details.before",
"tax.details.after",
"tax.list.before",
"tax.list.after",
] as const
/** /**
* All valid injection zones in the admin panel. An injection zone is a specific place * All valid injection zones in the admin panel. An injection zone is a specific place
* in the admin panel where a plugin can inject custom widgets. * in the admin panel where a plugin can inject custom widgets.
@@ -146,4 +192,10 @@ export const INJECTION_ZONES = [
...SHIPPING_PROFILE_INJECTION_ZONES, ...SHIPPING_PROFILE_INJECTION_ZONES,
...LOCATION_INJECTION_ZONES, ...LOCATION_INJECTION_ZONES,
...LOGIN_INJECTION_ZONES, ...LOGIN_INJECTION_ZONES,
...SALES_CHANNEL_INJECTION_ZONES,
...RESERVATION_INJECTION_ZONES,
...API_KEY_INJECTION_ZONES,
...WORKFLOW_INJECTION_ZONES,
...CAMPAIGN_INJECTION_ZONES,
...TAX_INJECTION_ZONES,
] as const ] as const
@@ -12,6 +12,9 @@ import { ApiKeyGeneralSection } from "./components/api-key-general-section"
import { ApiKeySalesChannelSection } from "./components/api-key-sales-channel-section" import { ApiKeySalesChannelSection } from "./components/api-key-sales-channel-section"
import { apiKeyLoader } from "./loader" import { apiKeyLoader } from "./loader"
import after from "virtual:medusa/widgets/api_key/details/after"
import before from "virtual:medusa/widgets/api_key/details/before"
export const ApiKeyManagementDetail = () => { export const ApiKeyManagementDetail = () => {
const initialData = useLoaderData() as Awaited< const initialData = useLoaderData() as Awaited<
ReturnType<typeof apiKeyLoader> ReturnType<typeof apiKeyLoader>
@@ -41,8 +44,22 @@ export const ApiKeyManagementDetail = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component apiKey={api_key} />
</div>
)
})}
<ApiKeyGeneralSection apiKey={api_key} /> <ApiKeyGeneralSection apiKey={api_key} />
{isPublishable && <ApiKeySalesChannelSection apiKey={api_key} />} {isPublishable && <ApiKeySalesChannelSection apiKey={api_key} />}
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component apiKey={api_key} />
</div>
)
})}
<JsonViewSection data={api_key} /> <JsonViewSection data={api_key} />
<Outlet /> <Outlet />
</div> </div>
@@ -2,6 +2,9 @@ import { Outlet, useLocation } from "react-router-dom"
import { getApiKeyTypeFromPathname } from "../common/utils" import { getApiKeyTypeFromPathname } from "../common/utils"
import { ApiKeyManagementListTable } from "./components/api-key-management-list-table" import { ApiKeyManagementListTable } from "./components/api-key-management-list-table"
import after from "virtual:medusa/widgets/api_key/list/after"
import before from "virtual:medusa/widgets/api_key/list/before"
export const ApiKeyManagementList = () => { export const ApiKeyManagementList = () => {
const { pathname } = useLocation() const { pathname } = useLocation()
@@ -9,7 +12,21 @@ export const ApiKeyManagementList = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
<ApiKeyManagementListTable keyType={keyType} /> <ApiKeyManagementListTable keyType={keyType} />
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
<Outlet /> <Outlet />
</div> </div>
) )
@@ -1,2 +1,2 @@
export { ReservationDetail as Component } from "./reservation-edit"
export { reservationItemLoader as loader } from "./loader" export { reservationItemLoader as loader } from "./loader"
export { ReservationDetail as Component } from "./reservation-detail"
@@ -1,10 +1,15 @@
import { Outlet, useLoaderData, useParams } from "react-router-dom" import { Outlet, useLoaderData, useParams } from "react-router-dom"
import { InventoryItemGeneralSection } from "../../inventory/inventory-detail/components/inventory-item-general-section"
import { JsonViewSection } from "../../../components/common/json-view-section" import { JsonViewSection } from "../../../components/common/json-view-section"
import { useReservationItem } from "../../../hooks/api/reservations"
import { InventoryItemGeneralSection } from "../../inventory/inventory-detail/components/inventory-item-general-section"
import { ReservationGeneralSection } from "./components/reservation-general-section" import { ReservationGeneralSection } from "./components/reservation-general-section"
import { reservationItemLoader } from "./loader" import { reservationItemLoader } from "./loader"
import { useReservationItem } from "../../../hooks/api/reservations"
import after from "virtual:medusa/widgets/reservation/details/after"
import before from "virtual:medusa/widgets/reservation/details/before"
import sideAfter from "virtual:medusa/widgets/reservation/details/side/after"
import sideBefore from "virtual:medusa/widgets/reservation/details/side/before"
export const ReservationDetail = () => { export const ReservationDetail = () => {
const { id } = useParams() const { id } = useParams()
@@ -31,18 +36,46 @@ export const ReservationDetail = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
<div className="flex flex-col gap-x-4 lg:flex-row lg:items-start"> {before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={reservation} />
</div>
)
})}
<div className="flex flex-col gap-x-4 xl:flex-row xl:items-start">
<div className="flex w-full flex-col gap-y-2"> <div className="flex w-full flex-col gap-y-2">
<ReservationGeneralSection reservation={reservation} /> <ReservationGeneralSection reservation={reservation} />
<div className="hidden lg:block"> {after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={reservation} />
</div>
)
})}
<div className="hidden xl:block">
<JsonViewSection data={reservation} /> <JsonViewSection data={reservation} />
</div> </div>
</div> </div>
<div className="mt-2 flex w-full max-w-[100%] flex-col gap-y-2 lg:mt-0 lg:max-w-[400px]"> <div className="mt-2 flex w-full max-w-[100%] flex-col gap-y-2 xl:mt-0 xl:max-w-[400px]">
{sideBefore.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={reservation} />
</div>
)
})}
<InventoryItemGeneralSection <InventoryItemGeneralSection
inventoryItem={reservation.inventory_item} inventoryItem={reservation.inventory_item}
/> />
<div className="lg:hidden"> {sideAfter.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={reservation} />
</div>
)
})}
<div className="xl:hidden">
<JsonViewSection data={reservation} /> <JsonViewSection data={reservation} />
</div> </div>
<Outlet /> <Outlet />
@@ -1,10 +1,27 @@
import { Outlet } from "react-router-dom" import { Outlet } from "react-router-dom"
import { ReservationListTable } from "./components/reservation-list-table" import { ReservationListTable } from "./components/reservation-list-table"
import after from "virtual:medusa/widgets/reservation/list/after"
import before from "virtual:medusa/widgets/reservation/list/before"
export const ReservationList = () => { export const ReservationList = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
<ReservationListTable /> <ReservationListTable />
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component key={i} />
</div>
)
})}
<Outlet /> <Outlet />
</div> </div>
) )
@@ -6,6 +6,9 @@ import { SalesChannelGeneralSection } from "./components/sales-channel-general-s
import { SalesChannelProductSection } from "./components/sales-channel-product-section" import { SalesChannelProductSection } from "./components/sales-channel-product-section"
import { salesChannelLoader } from "./loader" import { salesChannelLoader } from "./loader"
import after from "virtual:medusa/widgets/sales_channel/details/after"
import before from "virtual:medusa/widgets/sales_channel/details/before"
export const SalesChannelDetail = () => { export const SalesChannelDetail = () => {
const initialData = useLoaderData() as Awaited< const initialData = useLoaderData() as Awaited<
ReturnType<typeof salesChannelLoader> ReturnType<typeof salesChannelLoader>
@@ -22,8 +25,22 @@ export const SalesChannelDetail = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={sales_channel} />
</div>
)
})}
<SalesChannelGeneralSection salesChannel={sales_channel} /> <SalesChannelGeneralSection salesChannel={sales_channel} />
<SalesChannelProductSection salesChannel={sales_channel} /> <SalesChannelProductSection salesChannel={sales_channel} />
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={sales_channel} />
</div>
)
})}
<JsonViewSection data={sales_channel} /> <JsonViewSection data={sales_channel} />
<Outlet /> <Outlet />
</div> </div>
@@ -1,10 +1,28 @@
import { Outlet } from "react-router-dom" import { Outlet } from "react-router-dom"
import { SalesChannelListTable } from "./components/sales-channel-list-table" import { SalesChannelListTable } from "./components/sales-channel-list-table"
import after from "virtual:medusa/widgets/sales_channel/list/after"
import before from "virtual:medusa/widgets/sales_channel/list/before"
export const SalesChannelList = () => { export const SalesChannelList = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
<SalesChannelListTable /> <SalesChannelListTable />
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component key={i} />
</div>
)
})}
<Outlet /> <Outlet />
</div> </div>
) )
@@ -1,9 +1,13 @@
import { Outlet, useParams } from "react-router-dom" import { Outlet, useParams } from "react-router-dom"
import { JsonViewSection } from "../../../components/common/json-view-section" import { JsonViewSection } from "../../../components/common/json-view-section"
import { useTaxRegion } from "../../../hooks/api/tax-regions" import { useTaxRegion } from "../../../hooks/api/tax-regions"
import { TaxRateList } from "./components/tax-rate-list" import { TaxRateList } from "./components/tax-rate-list"
import { TaxRegionGeneralDetail } from "./components/tax-region-general-detail" import { TaxRegionGeneralDetail } from "./components/tax-region-general-detail"
import after from "virtual:medusa/widgets/tax/details/after"
import before from "virtual:medusa/widgets/tax/details/before"
export const TaxRegionDetail = () => { export const TaxRegionDetail = () => {
const { id } = useParams() const { id } = useParams()
const { tax_region: taxRegion, isLoading, isError, error } = useTaxRegion(id!) const { tax_region: taxRegion, isLoading, isError, error } = useTaxRegion(id!)
@@ -19,10 +23,24 @@ export const TaxRegionDetail = () => {
return ( return (
taxRegion && ( taxRegion && (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={taxRegion} />
</div>
)
})}
<TaxRegionGeneralDetail taxRegion={taxRegion} /> <TaxRegionGeneralDetail taxRegion={taxRegion} />
<TaxRateList taxRegion={taxRegion} isDefault={true} /> <TaxRateList taxRegion={taxRegion} isDefault={true} />
<TaxRateList taxRegion={taxRegion} isDefault={false} /> <TaxRateList taxRegion={taxRegion} isDefault={false} />
<JsonViewSection data={taxRegion} root="tax_region" /> {after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component data={taxRegion} />
</div>
)
})}
<JsonViewSection data={taxRegion} />
<Outlet /> <Outlet />
</div> </div>
) )
@@ -1,10 +1,27 @@
import { Outlet } from "react-router-dom" import { Outlet } from "react-router-dom"
import { TaxRegionListTable } from "./components/region-list-table" import { TaxRegionListTable } from "./components/region-list-table"
import after from "virtual:medusa/widgets/tax/list/after"
import before from "virtual:medusa/widgets/tax/list/before"
export const TaxRegionsList = () => { export const TaxRegionsList = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
<TaxRegionListTable /> <TaxRegionListTable />
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
<Outlet /> <Outlet />
</div> </div>
) )
@@ -7,6 +7,9 @@ import { WorkflowExecutionHistorySection } from "./components/workflow-execution
import { WorkflowExecutionPayloadSection } from "./components/workflow-execution-payload-section" import { WorkflowExecutionPayloadSection } from "./components/workflow-execution-payload-section"
import { WorkflowExecutionTimelineSection } from "./components/workflow-execution-timeline-section" import { WorkflowExecutionTimelineSection } from "./components/workflow-execution-timeline-section"
import after from "virtual:medusa/widgets/workflow/details/after"
import before from "virtual:medusa/widgets/workflow/details/before"
export const ExecutionDetail = () => { export const ExecutionDetail = () => {
const { id } = useParams() const { id } = useParams()
@@ -23,10 +26,24 @@ export const ExecutionDetail = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component execution={workflow_execution} />
</div>
)
})}
<WorkflowExecutionGeneralSection execution={workflow_execution} /> <WorkflowExecutionGeneralSection execution={workflow_execution} />
<WorkflowExecutionTimelineSection execution={workflow_execution} /> <WorkflowExecutionTimelineSection execution={workflow_execution} />
<WorkflowExecutionPayloadSection execution={workflow_execution} /> <WorkflowExecutionPayloadSection execution={workflow_execution} />
<WorkflowExecutionHistorySection execution={workflow_execution} /> <WorkflowExecutionHistorySection execution={workflow_execution} />
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component execution={workflow_execution} />
</div>
)
})}
<JsonViewSection data={workflow_execution} /> <JsonViewSection data={workflow_execution} />
</div> </div>
) )
@@ -1,9 +1,26 @@
import { WorkflowExecutionListTable } from "./components/workflow-execution-list-table" import { WorkflowExecutionListTable } from "./components/workflow-execution-list-table"
import after from "virtual:medusa/widgets/workflow/list/after"
import before from "virtual:medusa/widgets/workflow/list/before"
export const WorkflowExcecutionList = () => { export const WorkflowExcecutionList = () => {
return ( return (
<div className="flex flex-col gap-y-2"> <div className="flex flex-col gap-y-2">
{before.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
<WorkflowExecutionListTable /> <WorkflowExecutionListTable />
{after.widgets.map((w, i) => {
return (
<div key={i}>
<w.Component />
</div>
)
})}
</div> </div>
) )
} }