From 794e4ea29526e77ef9ee9b31a5a146d7aa33242c Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Mon, 28 Apr 2025 15:05:06 -0230 Subject: [PATCH] Update jwt modal (#34938) * Update jwt modal * update key style --- .../interfaces/Settings/API/JWTSettings.tsx | 94 ++++++++++++++----- 1 file changed, 68 insertions(+), 26 deletions(-) diff --git a/apps/studio/components/interfaces/Settings/API/JWTSettings.tsx b/apps/studio/components/interfaces/Settings/API/JWTSettings.tsx index deafd573c5e..0e944240265 100644 --- a/apps/studio/components/interfaces/Settings/API/JWTSettings.tsx +++ b/apps/studio/components/interfaces/Settings/API/JWTSettings.tsx @@ -9,10 +9,14 @@ import { ChevronDown, Eye, EyeOff, + Hourglass, Key, + KeyRound, Loader2, PenTool, + Power, RefreshCw, + Undo, } from 'lucide-react' import { Dispatch, SetStateAction, useState } from 'react' import { toast } from 'sonner' @@ -20,12 +24,13 @@ import { number, object } from 'yup' import { useParams } from 'common' import { ButtonTooltip } from 'components/ui/ButtonTooltip' +import { FormActions } from 'components/ui/Forms/FormActions' import Panel from 'components/ui/Panel' +import { useAuthConfigQuery } from 'data/auth/auth-config-query' +import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' import { useJwtSecretUpdateMutation } from 'data/config/jwt-secret-update-mutation' import { useJwtSecretUpdatingStatusQuery } from 'data/config/jwt-secret-updating-status-query' import { useProjectPostgrestConfigQuery } from 'data/config/project-postgrest-config-query' -import { useAuthConfigQuery } from 'data/auth/auth-config-query' -import { useAuthConfigUpdateMutation } from 'data/auth/auth-config-update-mutation' import { useCheckPermissions } from 'hooks/misc/useCheckPermissions' import { uuidv4 } from 'lib/helpers' import { @@ -38,21 +43,18 @@ import { DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, + Form, Input, InputNumber, Modal, WarningIcon, - Form, } from 'ui' +import { Admonition } from 'ui-patterns' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' import { JWT_SECRET_UPDATE_ERROR_MESSAGES, JWT_SECRET_UPDATE_PROGRESS_MESSAGES, } from './API.constants' -import { Admonition } from 'ui-patterns' -import { FormActions } from 'components/ui/Forms/FormActions' -import { FormPanel } from 'components/ui/Forms/FormPanel' -import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection' const schema = object({ JWT_EXP: number() @@ -133,7 +135,10 @@ const JWTSettings = () => { toast( 'Successfully submitted JWT secret update request. Please wait while your project is updated.' ) - } catch (error) {} + } catch (error) { + toast.error('Failed to update JWT secret. Please try again.') + console.error('Failed to update JWT secret:', error) + } } return ( @@ -296,30 +301,67 @@ const JWTSettings = () => { setIsGeneratingKey(false)} onConfirm={() => handleJwtSecretUpdate('ROLL', setIsGeneratingKey)} - alert={{ - title: 'This will invalidate all existing API keys', - description: ( - <> - Generating a new JWT secret will invalidate all of - your API keys, including your service_role and{' '} - anon keys. Your project will also be restarted during - this process, which will terminate any existing connections. You may receive API - errors for up to 2 minutes while the new secret is deployed. - - ), - }} > -

- This action cannot be undone and the old JWT secret will be lost. All existing API keys - will be invalidated, and any open connections will be terminated. -

+