mirror of https://github.com/halo-dev/halo
fix: pat can not be copied (#5274)
#### What type of PR is this? /area console /kind bug /milestone 2.12.x #### What this PR does / why we need it: 修复创建 PAT 之后,点击复制按钮无法复制 token 的问题。 #### Which issue(s) this PR fixes: Fixes #5273 #### Special notes for your reviewer: 测试步骤: 1. 构建生产环境的 UC。 2. 创建 PAT,点击复制按钮,观察是否能够正常复制。 #### Does this PR introduce a user-facing change? ```release-note 修复创建 PAT 之后,点击复制按钮无法复制 token 的问题。 ```pull/3818/head^2
parent
47a1aa7631
commit
e8a9f063f1
|
@ -7,7 +7,6 @@ import { Dialog, Toast, VButton, VModal, VSpace } from "@halo-dev/components";
|
|||
import { useMutation, useQueryClient } from "@tanstack/vue-query";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import type { PatSpec, PersonalAccessToken } from "@halo-dev/api-client";
|
||||
import { computed } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useRoleTemplateSelection } from "@/composables/use-role";
|
||||
import { useRoleStore } from "@/stores/role";
|
||||
|
@ -49,11 +48,11 @@ const { permissions } = useRoleStore();
|
|||
const { roleTemplateGroups, handleRoleTemplateSelect, selectedRoleTemplates } =
|
||||
useRoleTemplateSelection(toRefs(permissions).permissions);
|
||||
|
||||
const {
|
||||
mutate,
|
||||
isLoading,
|
||||
data: token,
|
||||
} = useMutation({
|
||||
const { copy } = useClipboard({
|
||||
legacy: true,
|
||||
});
|
||||
|
||||
const { mutate, isLoading } = useMutation({
|
||||
mutationKey: ["pat-creation"],
|
||||
mutationFn: async () => {
|
||||
if (formState.value.spec?.expiresAt) {
|
||||
|
@ -74,28 +73,23 @@ const {
|
|||
queryClient.invalidateQueries({ queryKey: ["personal-access-tokens"] });
|
||||
emit("close");
|
||||
|
||||
const token = data.metadata.annotations?.[patAnnotations.ACCESS_TOKEN];
|
||||
|
||||
setTimeout(() => {
|
||||
Dialog.info({
|
||||
title: t("core.uc_profile.pat.operations.copy.title"),
|
||||
description: data.metadata.annotations?.[patAnnotations.ACCESS_TOKEN],
|
||||
description: token,
|
||||
confirmType: "secondary",
|
||||
confirmText: t("core.common.buttons.copy"),
|
||||
showCancel: false,
|
||||
onConfirm: () => {
|
||||
copy();
|
||||
copy(token || "");
|
||||
Toast.success(t("core.common.toast.copy_success"));
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const { copy } = useClipboard({
|
||||
source: computed(
|
||||
() => token.value?.metadata.annotations?.[patAnnotations.ACCESS_TOKEN] || ""
|
||||
),
|
||||
legacy: true,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Reference in New Issue