2022-05-31 03:34:48 +00:00
|
|
|
<script lang="ts" setup>
|
2022-06-14 07:56:55 +00:00
|
|
|
import {
|
|
|
|
IconAddCircle,
|
|
|
|
VButton,
|
2023-09-25 03:30:14 +00:00
|
|
|
VEmpty,
|
|
|
|
VLoading,
|
2022-06-14 07:56:55 +00:00
|
|
|
VSpace,
|
|
|
|
} from "@halo-dev/components";
|
2023-09-25 03:30:14 +00:00
|
|
|
import { ref } from "vue";
|
2024-06-25 04:31:44 +00:00
|
|
|
import { ucApiClient } from "@halo-dev/api-client";
|
2022-07-13 07:36:21 +00:00
|
|
|
import type { PersonalAccessToken } from "@halo-dev/api-client";
|
2023-09-25 03:30:14 +00:00
|
|
|
import { useQuery } from "@tanstack/vue-query";
|
2023-09-26 15:34:16 +00:00
|
|
|
import PersonalAccessTokenCreationModal from "../components/PersonalAccessTokenCreationModal.vue";
|
|
|
|
import PersonalAccessTokenListItem from "../components/PersonalAccessTokenListItem.vue";
|
2022-05-31 03:34:48 +00:00
|
|
|
|
2023-09-25 03:30:14 +00:00
|
|
|
const {
|
|
|
|
data: pats,
|
|
|
|
isLoading,
|
|
|
|
refetch,
|
|
|
|
} = useQuery<PersonalAccessToken[]>({
|
|
|
|
queryKey: ["personal-access-tokens"],
|
|
|
|
queryFn: async () => {
|
2024-06-25 04:31:44 +00:00
|
|
|
const { data } =
|
|
|
|
await ucApiClient.security.personalAccessToken.obtainPats();
|
2023-09-25 03:30:14 +00:00
|
|
|
return data;
|
|
|
|
},
|
|
|
|
refetchInterval(data) {
|
|
|
|
const deletingTokens = data?.filter(
|
|
|
|
(token) => !!token.metadata.deletionTimestamp
|
|
|
|
);
|
|
|
|
return deletingTokens?.length ? 1000 : false;
|
|
|
|
},
|
|
|
|
});
|
2022-05-31 03:34:48 +00:00
|
|
|
|
2023-09-25 03:30:14 +00:00
|
|
|
const creationModal = ref(false);
|
2022-05-31 03:34:48 +00:00
|
|
|
</script>
|
|
|
|
<template>
|
2023-09-25 03:30:14 +00:00
|
|
|
<div v-if="pats?.length" class="my-5 flex justify-end">
|
2024-01-10 04:50:26 +00:00
|
|
|
<VButton type="secondary" @click="creationModal = true">
|
2023-09-25 03:30:14 +00:00
|
|
|
<template #icon>
|
|
|
|
<IconAddCircle class="h-full w-full" />
|
|
|
|
</template>
|
|
|
|
{{ $t("core.common.buttons.new") }}
|
|
|
|
</VButton>
|
|
|
|
</div>
|
2022-05-31 03:34:48 +00:00
|
|
|
|
2023-09-25 03:30:14 +00:00
|
|
|
<VLoading v-if="isLoading" />
|
2022-05-31 03:34:48 +00:00
|
|
|
|
2023-09-25 03:30:14 +00:00
|
|
|
<Transition v-else-if="!pats?.length" appear name="fade">
|
|
|
|
<VEmpty
|
2023-11-30 10:56:10 +00:00
|
|
|
:message="$t('core.uc_profile.pat.list.empty.message')"
|
|
|
|
:title="$t('core.uc_profile.pat.list.empty.title')"
|
2023-09-25 03:30:14 +00:00
|
|
|
>
|
|
|
|
<template #actions>
|
|
|
|
<VSpace>
|
|
|
|
<VButton @click="refetch">
|
|
|
|
{{ $t("core.common.buttons.refresh") }}
|
|
|
|
</VButton>
|
2024-01-10 04:50:26 +00:00
|
|
|
<VButton type="primary" @click="creationModal = true">
|
2023-09-25 03:30:14 +00:00
|
|
|
<template #icon>
|
|
|
|
<IconAddCircle class="h-full w-full" />
|
|
|
|
</template>
|
|
|
|
{{ $t("core.common.buttons.new") }}
|
|
|
|
</VButton>
|
|
|
|
</VSpace>
|
|
|
|
</template>
|
|
|
|
</VEmpty>
|
|
|
|
</Transition>
|
|
|
|
|
|
|
|
<Transition v-else appear name="fade">
|
|
|
|
<ul
|
|
|
|
class="box-border h-full w-full divide-y divide-gray-100 overflow-hidden rounded-base border"
|
|
|
|
role="list"
|
|
|
|
>
|
|
|
|
<li v-for="(token, index) in pats" :key="index">
|
|
|
|
<PersonalAccessTokenListItem :token="token" />
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</Transition>
|
|
|
|
|
|
|
|
<PersonalAccessTokenCreationModal
|
|
|
|
v-if="creationModal"
|
2024-01-10 04:50:26 +00:00
|
|
|
@close="creationModal = false"
|
2023-09-25 03:30:14 +00:00
|
|
|
/>
|
2022-05-31 03:34:48 +00:00
|
|
|
</template>
|