From 4ea55e58677d31739513b90ca04e437e3d5aa793 Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Tue, 11 Feb 2025 17:57:00 +0100 Subject: [PATCH] add frontend support for api token create, delete and revoke --- .../Controllers/Api/V1/ApiTokenController.php | 6 + .../Common/Invitation/InvitationTableRow.vue | 2 +- .../Common/Member/MemberTableRow.vue | 2 +- .../Pages/Profile/Partials/ApiTokensForm.vue | 317 ++++++++++++++++++ resources/js/Pages/Profile/Show.vue | 4 + .../js/Pages/Teams/Partials/ExportData.vue | 2 +- resources/js/packages/api/src/index.ts | 9 + .../packages/api/src/openapi.json.client.ts | 183 +++++++--- resources/js/packages/ui/src/utils/time.ts | 4 + 9 files changed, 488 insertions(+), 41 deletions(-) create mode 100644 resources/js/Pages/Profile/Partials/ApiTokensForm.vue diff --git a/app/Http/Controllers/Api/V1/ApiTokenController.php b/app/Http/Controllers/Api/V1/ApiTokenController.php index 140f4891..f590568f 100644 --- a/app/Http/Controllers/Api/V1/ApiTokenController.php +++ b/app/Http/Controllers/Api/V1/ApiTokenController.php @@ -37,6 +37,8 @@ class ApiTokenController extends Controller * The response will contain the access token that can be used to send authenticated API requests. * Please note that the access token is only shown in this response and cannot be retrieved later. * + * @operationId createApiToken + * * @throws AuthorizationException */ public function store(ApiTokenStoreRequest $request): ApiTokenWithAccessTokenResource @@ -53,6 +55,8 @@ class ApiTokenController extends Controller /** * Revoke an api token * + * @operationId revokeApiToken + * * @throws AuthorizationException */ public function revoke(string $apiTokenId): JsonResponse @@ -69,6 +73,8 @@ class ApiTokenController extends Controller /** * Delete an api token * + * @operationId deleteApiToken + * * @throws AuthorizationException */ public function destroy(string $apiTokenId): JsonResponse diff --git a/resources/js/Components/Common/Invitation/InvitationTableRow.vue b/resources/js/Components/Common/Invitation/InvitationTableRow.vue index 06e65bb7..7ac253c2 100644 --- a/resources/js/Components/Common/Invitation/InvitationTableRow.vue +++ b/resources/js/Components/Common/Invitation/InvitationTableRow.vue @@ -39,7 +39,7 @@ async function resendInvitation() { await handleApiRequestNotifications( () => api.resendInvitationEmail( - {}, + undefined, { params: { invitation: props.invitation.id, diff --git a/resources/js/Components/Common/Member/MemberTableRow.vue b/resources/js/Components/Common/Member/MemberTableRow.vue index 1703fd88..3c423a0b 100644 --- a/resources/js/Components/Common/Member/MemberTableRow.vue +++ b/resources/js/Components/Common/Member/MemberTableRow.vue @@ -32,7 +32,7 @@ async function invitePlaceholder(id: string) { await handleApiRequestNotifications( () => api.invitePlaceholder( - {}, + undefined, { params: { organization: organizationId, diff --git a/resources/js/Pages/Profile/Partials/ApiTokensForm.vue b/resources/js/Pages/Profile/Partials/ApiTokensForm.vue new file mode 100644 index 00000000..2db353be --- /dev/null +++ b/resources/js/Pages/Profile/Partials/ApiTokensForm.vue @@ -0,0 +1,317 @@ + + + diff --git a/resources/js/Pages/Profile/Show.vue b/resources/js/Pages/Profile/Show.vue index 9de35c9c..947975a3 100644 --- a/resources/js/Pages/Profile/Show.vue +++ b/resources/js/Pages/Profile/Show.vue @@ -9,6 +9,7 @@ import UpdateProfileInformationForm from '@/Pages/Profile/Partials/UpdateProfile import { usePage } from '@inertiajs/vue3'; import type { User } from '@/types/models'; import type { Session } from '@/types/jetstream'; +import ApiTokensForm from "@/Pages/Profile/Partials/ApiTokensForm.vue"; defineProps<{ confirmsTwoFactorAuthentication: boolean; @@ -65,6 +66,9 @@ const page = usePage<{ + + +