feat(api-key,js-sdk,dashboard): allow deleting api keys only once its revoked (#9118)

what:

- module only deletes api keys once its revoked
- disables ui elements


https://github.com/user-attachments/assets/437821ae-497e-4b59-b02c-4a6ff36e6a30

RESOLVES CC-106
RESOLVES CC-105
RESOLVES CC-104
This commit is contained in:
Riqwan Thamir
2024-09-12 10:16:15 +00:00
committed by GitHub
parent c94f89610f
commit 64d5b74c12
7 changed files with 108 additions and 24 deletions
@@ -12,7 +12,10 @@ import {
} from "@medusajs/ui"
import { useTranslation } from "react-i18next"
import { useNavigate } from "react-router-dom"
import { ActionMenu } from "../../../../../components/common/action-menu"
import {
Action,
ActionMenu,
} from "../../../../../components/common/action-menu"
import { Skeleton } from "../../../../../components/common/skeleton"
import { UserLink } from "../../../../../components/common/user-link"
import {
@@ -97,11 +100,12 @@ export const ApiKeyGeneralSection = ({ apiKey }: ApiKeyGeneralSectionProps) => {
})
}
const dangerousActions = [
const dangerousActions: Action[] = [
{
icon: <Trash />,
label: t("actions.delete"),
onClick: handleDelete,
disabled: !apiKey.revoked_at,
},
]
@@ -110,6 +114,7 @@ export const ApiKeyGeneralSection = ({ apiKey }: ApiKeyGeneralSectionProps) => {
icon: <XCircle />,
label: t("apiKeyManagement.actions.revoke"),
onClick: handleRevoke,
disabled: !!apiKey.revoked_at,
})
}
@@ -107,11 +107,13 @@ export const ApiKeyRowActions = ({
icon: <XCircle />,
label: t("apiKeyManagement.actions.revoke"),
onClick: handleRevoke,
disabled: !!apiKey.revoked_at,
},
{
icon: <Trash />,
label: t("actions.delete"),
onClick: handleDelete,
disabled: !apiKey.revoked_at,
},
],
},