feat(dashboard,types,sdk,medusa,ui): ProductCategory domain (#7675)

**What**
- Add missing features to ProductCategory domain in admin
- Add types
- Add SDK

**UI**
- Moves the TooltipProvider from the component to an export. Users should now wrap their entire application in a TooltipProvider. This change was made to take advantage of the built-in features of Radix Tooltip, and allows us to skip the delayDuration when moving the cursor from one tooltip to another within 500ms.
- Fixes the layout of the Hint component, as the create form revealed that it was off.
- Fixes an issue where focus styles were missing from the dropdown menu.

**Note**
- ~~We currently don't have an endpoint for deleting categories, so I have disabled the button in the admin. See CORE--2286~~ PR has been opened to add delete endpoint, so I have re-enabled the delete button.
- The update category workflow seems to be broken, it's possible for the `mpath` of a category to reach an invalid state, that breaks `include_descendants_tree` from working. See CORE-2287.
- The ProductCategory model is incorrect. All fields are optional and it's not possible to set the description to null, which means the only way of unsetting it is to set it to `""`. See CORE-2276.
- The design for the Organize drag-n-drop form is not final. Ludvig will create a final design, and we can then update the form.
- Currently, all things related to Metadata is left out, as we need to update the flow for metadata according to the latest designs.

RESOLVES CORE-1960, CORE-2230
*except for the above mentioned issues.
This commit is contained in:
Kasper Fabricius Kristensen
2024-06-12 13:15:12 +02:00
committed by GitHub
parent 73ca358606
commit 2f76fbc6ed
71 changed files with 2208 additions and 187 deletions

View File

@@ -1,13 +1,15 @@
import { render, screen, waitFor } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import { Tooltip } from "./tooltip"
import { Tooltip, TooltipProvider } from "./tooltip"
test("Tooltip renders trigger element", () => {
render(
<Tooltip content="Tooltip text">
<div>Hover me</div>
</Tooltip>
<TooltipProvider>
<Tooltip content="Tooltip text">
<div>Hover me</div>
</Tooltip>
</TooltipProvider>
)
const triggerElement = screen.getByText("Hover me")
@@ -16,9 +18,11 @@ test("Tooltip renders trigger element", () => {
test("Tooltip shows on hover", async () => {
render(
<Tooltip content="Tooltip text" data-testid="tooltip">
<div>Hover me</div>
</Tooltip>
<TooltipProvider>
<Tooltip content="Tooltip text" data-testid="tooltip">
<div>Hover me</div>
</Tooltip>
</TooltipProvider>
)
const triggerElement = screen.getByText("Hover me")

View File

@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react"
import * as React from "react"
import { InformationCircleSolid } from "@medusajs/icons"
import { Tooltip } from "./tooltip"
import { Tooltip, TooltipProvider } from "./tooltip"
const meta: Meta<typeof Tooltip> = {
title: "Components/Tooltip",
@@ -21,6 +21,7 @@ const meta: Meta<typeof Tooltip> = {
},
},
},
render: (args) => <TooltipProvider><Tooltip {...args} /></TooltipProvider>,
}
export default meta

View File

@@ -40,7 +40,6 @@ const Tooltip = ({
...props
}: TooltipProps) => {
return (
<Primitives.Provider delayDuration={100}>
<Primitives.Root
open={open}
defaultOpen={defaultOpen}
@@ -67,8 +66,18 @@ const Tooltip = ({
</Primitives.Content>
</Primitives.Portal>
</Primitives.Root>
</Primitives.Provider>
)
}
export { Tooltip }
interface TooltipProviderProps extends Primitives.TooltipProviderProps {}
const TooltipProvider = ({ children, delayDuration = 100, skipDelayDuration = 300, ...props }: TooltipProviderProps) => {
return (
<Primitives.TooltipProvider delayDuration={delayDuration} skipDelayDuration={skipDelayDuration} {...props}>
{children}
</Primitives.TooltipProvider>
)
}
export { Tooltip, TooltipProvider }