fix(dashboard): Remove token copy from badge (#9508)
**What** - Removes the <Copy /> wrapper from the Token badge in API key tables. - The usage of copy spawned to issues: the click was being propagated despite stopping propagation causing navigation to the API keys detail page, the Copy acts as a <a /> tag when it's a child of a <Link />, escaping react-router-dom and doing a "hard" navigate to the next page. Fixes CC-576
This commit is contained in:
+4
-8
@@ -154,15 +154,11 @@ export const ApiKeyGeneralSection = ({ apiKey }: ApiKeyGeneralSectionProps) => {
|
|||||||
{t("fields.key")}
|
{t("fields.key")}
|
||||||
</Text>
|
</Text>
|
||||||
{apiKey.type === "secret" ? (
|
{apiKey.type === "secret" ? (
|
||||||
<Badge size="2xsmall" className="w-fit">
|
<Badge size="2xsmall">{prettifyRedactedToken(apiKey.redacted)}</Badge>
|
||||||
{prettifyRedactedToken(apiKey.redacted)}
|
|
||||||
</Badge>
|
|
||||||
) : (
|
) : (
|
||||||
<Copy asChild content={apiKey.token}>
|
<Copy asChild content={apiKey.token} className="cursor-pointer">
|
||||||
<Badge size="2xsmall" className="w-fit max-w-40 cursor-pointer">
|
<Badge size="2xsmall" className="text-ui-tag-neutral-text">
|
||||||
<Text size="xsmall" leading="compact" className="truncate">
|
{prettifyRedactedToken(apiKey.redacted)}
|
||||||
{prettifyRedactedToken(apiKey.redacted)}
|
|
||||||
</Text>
|
|
||||||
</Badge>
|
</Badge>
|
||||||
</Copy>
|
</Copy>
|
||||||
)}
|
)}
|
||||||
|
|||||||
+4
-24
@@ -1,7 +1,7 @@
|
|||||||
import { AdminApiKeyResponse } from "@medusajs/types"
|
import { AdminApiKeyResponse } from "@medusajs/types"
|
||||||
import { Badge, Copy, Text } from "@medusajs/ui"
|
import { Badge } from "@medusajs/ui"
|
||||||
import { createColumnHelper } from "@tanstack/react-table"
|
import { createColumnHelper } from "@tanstack/react-table"
|
||||||
import { MouseEvent, useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
|
|
||||||
import { DateCell } from "../../../../../components/table/table-cells/common/date-cell"
|
import { DateCell } from "../../../../../components/table/table-cells/common/date-cell"
|
||||||
@@ -31,29 +31,9 @@ export const useApiKeyManagementTableColumns = () => {
|
|||||||
}),
|
}),
|
||||||
columnHelper.accessor("redacted", {
|
columnHelper.accessor("redacted", {
|
||||||
header: "Token",
|
header: "Token",
|
||||||
cell: ({ getValue, row }) => {
|
cell: ({ getValue }) => {
|
||||||
const token = getValue()
|
const token = getValue()
|
||||||
const isSecret = row.original.type === "secret"
|
return <Badge size="2xsmall">{prettifyRedactedToken(token)}</Badge>
|
||||||
|
|
||||||
if (isSecret) {
|
|
||||||
return <Badge size="2xsmall">{prettifyRedactedToken(token)}</Badge>
|
|
||||||
}
|
|
||||||
|
|
||||||
const clickHandler = (e: MouseEvent) => e.stopPropagation()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Badge size="2xsmall" className="max-w-40" onClick={clickHandler}>
|
|
||||||
<Copy
|
|
||||||
content={row.original.token}
|
|
||||||
className="text-ui-fg-subtle"
|
|
||||||
asChild
|
|
||||||
>
|
|
||||||
<Text size="xsmall" leading="compact" className="truncate">
|
|
||||||
{prettifyRedactedToken(token)}
|
|
||||||
</Text>
|
|
||||||
</Copy>
|
|
||||||
</Badge>
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor("type", {
|
columnHelper.accessor("type", {
|
||||||
|
|||||||
Reference in New Issue
Block a user