fix(admin-ui): Fix Y-axis scroll in bulk editor (#5726)

This commit is contained in:
Kasper Fabricius Kristensen
2023-11-27 11:13:11 +00:00
committed by GitHub
parent 18afe0b9ad
commit 5f6751a61f
4 changed files with 33 additions and 27 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---
fix(admin-ui): Makes it possible to scroll overflow on the Y-axis in the /products/:id bulk editor
@@ -1,7 +1,7 @@
import React, { useMemo } from "react" import { useMemo } from "react"
import { useAdminRegions, useAdminStore } from "medusa-react"
import * as DropdownMenu from "@radix-ui/react-dropdown-menu" import * as DropdownMenu from "@radix-ui/react-dropdown-menu"
import { useAdminRegions, useAdminStore } from "medusa-react"
import Button from "../../../fundamentals/button" import Button from "../../../fundamentals/button"
import AdjustmentsIcon from "../../../fundamentals/icons/adjustments-icon" import AdjustmentsIcon from "../../../fundamentals/icons/adjustments-icon"
@@ -38,7 +38,7 @@ function EditPricesActions(props: EditPricesActionsProps) {
return ( return (
<div <div
style={{ fontSize: 13 }} style={{ fontSize: 13 }}
className="flex items-center gap-2 border-t py-[12px] px-4" className="border-ui-border-base flex items-center gap-2 border-b border-t px-4 py-[12px]"
> >
<DropdownMenu.Root> <DropdownMenu.Root>
<DropdownMenu.Trigger asChild> <DropdownMenu.Trigger asChild>
@@ -1,18 +1,18 @@
import React, { useEffect, useMemo, useRef, useState } from "react"
import { useAdminRegions, useAdminStore } from "medusa-react"
import { Product } from "@medusajs/client-types" import { Product } from "@medusajs/client-types"
import { useAdminRegions, useAdminStore } from "medusa-react"
import React, { useEffect, useMemo, useRef, useState } from "react"
import useNotification from "../../../../hooks/use-notification"
import { currencies as CURRENCY_MAP } from "../../../../utils/currencies"
import Tooltip from "../../../atoms/tooltip"
import IconBuildingTax from "../../../fundamentals/icons/building-tax-icon"
import CurrencyCell from "./currency-cell"
import { import {
getCurrencyPricesOnly, getCurrencyPricesOnly,
getRegionPricesOnly, getRegionPricesOnly,
mod,
isText, isText,
mod,
} from "./utils" } from "./utils"
import IconBuildingTax from "../../../fundamentals/icons/building-tax-icon"
import { currencies as CURRENCY_MAP } from "../../../../utils/currencies"
import Tooltip from "../../../atoms/tooltip"
import CurrencyCell from "./currency-cell"
import useNotification from "../../../../hooks/use-notification"
enum ArrowMove { enum ArrowMove {
UP, UP,
@@ -669,21 +669,22 @@ function EditPricesTable(props: EditPricesTableProps) {
} }
return ( return (
<div className="h-full overflow-x-auto"> // 60px is the height of the subheader, 64px is the height of the header
<div className="h-[calc(100%-60px-64px)] overflow-auto">
<table <table
onMouseMove={ onMouseMove={
/** prevent default browser highlighting while dragging **/ /** prevent default browser highlighting while dragging **/
(e) => e.preventDefault() (e) => e.preventDefault()
} }
style={{ fontSize: 13, borderCollapse: "collapse" }} style={{ fontSize: 13, borderCollapse: "collapse" }}
className="w-full table-auto" className="h-full w-full table-auto"
> >
<thead> <thead>
<tr <tr
style={{ height: 42 }} style={{ height: 42 }}
className="tw-text-medusa-text-subtle h-2 text-left font-normal" className="tw-text-medusa-text-subtle h-2 text-left font-normal"
> >
<th className="h-2 border pl-4 font-medium text-gray-400"> <th className="h-2 border border-t-0 pl-4 font-medium text-gray-400">
Product Product
</th> </th>
{props.currencies.map((c) => { {props.currencies.map((c) => {
@@ -691,7 +692,7 @@ function EditPricesTable(props: EditPricesTableProps) {
return ( return (
<th <th
key={c} key={c}
className="min-w-[220px] border px-4 font-medium text-gray-400" className="min-w-[220px] border border-t-0 px-4 font-medium text-gray-400"
> >
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<span>Price {c.toUpperCase()}</span> <span>Price {c.toUpperCase()}</span>
@@ -712,7 +713,7 @@ function EditPricesTable(props: EditPricesTableProps) {
return ( return (
<th <th
key={r} key={r}
className="min-w-[220px] max-w-[220px] border px-4 font-medium text-gray-400" className="min-w-[220px] max-w-[220px] border border-t-0 px-4 font-medium text-gray-400"
> >
<div className="flex items-center justify-between gap-2"> <div className="flex items-center justify-between gap-2">
<span className="flex overflow-hidden"> <span className="flex overflow-hidden">
@@ -1,26 +1,26 @@
import { MoneyAmount, Product } from "@medusajs/client-types" import { MoneyAmount, Product } from "@medusajs/client-types"
import { useAdminRegions, useAdminUpdateVariant } from "medusa-react"
import { useEffect, useMemo, useRef, useState } from "react"
import { import {
getAllProductPricesCurrencies, getAllProductPricesCurrencies,
getAllProductPricesRegions, getAllProductPricesRegions,
getCurrencyPricesOnly, getCurrencyPricesOnly,
getRegionPricesOnly, getRegionPricesOnly,
} from "./utils" } from "./utils"
import { useAdminRegions, useAdminUpdateVariant } from "medusa-react"
import { useEffect, useMemo, useRef, useState } from "react"
import Button from "../../../fundamentals/button"
import { currencies as CURRENCY_MAP } from "../../../../utils/currencies"
import CrossIcon from "../../../fundamentals/icons/cross-icon"
import DeletePrompt from "../../delete-prompt"
import EditPricesActions from "./edit-prices-actions"
import EditPricesTable from "./edit-prices-table"
import Fade from "../../../atoms/fade-wrapper"
import Modal from "../../../molecules/modal"
import SavePrompt from "./save-prompt"
import mapKeys from "lodash/mapKeys" import mapKeys from "lodash/mapKeys"
import pick from "lodash/pick" import pick from "lodash/pick"
import pickBy from "lodash/pickBy" import pickBy from "lodash/pickBy"
import useNotification from "../../../../hooks/use-notification" import useNotification from "../../../../hooks/use-notification"
import { currencies as CURRENCY_MAP } from "../../../../utils/currencies"
import Fade from "../../../atoms/fade-wrapper"
import Button from "../../../fundamentals/button"
import CrossIcon from "../../../fundamentals/icons/cross-icon"
import Modal from "../../../molecules/modal"
import DeletePrompt from "../../delete-prompt"
import EditPricesActions from "./edit-prices-actions"
import EditPricesTable from "./edit-prices-table"
import SavePrompt from "./save-prompt"
type EditPricesModalProps = { type EditPricesModalProps = {
close: () => void close: () => void