Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(ui): migrate project upgrade gate to v3 (#7954)

Andrew Huangeeb00b31f868
diff --git a/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.stories.tsx b/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.stories.tsx
index c31981ff1b..93ce77c171 100644
--- a/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.stories.tsx
+++ b/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.stories.tsx
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
+import { TriangleAlertIcon } from "lucide-react";
import { Button } from "../../generic/Button";
import { AccessRestrictedDialog } from "./AccessRestrictedDialog";
@@ -64,7 +65,7 @@ export const WithAction: Story = {
docs: {
description: {
story:
- "Surfaces with a self-serve flow (e.g. request access) can append a call to action after the standard navigation buttons."
+ "Surfaces with a self-serve flow (e.g. request access) can append a call to action after the standard navigation buttons. The footer gives it the remaining row width and stacks it when the panel is narrow."
}
}
}
@@ -83,3 +84,29 @@ export const CustomCopy: Story = {
}
}
};
+
+export const Prerequisite: Story = {
+ name: "Example: Prerequisite",
+ args: {
+ title: "Upgrade your secrets engine to view your project dashboard.",
+ subtitle: null,
+ description: "Upgrade this project before viewing its secrets in the UI.",
+ badgeIcon: <TriangleAlertIcon />,
+ badgeLabel: "Upgrade Required",
+ docsUrl: null,
+ showGoBack: false,
+ action: (
+ <Button variant="project" isFullWidth>
+ Upgrade Secrets Engine
+ </Button>
+ )
+ },
+ parameters: {
+ docs: {
+ description: {
+ story:
+ "Customize the badge, omit the access-control link, and hide history-based navigation when a page is gated by a prerequisite rather than a missing permission."
+ }
+ }
+ }
+};
diff --git a/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx b/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx
index d9d26bc860..8410530968 100644
--- a/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx
+++ b/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx
@@ -4,6 +4,7 @@ import { ArrowLeftIcon, ExternalLinkIcon, HouseIcon, InfoIcon, LockIcon } from "
import { Badge } from "../../generic/Badge";
import { Button } from "../../generic/Button";
+import { CodeBlock } from "../../generic/CodeBlock";
import { cn } from "../../utils";
const RBAC_DOCS_URL =
@@ -54,25 +55,31 @@ export const toPermissionRequirement = (
typeof action === "string" && typeof subject === "string" ? { action, subject } : undefined;
type Props = {
- // First line of the two-line heading, matching the error-page family.
+ // Primary heading, matching the error-page family. Set subtitle to null for one line.
title?: string;
- subtitle?: string;
+ subtitle?: string | null;
description?: ReactNode;
// The CASL action/subject the viewer is missing. Shown verbatim so an operator can hand it to
// whoever edits their role.
requirement?: TAccessRestrictedRequirement;
- docsUrl?: string;
+ // Set to null when access is gated by a prerequisite rather than role-based access control.
+ docsUrl?: string | null;
+ // Non-permission prerequisites can replace the default lock badge while reusing the gate.
+ badgeIcon?: ReactNode;
+ badgeLabel?: string;
// Extra call to action rendered after "Back to Home" — e.g. a request-access flow on the
// surfaces that have one.
action?: ReactNode;
+ showGoBack?: boolean;
className?: string;
};
/**
- * Page- and tab-level permission gate, styled to the ErrorPage/ForbiddenPage family: a
+ * Page- and tab-level access gate, styled to the ErrorPage/ForbiddenPage family: a
* dialog-look panel floating over a redacted stand-in for the content. It renders in normal
* document flow, so the surrounding page chrome (sidebar, sibling tabs) stays usable by both
- * pointer and keyboard.
+ * pointer and keyboard. It defaults to permission-focused copy but can represent another
+ * prerequisite with custom copy and badge content.
*
* For a single section inside an otherwise usable page, use AccessRestrictedNotice instead.
*/
@@ -82,17 +89,17 @@ export const AccessRestrictedDialog = ({
description = "Your role doesn't include the permission this page requires.",
requirement,
docsUrl = RBAC_DOCS_URL,
+ badgeIcon = <LockIcon />,
+ badgeLabel = "Access Restricted",
action,
+ showGoBack = true,
className
}: Props) => {
const titleId = useId();
- const monoRows: [string, string][] = [
- ...(requirement
- ? ([["requires", `${requirement.action} on ${requirement.subject}`]] as [string, string][])
- : []),
- ["route", window.location.pathname]
- ];
+ const accessDetails = requirement
+ ? `requires ${requirement.action} on ${requirement.subject}\nroute ${window.location.pathname}`
+ : window.location.pathname;
// Deliberately NOT a real <Dialog>: this is a permanent page state with no close affordance,
// and Radix DialogContent hardcodes a Tab loop (FocusScope loop) plus mount autofocus even
@@ -108,51 +115,59 @@ export const AccessRestrictedDialog = ({
<div className="relative col-start-1 row-start-1 flex items-center justify-center p-4">
<section
aria-labelledby={titleId}
- className="flex w-full max-w-2xl animate-in flex-col gap-5 rounded-lg border border-border bg-popover p-6 pb-0 text-foreground shadow-lg duration-200 fade-in-0 zoom-in-95"
+ className="@container/access-restricted flex w-full max-w-2xl animate-in flex-col gap-5 rounded-lg border border-border bg-popover p-6 pb-0 text-foreground shadow-lg duration-200 fade-in-0 zoom-in-95"
>
<div className="flex flex-col items-start gap-5 text-left">
<Badge variant="warning" className="h-6 px-2">
- <LockIcon />
- Access Restricted
+ {badgeIcon}
+ {badgeLabel}
</Badge>
{/* Alliance ships only weight 400, so font-normal rather than a faux-bolded semibold. */}
- <h2 id={titleId} className="font-alliance text-3xl leading-tight font-normal">
+ <h2
+ id={titleId}
+ className="font-alliance text-3xl leading-tight font-normal text-balance"
+ >
{title}
- <br />
- <span className="text-2xl">{subtitle}</span>
+ {subtitle && (
+ <>
+ <br />
+ <span className="text-2xl">{subtitle}</span>
+ </>
+ )}
</h2>
- <p className="text-sm leading-relaxed text-accent">{description}</p>
+ <div className="flex flex-col gap-3 text-sm leading-relaxed text-accent">
+ {description}
+ </div>
</div>
- <div className="flex flex-col gap-1.5 rounded-md border border-border bg-bunker-800/50 px-4 py-3">
- {monoRows.map(([key, value]) => (
- <div key={key} className="flex gap-4 font-mono text-xs">
- <span className="w-16 shrink-0 text-muted">{key}</span>
- <span className="break-all text-label">{value}</span>
- </div>
- ))}
- </div>
- <a
- href={docsUrl}
- target="_blank"
- rel="noopener noreferrer"
- className="flex w-fit items-center gap-1.5 text-xs text-info transition-colors hover:text-info/75"
- >
- <InfoIcon className="size-3.5" />
- Access control documentation
- <ExternalLinkIcon className="size-3" />
- </a>
- <div className="-mx-6 flex flex-row flex-wrap justify-end gap-2 rounded-b-lg border-t border-border bg-container p-4">
- <Button variant="outline" onClick={() => window.history.back()}>
- <ArrowLeftIcon />
- Go Back
- </Button>
- <Button variant="neutral" asChild>
- <Link to="/">
- <HouseIcon />
- Back to Home
- </Link>
- </Button>
- {action}
+ <CodeBlock label={requirement ? "Access details" : undefined} value={accessDetails} />
+ {docsUrl && (
+ <a
+ href={docsUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex w-fit items-center gap-1.5 text-xs text-info transition-colors hover:text-info/75"
+ >
+ <InfoIcon className="size-3.5" />
+ Access control documentation
+ <ExternalLinkIcon className="size-3" />
+ </a>
+ )}
+ <div className="-mx-6 flex flex-col gap-2 rounded-b-lg border-t border-border bg-container p-4 @xl/access-restricted:flex-row @xl/access-restricted:items-center">
+ <div className="ml-auto flex flex-row flex-wrap justify-end gap-2">
+ {showGoBack && (
+ <Button variant="outline" onClick={() => window.history.back()}>
+ <ArrowLeftIcon />
+ Go Back
+ </Button>
+ )}
+ <Button variant="neutral" asChild>
+ <Link to="/">
+ <HouseIcon />
+ Back to Home
+ </Link>
+ </Button>
+ </div>
+ {action && <div className="flex min-w-0 flex-1 justify-end">{action}</div>}
</div>
</section>
</div>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx
index 79a658717d..65d043d26a 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretV2MigrationSection/SecretV2MigrationSection.tsx
@@ -1,13 +1,32 @@
import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
-import { faTriangleExclamation, faWarning } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
import { useQueryClient } from "@tanstack/react-query";
+import { CircleXIcon, TriangleAlertIcon } from "lucide-react";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import { Button, Checkbox, Modal, ModalContent, Spinner } from "@app/components/v2";
+import {
+ AccessRestrictedDialog,
+ Alert,
+ AlertDescription,
+ Button,
+ Checkbox,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldContent,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ FieldLegend,
+ FieldSet,
+ Spinner
+} from "@app/components/v3";
import { useProject, useProjectPermission } from "@app/context";
import { usePopUp } from "@app/hooks";
import { projectKeys, useGetWorkspaceById, useMigrateProjectToV3 } from "@app/hooks/api";
@@ -40,7 +59,12 @@ export const SecretV2MigrationSection = () => {
);
const { hasProjectRole } = useProjectPermission();
const migrateProjectToV3 = useMigrateProjectToV3();
- const { handleSubmit, control, reset } = useForm({ resolver: zodResolver(formSchema) });
+ const {
+ handleSubmit,
+ control,
+ reset,
+ formState: { isSubmitting, isValid }
+ } = useForm({ resolver: zodResolver(formSchema), mode: "onChange" });
useEffect(() => {
if (!popUp.migrationInfo.isOpen) {
reset();
@@ -76,71 +100,95 @@ export const SecretV2MigrationSection = () => {
const isAdmin = hasProjectRole(ProjectMembershipRole.Admin);
return (
- <div className="mt-4 flex max-w-2xl flex-col rounded-lg border border-primary/50 bg-primary/10 px-6 py-5">
+ <div className="flex w-full flex-col gap-3">
{isUpgrading && (
- <div className="bg-opacity-80 absolute top-0 left-0 z-50 flex h-screen w-screen items-center justify-center bg-bunker-500">
- <Spinner size="lg" className="text-primary" />
- <div className="ml-4 flex flex-col space-y-1">
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-page/80 backdrop-blur-sm">
+ <Spinner size="lg" label="Upgrading secrets engine" />
+ <div className="ml-4 flex flex-col gap-1 text-foreground">
<div className="text-3xl font-medium">Please wait</div>
- <span className="inline-block">Upgrading secrets engine...</span>
+ <span>Upgrading secrets engine...</span>
</div>
</div>
)}
- <div className="mb-4 flex items-start gap-2">
- <FontAwesomeIcon icon={faWarning} size="xl" className="mt-1 text-primary" />
- <p className="text-xl font-medium">Upgrade secrets engine version</p>
- </div>
- <p className="mx-1 mb-4 leading-7 text-mineshaft-100">
- Your existing workflows to fetch secrets will continue to work. However, viewing secrets on
- the UI requires you to upgrade your project&apos;s secrets engine version.
- </p>
- <p className="mx-1 mb-4 leading-7 text-mineshaft-100">
- Upgrading is free and enables the use of Infisical&apos;s new secrets engine, which is 10x
- faster and allows you to encrypt secrets with your own KMS provider.
- </p>
- <p className="mx-1 mb-6 leading-7 text-mineshaft-100">
- The upgrade takes only 1-2 minutes and will not cause any downtime.
- </p>
- <Button
- onClick={() => handlePopUpOpen("migrationInfo")}
- isDisabled={!isAdmin || isUpgrading}
- isLoading={migrateProjectToV3.isPending}
- className="w-full"
- >
- {isAdmin ? "Upgrade Secrets Engine" : "Upgrade requires admin privilege"}
- </Button>
+ <AccessRestrictedDialog
+ title="Upgrade your secrets engine to view your project dashboard."
+ subtitle={null}
+ description={
+ <>
+ <p>
+ Your existing secret-fetching workflows will continue to work. To view secrets in the
+ UI, upgrade your project’s secrets engine.
+ </p>
+ <p>
+ The upgrade takes 1–2 minutes with no downtime and delivers up to 10× faster
+ performance plus support for your own KMS provider.
+ </p>
+ </>
+ }
+ badgeIcon={<TriangleAlertIcon />}
+ badgeLabel="Upgrade Required"
+ docsUrl={null}
+ showGoBack={false}
+ action={
+ <Button
+ variant="project"
+ onClick={() => handlePopUpOpen("migrationInfo")}
+ isDisabled={!isAdmin || isUpgrading}
+ isPending={migrateProjectToV3.isPending}
+ isFullWidth
+ >
+ {isAdmin ? "Upgrade Secrets Engine" : "Upgrade requires admin privilege"}
+ </Button>
+ }
+ />
{didProjectUpgradeFailed && (
- <p className="mt-2 text-sm leading-7 text-red-400">
- <FontAwesomeIcon icon={faTriangleExclamation} className="mr-2" />
- Secrets engine upgrade unsuccessful. For assistance, please contact the Infisical support
- team.
- </p>
+ <Alert variant="danger">
+ <CircleXIcon />
+ <AlertDescription>
+ Secrets engine upgrade unsuccessful. For assistance, please contact the Infisical
+ support team.
+ </AlertDescription>
+ </Alert>
)}
- <Modal
- isOpen={popUp.migrationInfo.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("migrationInfo", isOpen)}
+ <Dialog
+ open={popUp.migrationInfo.isOpen}
+ onOpenChange={(open) => handlePopUpToggle("migrationInfo", open)}
>
- <ModalContent
- title="Upgrade Checklist"
- subTitle="To ensure smooth transition, please ensure the following requirements are met before upgrading this project."
- >
- <div>
- <form onSubmit={handleSubmit(handleMigrationSecretV2)}>
- <div className="flex flex-col space-y-4">
+ <DialogContent className="max-w-xl">
+ <DialogHeader>
+ <DialogTitle>Upgrade Checklist</DialogTitle>
+ <DialogDescription>
+ To ensure smooth transition, please ensure the following requirements are met before
+ upgrading this project.
+ </DialogDescription>
+ </DialogHeader>
+ <form onSubmit={handleSubmit(handleMigrationSecretV2)} className="flex flex-col gap-6">
+ <FieldSet>
+ <FieldLegend className="sr-only">Upgrade requirements</FieldLegend>
+ <FieldGroup>
<Controller
control={control}
name="isCLIChecked"
defaultValue={false}
render={({ field: { onBlur, value, onChange }, fieldState: { error } }) => (
- <Checkbox
- id="is-cli-checked"
- isChecked={value}
- onCheckedChange={onChange}
- onBlur={onBlur}
- isError={Boolean(error?.message)}
- >
- Infisical CLI version is v0.25.0 or above.
- </Checkbox>
+ <Field orientation="horizontal" data-invalid={Boolean(error)}>
+ <Checkbox
+ id="is-cli-checked"
+ variant="project"
+ isChecked={value}
+ onCheckedChange={(checked) => onChange(checked === true)}
+ onBlur={onBlur}
+ isError={Boolean(error)}
+ />
+ <FieldContent>
+ <FieldLabel htmlFor="is-cli-checked" className="cursor-pointer" size="sm">
+ Infisical CLI version is v0.25.0 or above.
+ </FieldLabel>
+ <FieldError>
+ {error && "Confirm this requirement before upgrading."}
+ </FieldError>
+ </FieldContent>
+ </Field>
)}
/>
<Controller
@@ -148,15 +196,28 @@ export const SecretV2MigrationSection = () => {
name="isOperatorChecked"
defaultValue={false}
render={({ field: { onBlur, value, onChange }, fieldState: { error } }) => (
- <Checkbox
- id="is-operator-checked"
- isChecked={value}
- onCheckedChange={onChange}
- onBlur={onBlur}
- isError={Boolean(error?.message)}
- >
- Infisical Kubernetes Operator version is v0.7.0 or above.
- </Checkbox>
+ <Field orientation="horizontal" data-invalid={Boolean(error)}>
+ <Checkbox
+ id="is-operator-checked"
+ variant="project"
+ isChecked={value}
+ onCheckedChange={(checked) => onChange(checked === true)}
+ onBlur={onBlur}
+ isError={Boolean(error)}
+ />
+ <FieldContent>
+ <FieldLabel
+ htmlFor="is-operator-checked"
+ className="cursor-pointer"
+ size="sm"
+ >
+ Infisical Kubernetes Operator version is v0.7.0 or above.
+ </FieldLabel>
+ <FieldError>
+ {error && "Confirm this requirement before upgrading."}
+ </FieldError>
+ </FieldContent>
+ </Field>
)}
/>
<Controller
@@ -164,28 +225,52 @@ export const SecretV2MigrationSection = () => {
name="shouldCloseOpenApprovals"
defaultValue={false}
render={({ field: { onBlur, value, onChange }, fieldState: { error } }) => (
- <Checkbox
- id="is-approvals-checked"
- isChecked={value}
- onCheckedChange={onChange}
- onBlur={onBlur}
- isError={Boolean(error?.message)}
- >
- Close/merge all open approval/access requests.
- </Checkbox>
+ <Field orientation="horizontal" data-invalid={Boolean(error)}>
+ <Checkbox
+ id="is-approvals-checked"
+ variant="project"
+ isChecked={value}
+ onCheckedChange={(checked) => onChange(checked === true)}
+ onBlur={onBlur}
+ isError={Boolean(error)}
+ />
+ <FieldContent>
+ <FieldLabel
+ htmlFor="is-approvals-checked"
+ className="cursor-pointer"
+ size="sm"
+ >
+ Close/merge all open approval/access requests.
+ </FieldLabel>
+ <FieldError>
+ {error && "Confirm this requirement before upgrading."}
+ </FieldError>
+ </FieldContent>
+ </Field>
)}
/>
- </div>
- <div className="mt-8 flex space-x-4">
- <Button type="submit">Confirm Upgrade</Button>
- <Button variant="outline_bg" onClick={() => handlePopUpToggle("migrationInfo")}>
- Cancel
- </Button>
- </div>
- </form>
- </div>
- </ModalContent>
- </Modal>
+ </FieldGroup>
+ </FieldSet>
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="ghost"
+ onClick={() => handlePopUpToggle("migrationInfo")}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="submit"
+ variant="project"
+ isDisabled={!isValid || isSubmitting}
+ isPending={isSubmitting}
+ >
+ Confirm Upgrade
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
</div>
);
};