-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard, medusa, medusa-js, medusa-react, icons): DataGrid, pa…
…rtial Product domain, and ProductVariant hook (#6428) The PR for the Products section is growing quite large, so I would like to merge this PR that contains a lot of the ground work before moving onto finalizing the rest of the domain. **Note** Since the PR contains changes to the core, that the dashboard depends on, the staging env will not work. To preview this PR, you will need to run it locally. ## `@medusajs/medusa` **What** - Adds missing query params to `GET /admin/products/:id/variants` - `options.values` has been added to the default relations of admin product endpoints. ## `medusa-react` **What** - Adds missing hook for `GET /admin/products/:id/variants` ## `@medusajs/dashboard` - Adds base implementation for `DataGrid` component (formerly `BulkEditor`) (WIP) - Adds `/products` overview page - Adds partial `/products/create` page for creating new products (WIP - need to go over design w/ Ludvig before continuing) - Adds `/products/:id` details page - Adds `/products/:id/gallery` page for inspecting a products images in fullscreen. - Adds `/products/:id/edit` page for editing the general information of a product - Adds `/products/:id/attributes` page for editing the attributes information of a product - Adds `/products/:id/sales-channels` page for editing which sales channels a product is available in - Fixes a bug in `DataTable` where a table with two fixed columns would not display correctly For the review its not important to test the DataGrid, as it is still WIP, and I need to go through some minor changes to the behaviour with Ludvig, as virtualizing it adds some constraints. ## `@medusajs/icons` **What** - Pulls latest icons from Figma ## TODO in next PR - [ ] Fix the typing of POST /admin/products/:id as it is currently not possible to delete any of the nullable fields once they have been added. Be aware of this when reviewing this PR. - [ ] Wrap up `/products/create` page - [ ] Add `/products/:id/media` page for managing media associated with the product. - [ ] Add `/products/id/options` for managing product options (need Ludvig to rethink this as the current API is very limited and we can implement the current design as is.) - [ ] Add `/products/:id/variants/:id` page for editing a variant. (Possibly concat all of these into one BulkEditor page?)
- Loading branch information
1 parent
c3e3022
commit 44d43e8
Showing
131 changed files
with
5,798 additions
and
655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@medusajs/client-types": patch | ||
"@medusajs/icons": patch | ||
"medusa-react": patch | ||
"@medusajs/medusa-js": patch | ||
"@medusajs/medusa": patch | ||
--- | ||
|
||
feat(medusa,medusa-js,medusa-react,icons): Fixes GET /admin/products/:id/variants endpoint in the core, and medusa-js and medusa-react. Pulls latest icons from Figma into `@medusajs/icons`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/admin-next/dashboard/src/components/common/handle-input/handle-input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Input, Text } from "@medusajs/ui" | ||
import { ComponentProps, ElementRef, forwardRef } from "react" | ||
|
||
export const HandleInput = forwardRef< | ||
ElementRef<typeof Input>, | ||
ComponentProps<typeof Input> | ||
>((props, ref) => { | ||
return ( | ||
<div className="relative"> | ||
<div className="absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r"> | ||
<Text | ||
className="text-ui-fg-muted" | ||
size="small" | ||
leading="compact" | ||
weight="plus" | ||
> | ||
/ | ||
</Text> | ||
</div> | ||
<Input ref={ref} {...props} className="pl-10" /> | ||
</div> | ||
) | ||
}) | ||
HandleInput.displayName = "HandleInput" |
1 change: 1 addition & 0 deletions
1
packages/admin-next/dashboard/src/components/common/handle-input/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./handle-input" |
51 changes: 44 additions & 7 deletions
51
packages/admin-next/dashboard/src/components/error/error-boundary/error-boundary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,59 @@ | ||
import { Navigate, useLocation, useRouteError } from "react-router-dom" | ||
|
||
import { ExclamationCircle } from "@medusajs/icons" | ||
import { Text } from "@medusajs/ui" | ||
import { useTranslation } from "react-i18next" | ||
import { isAxiosError } from "../../../lib/is-axios-error" | ||
|
||
// WIP - Need to allow wrapping <Outlet> with ErrorBoundary for more granular error handling. | ||
export const ErrorBoundary = () => { | ||
const error = useRouteError() | ||
const location = useLocation() | ||
const { t } = useTranslation() | ||
|
||
if (isAxiosError(error)) { | ||
if (error.response?.status === 404) { | ||
return <Navigate to="/404" /> | ||
} | ||
let code: number | null = null | ||
|
||
if (isAxiosError(error)) { | ||
if (error.response?.status === 401) { | ||
return <Navigate to="/login" state={{ from: location }} replace /> | ||
} | ||
|
||
// TODO: Catch other server errors | ||
code = error.response?.status ?? null | ||
} | ||
|
||
let title: string | ||
let message: string | ||
|
||
switch (code) { | ||
case 400: | ||
title = t("errorBoundary.badRequestTitle") | ||
message = t("errorBoundary.badRequestMessage") | ||
break | ||
case 404: | ||
title = t("errorBoundary.notFoundTitle") | ||
message = t("errorBoundary.notFoundMessage") | ||
break | ||
case 500: | ||
title = t("errorBoundary.internalServerErrorTitle") | ||
message = t("errorBoundary.internalServerErrorMessage") | ||
break | ||
default: | ||
title = t("errorBoundary.defaultTitle") | ||
message = t("errorBoundary.defaultMessage") | ||
break | ||
} | ||
|
||
// TODO: Actual catch-all error page | ||
return <div>Dang!</div> | ||
return ( | ||
<div className="flex size-full min-h-screen items-center justify-center"> | ||
<div className="text-ui-fg-subtle flex flex-col items-center gap-y-2"> | ||
<ExclamationCircle /> | ||
<Text size="small" leading="compact" weight="plus"> | ||
{title} | ||
</Text> | ||
<Text size="small" className="text-ui-fg-muted"> | ||
{message} | ||
</Text> | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.