Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix: show and allow editing 2FA method in credential edit modal (SKY-8430) (#5137)
Celal Zamanoğlu2003d6c26a82
diff --git a/skyvern-frontend/src/routes/credentials/CredentialsModal.tsx b/skyvern-frontend/src/routes/credentials/CredentialsModal.tsxindex c16718016..ece170524 100644--- a/skyvern-frontend/src/routes/credentials/CredentialsModal.tsx+++ b/skyvern-frontend/src/routes/credentials/CredentialsModal.tsx@@ -32,7 +32,7 @@ import { AxiosError } from "axios";import {CheckCircledIcon,CrossCircledIcon,- InfoCircledIcon,+ ExclamationTriangleIcon,ReloadIcon,} from "@radix-ui/react-icons";import { Alert, AlertDescription } from "@/components/ui/alert";@@ -1182,11 +1182,12 @@ function CredentialsModal({</DialogTitle></DialogHeader>{isEditMode && editingGroups.values && (- <Alert>- <InfoCircledIcon className="size-4" />+ <Alert variant="warning">+ <ExclamationTriangleIcon className="size-4" /><AlertDescription>- For security, saved values are never retrieved. All credential- fields must be filled in to save your changes.+ For security, saved values are never retrieved. Changing any field+ other than the credential name requires re-entering all fields,+ including passwords and 2FA settings.</AlertDescription></Alert>)}diff --git a/skyvern-frontend/src/routes/credentials/PasswordCredentialContent.tsx b/skyvern-frontend/src/routes/credentials/PasswordCredentialContent.tsxindex e159bfb69..22cd399b1 100644--- a/skyvern-frontend/src/routes/credentials/PasswordCredentialContent.tsx+++ b/skyvern-frontend/src/routes/credentials/PasswordCredentialContent.tsx@@ -73,7 +73,21 @@ function PasswordCredentialContent({>(totp_type === "email" || totp_type === "text" ? totp_type : "authenticator",);+ const [totpAccordionValue, setTotpAccordionValue] = useState<string>("");const [showPassword, setShowPassword] = useState(false);++ // Sync totpMethod and auto-expand accordion when totp_type prop changes+ // (e.g. edit data arriving after mount)+ useEffect(() => {+ setTotpMethod(+ totp_type === "email" || totp_type === "text"+ ? totp_type+ : "authenticator",+ );+ if (totp_type && totp_type !== "none") {+ setTotpAccordionValue("two-factor-authentication");+ }+ }, [totp_type]);const prevUsernameRef = useRef(username);const prevTotpMethodRef = useRef<typeof totpMethod>(totpMethod);const totpIdentifierLabel =@@ -130,10 +144,11 @@ function PasswordCredentialContent({prevTotpMethodRef.current = totpMethod;}, [totpMethod, totp_identifier, updateValues, username]);- // Update totp_type when totpMethod changes+ // Update totp_type when totpMethod changes; also enter edit mode for valuesconst handleTotpMethodChange = (method: "authenticator" | "email" | "text",) => {+ onEnableEditValues?.();setTotpMethod(method);updateValues({totp: method === "authenticator" ? totp : "",@@ -253,7 +268,12 @@ function PasswordCredentialContent({)}</div><Separator />- <Accordion type="single" collapsible>+ <Accordion+ type="single"+ collapsible+ value={totpAccordionValue}+ onValueChange={setTotpAccordionValue}+ ><AccordionItem value="two-factor-authentication" className="border-b-0"><AccordionTrigger className="py-2">Two-Factor Authentication@@ -264,11 +284,7 @@ function PasswordCredentialContent({Set up Skyvern to automatically retrieve two-factorauthentication codes.</p>- <div- className={cn("grid h-36 grid-cols-3 gap-4", {- "pointer-events-none opacity-70": valuesReadOnly,- })}- >+ <div className="grid h-36 grid-cols-3 gap-4"><divclassName={cn("flex cursor-pointer items-center justify-center gap-2 rounded-lg bg-slate-elevation1 hover:bg-slate-elevation3",