mirror of https://github.com/halo-dev/halo
perf: improve the display of user auth providers in user details (#3624)
#### What type of PR is this? /kind improvement /area console /milestone 2.4.x #### What this PR does / why we need it: 优化用户详情页面中认证方式的显示逻辑。 #### Does this PR introduce a user-facing change? ```release-note None ```pull/3617/head^2
parent
9814053d0e
commit
4c11ccfcd1
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
import { Dialog, IconUserSettings, VButton, VTag } from "@halo-dev/components";
|
||||
import type { ComputedRef, Ref } from "vue";
|
||||
import { inject } from "vue";
|
||||
import { inject, computed } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import type { DetailedUser, ListedAuthProvider } from "@halo-dev/api-client";
|
||||
import { rbacAnnotations } from "@/constants/annotations";
|
||||
|
@ -17,7 +17,7 @@ const isCurrentUser = inject<ComputedRef<boolean>>("isCurrentUser");
|
|||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
const { data: authProviders } = useQuery<ListedAuthProvider[]>({
|
||||
const { data: authProviders, isFetching } = useQuery<ListedAuthProvider[]>({
|
||||
queryKey: ["user-auth-providers"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.authProvider.listAuthProviders();
|
||||
|
@ -27,6 +27,12 @@ const { data: authProviders } = useQuery<ListedAuthProvider[]>({
|
|||
enabled: isCurrentUser,
|
||||
});
|
||||
|
||||
const availableAuthProviders = computed(() => {
|
||||
return authProviders.value?.filter(
|
||||
(authProvider) => authProvider.enabled && authProvider.supportsBinding
|
||||
);
|
||||
});
|
||||
|
||||
const handleUnbindAuth = (authProvider: ListedAuthProvider) => {
|
||||
Dialog.warning({
|
||||
title: t("core.user.detail.operations.unbind.title", {
|
||||
|
@ -149,7 +155,7 @@ const handleBindAuth = (authProvider: ListedAuthProvider) => {
|
|||
</dd>
|
||||
</div>
|
||||
<div
|
||||
v-if="isCurrentUser"
|
||||
v-if="!isFetching && isCurrentUser && availableAuthProviders?.length"
|
||||
class="bg-white py-5 px-2 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4"
|
||||
>
|
||||
<dt class="text-sm font-medium text-gray-900">
|
||||
|
|
Loading…
Reference in New Issue