Skip to content

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

feat(ui): add LookingForOrgPageLink component for organization navigation

Andrew Huangee378ffc60ad
diff --git a/frontend/src/components/v3/platform/LookingForOrgPageLink/LookingForOrgPageLink.tsx b/frontend/src/components/v3/platform/LookingForOrgPageLink/LookingForOrgPageLink.tsx
new file mode 100644
index 0000000000..d63888f6ea
--- /dev/null
+++ b/frontend/src/components/v3/platform/LookingForOrgPageLink/LookingForOrgPageLink.tsx
@@ -0,0 +1,55 @@
+import { Link } from "@tanstack/react-router";
+import { ChevronRightIcon } from "lucide-react";
+
+import { useOrganization } from "@app/context";
+
+import { Button } from "../../generic";
+import { cn } from "../../utils";
+
+const ORG_PAGE_CONFIG = {
+ settings: {
+ to: "/organizations/$orgId/settings",
+ label: "settings"
+ },
+ accessControl: {
+ to: "/organizations/$orgId/access-management",
+ label: "access control"
+ },
+ auditLogs: {
+ to: "/organizations/$orgId/audit-logs",
+ label: "audit logs"
+ }
+} as const;
+
+export type TLookingForOrgPageLinkProps = {
+ page: keyof typeof ORG_PAGE_CONFIG;
+ target?: "current" | "root";
+ className?: string;
+};
+
+export const LookingForOrgPageLink = ({
+ page,
+ target = "current",
+ className
+}: TLookingForOrgPageLinkProps) => {
+ const { currentOrg, isSubOrganization } = useOrganization();
+ const { to, label } = ORG_PAGE_CONFIG[page];
+
+ if (target === "root" && !isSubOrganization) {
+ return null;
+ }
+
+ const orgId = target === "root" ? (currentOrg.rootOrgId ?? "") : currentOrg.id;
+ const scopeLabel =
+ target === "root" ? "root org" : `${isSubOrganization ? "sub-" : ""}org`;
+ const text = `${scopeLabel} ${label}`;
+
+ return (
+ <Button variant="ghost" size="sm" asChild className={cn("text-muted", className)}>
+ <Link to={to} params={{ orgId }}>
+ {text.charAt(0).toUpperCase() + text.slice(1)}
+ <ChevronRightIcon aria-hidden />
+ </Link>
+ </Button>
+ );
+};
diff --git a/frontend/src/components/v3/platform/LookingForOrgPageLink/index.ts b/frontend/src/components/v3/platform/LookingForOrgPageLink/index.ts
new file mode 100644
index 0000000000..d5e19d4702
--- /dev/null
+++ b/frontend/src/components/v3/platform/LookingForOrgPageLink/index.ts
@@ -0,0 +1 @@
+export { LookingForOrgPageLink, type TLookingForOrgPageLinkProps } from "./LookingForOrgPageLink";
diff --git a/frontend/src/components/v3/platform/index.ts b/frontend/src/components/v3/platform/index.ts
index a430afa207..c1f62a6d58 100644
--- a/frontend/src/components/v3/platform/index.ts
+++ b/frontend/src/components/v3/platform/index.ts
@@ -4,6 +4,7 @@ export * from "./DeleteConfirmDialog";
export * from "./DocumentationLinkBadge";
export * from "./GatewayPicker";
export * from "./IdentityRoleBadges";
+export * from "./LookingForOrgPageLink";
export * from "./OverflowBadgeList";
export * from "./PageHeader";
export * from "./PageLoader";
diff --git a/frontend/src/pages/kms/SettingsPage/SettingsPage.tsx b/frontend/src/pages/kms/SettingsPage/SettingsPage.tsx
index 56eda913fa..b1c564d93a 100644
--- a/frontend/src/pages/kms/SettingsPage/SettingsPage.tsx
+++ b/frontend/src/pages/kms/SettingsPage/SettingsPage.tsx
@@ -1,10 +1,8 @@
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
-import { Link } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
import { PageHeader, TabPanel, Tabs } from "@app/components/v2";
-import { useOrganization } from "@app/context";
+import { LookingForOrgPageLink } from "@app/components/v3";
import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectGeneralTab } from "@app/pages/project/SettingsPage/components/ProjectGeneralTab";
@@ -19,8 +17,6 @@ const tabs = [
export const SettingsPage = () => {
const { t } = useTranslation();
- const { currentOrg, isSubOrganization } = useOrganization();
-
return (
<div className="flex h-full w-full justify-center bg-bunker-800 text-white">
<Helmet>
@@ -32,16 +28,7 @@ export const SettingsPage = () => {
title="Project Settings"
description="Configure general project settings"
>
- <Link
- to="/organizations/$orgId/settings"
- params={{
- orgId: currentOrg.id
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for {isSubOrganization ? "sub-" : ""}organization
- settings?
- </Link>
+ <LookingForOrgPageLink page="settings" />
</PageHeader>
<Tabs orientation="vertical" defaultValue={tabs[0].key}>
{tabs.map(({ key, Component }) => (
diff --git a/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx b/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
index 46a0ce1f01..ef76420ca6 100644
--- a/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
@@ -3,12 +3,17 @@ import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { Link, useNavigate, useSearch } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
+import { useNavigate, useSearch } from "@tanstack/react-router";
import { OrgPermissionGuardBanner } from "@app/components/permissions/OrgPermissionCan";
import { Button, PageHeader } from "@app/components/v2";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@app/components/v3";
+import {
+ LookingForOrgPageLink,
+ Tabs,
+ TabsContent,
+ TabsList,
+ TabsTrigger
+} from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import {
OrgPermissionActions,
@@ -109,17 +114,7 @@ export const AccessManagementPage = () => {
title={`${isSubOrganization ? "Sub-Organization" : "Organization"} Access Control`}
description={`Manage fine-grained access for users, groups, roles, and machine identities within your ${isSubOrganization ? "sub-" : ""}organization resources.`}
>
- {isSubOrganization && (
- <Link
- to="/organizations/$orgId/access-management"
- params={{
- orgId: currentOrg.rootOrgId ?? ""
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for root organization access control?
- </Link>
- )}
+ <LookingForOrgPageLink page="accessControl" target="root" />
</PageHeader>
{!currentOrg.shouldUseNewPrivilegeSystem && (
<div className="mt-4 mb-4 flex flex-col rounded-r border-l-2 border-l-primary bg-mineshaft-300/5 px-4 py-2.5">
diff --git a/frontend/src/pages/organization/AuditLogsPage/AuditLogsPage.tsx b/frontend/src/pages/organization/AuditLogsPage/AuditLogsPage.tsx
index c8f4a6daad..eacf18fb6f 100644
--- a/frontend/src/pages/organization/AuditLogsPage/AuditLogsPage.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/AuditLogsPage.tsx
@@ -1,9 +1,14 @@
import { Helmet } from "react-helmet";
-import { Link, useNavigate, useSearch } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
+import { useNavigate, useSearch } from "@tanstack/react-router";
import { PageHeader } from "@app/components/v2";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@app/components/v3";
+import {
+ LookingForOrgPageLink,
+ Tabs,
+ TabsContent,
+ TabsList,
+ TabsTrigger
+} from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import { useOrganization } from "@app/context";
@@ -55,17 +60,7 @@ export const AuditLogsPage = () => {
title={`${isSubOrganization ? "Sub-Organization" : "Organization"} Audit Logs`}
description="Audit logs for security and compliance teams to monitor information access."
>
- {isSubOrganization && (
- <Link
- to="/organizations/$orgId/audit-logs"
- params={{
- orgId: currentOrg.rootOrgId ?? ""
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for root organization audit logs?
- </Link>
- )}
+ <LookingForOrgPageLink page="auditLogs" target="root" />
</PageHeader>
<Tabs value={activeTab} onValueChange={updateSelectedTab}>
<TabsList variant={isSubOrganization ? "sub-org" : "org"}>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
index 5345dd6488..de29b6677e 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
@@ -4,7 +4,7 @@ import { Link, useSearch } from "@tanstack/react-router";
import { InfoIcon } from "lucide-react";
import { PageHeader, TabPanel, Tabs } from "@app/components/v2";
-import { Alert, AlertDescription, AlertTitle } from "@app/components/v3";
+import { Alert, AlertDescription, AlertTitle, LookingForOrgPageLink } from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import { useOrganization, useSubscription } from "@app/context";
@@ -97,17 +97,7 @@ export const OrgTabGroup = () => {
}
title={selectedTabName ?? settingsTitle}
>
- {isSubOrganization && (
- <Link
- to="/organizations/$orgId/settings"
- params={{
- orgId: currentOrg.rootOrgId ?? ""
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for root organization settings?
- </Link>
- )}
+ <LookingForOrgPageLink page="settings" target="root" />
</PageHeader>
{selectedTab === "tab-org-general" && (
<Alert variant="info" className="mb-6">
diff --git a/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx b/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
index 2bc014c414..33a057bd53 100644
--- a/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
+++ b/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
@@ -1,9 +1,15 @@
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
-import { Link, useNavigate, useSearch } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
+import { useNavigate, useSearch } from "@tanstack/react-router";
-import { PageHeader, Tabs, TabsContent, TabsList, TabsTrigger } from "@app/components/v3";
+import {
+ LookingForOrgPageLink,
+ PageHeader,
+ Tabs,
+ TabsContent,
+ TabsList,
+ TabsTrigger
+} from "@app/components/v3";
import { useOrganization, useProject } from "@app/context";
import { getProjectBaseURL } from "@app/helpers/project";
import { ProjectType } from "@app/hooks/api/projects/types";
@@ -19,7 +25,7 @@ import {
const Page = () => {
const navigate = useNavigate();
- const { currentOrg, isSubOrganization } = useOrganization();
+ const { currentOrg } = useOrganization();
const { currentProject } = useProject();
const selectedTab = useSearch({
strict: false,
@@ -69,16 +75,7 @@ const Page = () => {
: "Manage fine-grained access for users, groups, roles, and machine identities within your project resources."
}
>
- <Link
- to="/organizations/$orgId/access-management"
- params={{
- orgId: currentOrg.id
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for {isSubOrganization ? "sub-" : ""}organization access
- control?
- </Link>
+ <LookingForOrgPageLink page="accessControl" />
</PageHeader>
{hasTabs ? (
<Tabs value={selectedTab} onValueChange={updateSelectedTab}>
diff --git a/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx b/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx
index 5bdb155d90..3b8f1468f9 100644
--- a/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx
+++ b/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx
@@ -1,15 +1,13 @@
import { Helmet } from "react-helmet";
-import { Link } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
import { PageHeader } from "@app/components/v2";
-import { useOrganization, useProject } from "@app/context";
+import { LookingForOrgPageLink } from "@app/components/v3";
+import { useProject } from "@app/context";
import { ProjectType } from "@app/hooks/api/projects/types";
import { LogsSection } from "@app/pages/organization/AuditLogsPage/components";
export const AuditLogsPage = () => {
const { currentProject } = useProject();
- const { isSubOrganization } = useOrganization();
const isCertManager = currentProject.type === ProjectType.CertificateManager;
return (
<div className="mx-auto flex flex-col justify-between text-white">
@@ -24,16 +22,7 @@ export const AuditLogsPage = () => {
title={isCertManager ? "Audit logs" : "Project Audit logs"}
description="Audit logs for security and compliance teams to monitor information access."
>
- <Link
- to="/organizations/$orgId/audit-logs"
- params={{
- orgId: currentProject.orgId
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for {isSubOrganization ? "sub-" : ""}organization audit
- logs?
- </Link>
+ <LookingForOrgPageLink page="auditLogs" />
</PageHeader>
<LogsSection pageView project={currentProject} />
</div>
diff --git a/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx b/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx
index 172cdc8ca4..f3e86958cf 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx
@@ -1,11 +1,11 @@
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
-import { Link, useSearch } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
+import { useSearch } from "@tanstack/react-router";
import { PageHeader } from "@app/components/v2";
+import { LookingForOrgPageLink } from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
-import { useOrganization, useProject } from "@app/context";
+import { useProject } from "@app/context";
import { ProjectType, ProjectVersion } from "@app/hooks/api/projects/types";
import { ProjectGeneralTab } from "@app/pages/project/SettingsPage/components/ProjectGeneralTab";
@@ -18,7 +18,6 @@ import { WorkflowIntegrationTab } from "./components/WorkflowIntegrationSection"
export const SettingsPage = () => {
const { t } = useTranslation();
- const { isSubOrganization } = useOrganization();
const { currentProject } = useProject();
const { selectedTab } = useSearch({
@@ -93,16 +92,7 @@ export const SettingsPage = () => {
title={activeTab?.name ?? baseTitle}
description={activeTab?.description}
>
- <Link
- to="/organizations/$orgId/settings"
- params={{
- orgId: currentProject.orgId
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for {isSubOrganization ? "sub-" : ""}organization
- settings?
- </Link>
+ <LookingForOrgPageLink page="settings" />
</PageHeader>
<div className="grow rounded-br-md rounded-bl-md py-5 outline-hidden xl:overflow-x-hidden xl:py-0">
{ActiveTabComponent ? <ActiveTabComponent /> : null}
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentSection.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentSection.tsx
index a45e887ca1..944e87ce89 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentSection.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentSection.tsx
@@ -1,6 +1,6 @@
import { useState } from "react";
import { addDays, format } from "date-fns";
-import { ClockIcon, KeyIcon, PlusIcon, RotateCcwIcon, TriangleAlertIcon } from "lucide-react";
+import { PlusIcon, TriangleAlertIcon } from "lucide-react";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
@@ -11,6 +11,7 @@ import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
+ AlertDialogConfirmationField,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -22,8 +23,7 @@ import {
CardContent,
CardDescription,
CardHeader,
- CardTitle,
- Input
+ CardTitle
} from "@app/components/v3";
import {
ProjectPermissionActions,
@@ -32,7 +32,7 @@ import {
useProjectPermission,
useSubscription
} from "@app/context";
-import { useDeleteWsEnvironment } from "@app/hooks/api";
+import { useDeleteWsEnvironment, useRestoreEnvironment } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
import { AddEnvironmentModal } from "./AddEnvironmentModal";
@@ -45,11 +45,14 @@ export const EnvironmentSection = () => {
const { permission } = useProjectPermission();
const deleteWsEnvironment = useDeleteWsEnvironment();
- const [hardDeleteConfirmation, setHardDeleteConfirmation] = useState("");
+ const restoreEnvironment = useRestoreEnvironment();
const [isTableMutationPending, setIsTableMutationPending] = useState(false);
const [isDeleteSubmitting, setIsDeleteSubmitting] = useState(false);
+ const [isRestoreSubmitting, setIsRestoreSubmitting] = useState(false);
const isDeletePending = deleteWsEnvironment.isPending || isDeleteSubmitting;
+ const isRestorePending = restoreEnvironment.isPending || isRestoreSubmitting;
+ const isExternalMutationPending = isDeletePending || isRestorePending;
const isMoreEnvironmentsAllowed =
subscription?.environmentLimit && currentProject?.environments
@@ -60,6 +63,7 @@ export const EnvironmentSection = () => {
"createEnv",
"updateEnv",
"deleteEnv",
+ "restoreEnv",
"hardDeleteEnv",
"upgradePlan"
] as const);
@@ -72,6 +76,10 @@ export const EnvironmentSection = () => {
| { name: string; slug: string; id: string; deleteAfter?: string }
| undefined;
+ const restoreEnvData = popUp?.restoreEnv?.data as
+ | { name: string; slug: string; id: string }
+ | undefined;
+
const onEnvDeleteSubmit = async () => {
if (!currentProject?.id || !deleteEnvData?.id || isDeletePending) return;
@@ -100,6 +108,28 @@ export const EnvironmentSection = () => {
handlePopUpOpen("hardDeleteEnv", deleteEnvData);
};
+ const onEnvRestoreSubmit = async () => {
+ if (!currentProject?.id || !restoreEnvData?.id || isRestorePending) return;
+
+ setIsRestoreSubmitting(true);
+
+ try {
+ await restoreEnvironment.mutateAsync({
+ projectId: currentProject.id,
+ id: restoreEnvData.id
+ });
+
+ createNotification({
+ text: "Successfully restored environment",
+ type: "success"
+ });
+
+ handlePopUpClose("restoreEnv");
+ } finally {
+ setIsRestoreSubmitting(false);
+ }
+ };
+
const onEnvHardDeleteSubmit = async () => {
if (!currentProject?.id || !hardDeleteEnvData?.id || isDeletePending) return;
@@ -118,7 +148,6 @@ export const EnvironmentSection = () => {
});
handlePopUpClose("hardDeleteEnv");
- setHardDeleteConfirmation("");
} finally {
setIsDeleteSubmitting(false);
}
@@ -142,14 +171,14 @@ export const EnvironmentSection = () => {
variant="project"
size="sm"
onClick={() => {
- if (isDeletePending || isTableMutationPending) return;
+ if (isExternalMutationPending || isTableMutationPending) return;
if (isMoreEnvironmentsAllowed) {
handlePopUpOpen("createEnv");
} else {
handlePopUpOpen("upgradePlan");
}
}}
- isDisabled={!isAllowed || isDeletePending || isTableMutationPending}
+ isDisabled={!isAllowed || isExternalMutationPending || isTableMutationPending}
>
<PlusIcon className="size-4" />
Create Environment
@@ -162,7 +191,7 @@ export const EnvironmentSection = () => {
{permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.Environments) ? (
<EnvironmentTable
handlePopUpOpen={handlePopUpOpen}
- isDeletePending={isDeletePending}
+ isExternalMutationPending={isExternalMutationPending}
onMutationPendingChange={setIsTableMutationPending}
/>
) : (
@@ -199,30 +228,17 @@ export const EnvironmentSection = () => {
.
</AlertDialogDescription>
</AlertDialogHeader>
- <Card className="p-3 text-sm">
- <CardContent className="space-y-2">
- <div className="flex gap-2">
- <RotateCcwIcon className="mt-0.5 size-4 shrink-0 text-muted" />
- <p>
- <span className="font-medium text-foreground">
- Restore anytime within 14 days
- </span>{" "}
- <span className="opacity-80">secrets, folders, and history are preserved.</span>
- </p>
- </div>
- <div className="flex gap-2 opacity-80">
- <KeyIcon className="mt-0.5 size-4 shrink-0 text-muted" />
- <p>
- Service tokens and integrations referencing {deleteEnvData?.slug ?? ""} will fail
- to resolve. Fix or remove them before the grace period ends.
- </p>
- </div>
- <div className="flex gap-2 opacity-80">
- <ClockIcon className="mt-0.5 size-4 shrink-0 text-muted" />
- <p>After 14 days, all secret data is wiped and cannot be recovered.</p>
- </div>
- </CardContent>
- </Card>
+ <ul className="list-disc pl-4 text-sm text-label">
+ <li>Restore anytime within 14 days. Secrets, folders, and history are preserved.</li>
+ <li>After 14 days, all secret data is wiped and cannot be recovered.</li>
+ </ul>
+ <Alert variant="warning">
+ <TriangleAlertIcon />
+ <AlertDescription>
+ Service tokens and integrations referencing {deleteEnvData?.slug ?? ""} will fail to
+ resolve. Fix or remove them before the grace period ends.
+ </AlertDescription>
+ </Alert>
<AlertDialogFooter className="sm:justify-between">
<Button
variant="danger"
@@ -230,7 +246,7 @@ export const EnvironmentSection = () => {
onClick={onSwitchToHardDelete}
isDisabled={isDeletePending}
>
- Delete Permanently
+ Delete Now
</Button>
<div className="flex gap-2">
<AlertDialogCancel isDisabled={isDeletePending}>Cancel</AlertDialogCancel>
@@ -248,12 +264,41 @@ export const EnvironmentSection = () => {
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
+ <AlertDialog
+ open={popUp.restoreEnv.isOpen}
+ onOpenChange={(isOpen) => {
+ if (!isOpen && isRestorePending) return;
+ handlePopUpToggle("restoreEnv", isOpen);
+ }}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Restore {restoreEnvData?.name ?? "environment"}?</AlertDialogTitle>
+ <AlertDialogDescription>
+ The {restoreEnvData?.slug ?? ""} environment will become accessible again with its
+ secrets, folders, and history preserved. Service tokens and integrations referencing
+ it will begin resolving again.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel isDisabled={isRestorePending}>Cancel</AlertDialogCancel>
+ <Button
+ variant="project"
+ size="sm"
+ onClick={() => onEnvRestoreSubmit().catch(() => undefined)}
+ isPending={isRestorePending}
+ >
+ Restore Environment
+ </Button>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
<AlertDialog
open={popUp.hardDeleteEnv.isOpen}
+ confirmationValue={hardDeleteEnvData?.slug}
onOpenChange={(isOpen) => {
if (!isOpen && isDeletePending) return;
handlePopUpToggle("hardDeleteEnv", isOpen);
- if (!isOpen) setHardDeleteConfirmation("");
}}
>
<AlertDialogContent className="sm:max-w-xl!">
@@ -274,30 +319,22 @@ export const EnvironmentSection = () => {
restored from this UI.
</AlertDescription>
</Alert>
- <div className="w-full pt-2 pb-4">
- <p className="mb-2 text-sm text-muted">
- Type {hardDeleteEnvData?.slug ?? ""} to confirm.
- </p>
- <Input
- value={hardDeleteConfirmation}
- onChange={(e) => setHardDeleteConfirmation(e.target.value)}
- placeholder={hardDeleteEnvData?.slug ?? ""}
- disabled={isDeletePending}
- />
- </div>
+ <AlertDialogConfirmationField
+ inputProps={{ disabled: isDeletePending }}
+ onConfirm={() => onEnvHardDeleteSubmit().catch(() => undefined)}
+ />
<AlertDialogFooter>
<AlertDialogCancel isDisabled={isDeletePending}>Cancel</AlertDialogCancel>
- <Button
+ <AlertDialogAction
variant="danger"
- size="sm"
- onClick={onEnvHardDeleteSubmit}
+ onClick={(event) => {
+ event.preventDefault();
+ onEnvHardDeleteSubmit().catch(() => undefined);
+ }}
isPending={isDeletePending}
- isDisabled={
- !hardDeleteEnvData?.slug || hardDeleteConfirmation !== hardDeleteEnvData.slug
- }
>
- Delete Permanently
- </Button>
+ Delete Now
+ </AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentTable.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentTable.tsx
index 6e2f23a5ce..3b1462a243 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentTable.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/EnvironmentSection/EnvironmentTable.tsx
@@ -39,17 +39,17 @@ import {
useProject,
useSubscription
} from "@app/context";
-import { useRestoreEnvironment, useUpdateWsEnvironment } from "@app/hooks/api";
+import { useUpdateWsEnvironment } from "@app/hooks/api";
import { ProjectDeletedEnvActor } from "@app/hooks/api/projects/types";
import { UsePopUpState } from "@app/hooks/usePopUp";
-type PopUpKeys = "updateEnv" | "deleteEnv" | "hardDeleteEnv" | "upgradePlan";
+type PopUpKeys = "updateEnv" | "deleteEnv" | "restoreEnv" | "hardDeleteEnv" | "upgradePlan";
type EnvPayload = { name: string; slug: string; id: string; deleteAfter?: string };
type Props = {
handlePopUpOpen: (popUpName: keyof UsePopUpState<[PopUpKeys]>, env: EnvPayload) => void;
- isDeletePending: boolean;
+ isExternalMutationPending: boolean;
onMutationPendingChange: (isPending: boolean) => void;
};
@@ -81,34 +81,26 @@ const formatRemainingDuration = (target: Date): string | null => {
export const EnvironmentTable = ({
handlePopUpOpen,
- isDeletePending,
+ isExternalMutationPending,
onMutationPendingChange
}: Props) => {
const { currentProject } = useProject();
const { subscription } = useSubscription();
const updateEnvironment = useUpdateWsEnvironment();
- const restoreEnvironment = useRestoreEnvironment();
const [pendingAction, setPendingAction] = useState<
- | { type: "reorder"; id: string; direction: "up" | "down" }
- | { type: "restore"; id: string }
- | undefined
+ { id: string; direction: "up" | "down" } | undefined
>();
const activeEnvironments = currentProject.environments ?? [];
const deletedEnvironments = currentProject.deletedEnvironments ?? [];
const handleReorderEnv = async (id: string, position: number, direction: "up" | "down") => {
- if (
- !currentProject?.id ||
- isDeletePending ||
- updateEnvironment.isPending ||
- restoreEnvironment.isPending
- ) {
+ if (!currentProject?.id || isExternalMutationPending || updateEnvironment.isPending) {
return;
}
- setPendingAction({ type: "reorder", id, direction });
+ setPendingAction({ id, direction });
onMutationPendingChange(true);
try {
@@ -128,43 +120,7 @@ export const EnvironmentTable = ({
}
};
- const handleRestoreEnv = async (id: string) => {
- if (
- !currentProject?.id ||
- isDeletePending ||
- updateEnvironment.isPending ||
- restoreEnvironment.isPending
- ) {
- return;
- }
-
- setPendingAction({ type: "restore", id });
- onMutationPendingChange(true);
-
- try {
- await restoreEnvironment.mutateAsync({
- projectId: currentProject.id,
- id
- });
-
- createNotification({
- text: "Successfully restored environment",
- type: "success"
- });
- } catch (err) {
- const message = err instanceof Error ? err.message : "Failed to restore environment";
- createNotification({
- text: message,
- type: "error"
- });
- } finally {
- setPendingAction(undefined);
- onMutationPendingChange(false);
- }
- };
-
- const isMutationPending =
- isDeletePending || updateEnvironment.isPending || restoreEnvironment.isPending;
+ const isMutationPending = isExternalMutationPending || updateEnvironment.isPending;
const isMoreEnvironmentsAllowed =
subscription?.environmentLimit && activeEnvironments
@@ -215,11 +171,7 @@ export const EnvironmentTable = ({
onClick={() =>
handleReorderEnv(id, Math.min(activeEnvironments.length, pos + 2), "down")
}
- isPending={
- pendingAction?.type === "reorder" &&
- pendingAction.id === id &&
- pendingAction.direction === "down"
- }
+ isPending={pendingAction?.id === id && pendingAction.direction === "down"}
isDisabled={
pos === activeEnvironments.length - 1 || !isAllowed || isMutationPending
}
@@ -237,11 +189,7 @@ export const EnvironmentTable = ({
aria-label="Move up"
variant="ghost-muted"
onClick={() => handleReorderEnv(id, Math.max(1, pos), "up")}
- isPending={
- pendingAction?.type === "reorder" &&
- pendingAction.id === id &&
- pendingAction.direction === "up"
- }
+ isPending={pendingAction?.id === id && pendingAction.direction === "up"}
isDisabled={pos === 0 || !isAllowed || isMutationPending}
>
<ArrowUpIcon />
@@ -312,8 +260,8 @@ export const EnvironmentTable = ({
return (
<TableRow key={id} className="bg-warning/[0.025]">
- <TableCell className="text-muted line-through">{name}</TableCell>
- <TableCell className="text-muted">{slug}</TableCell>
+ <TableCell className="text-warning/80 line-through">{name}</TableCell>
+ <TableCell className="text-warning/80 line-through">{slug}</TableCell>
<TableCell>
<div className="flex items-center justify-end gap-2">
<Tooltip>
@@ -360,7 +308,9 @@ export const EnvironmentTable = ({
<DropdownMenuContent align="end">
<DropdownMenuItem
isDisabled={isMutationPending}
- onClick={() => handleRestoreEnv(id)}
+ onClick={() =>
+ handlePopUpOpen("restoreEnv", { name, slug, id, deleteAfter })
+ }
>
<RotateCcwIcon />
Restore environment
@@ -373,7 +323,7 @@ export const EnvironmentTable = ({
}
>
<Trash2Icon />
- Delete permanently
+ Delete Now
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/frontend/src/pages/secret-scanning/SettingsPage/SettingsPage.tsx b/frontend/src/pages/secret-scanning/SettingsPage/SettingsPage.tsx
index 2b1d9ad9b3..c9a8785258 100644
--- a/frontend/src/pages/secret-scanning/SettingsPage/SettingsPage.tsx
+++ b/frontend/src/pages/secret-scanning/SettingsPage/SettingsPage.tsx
@@ -1,11 +1,11 @@
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
-import { Link, useSearch } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
+import { useSearch } from "@tanstack/react-router";
import { ProjectPermissionCan } from "@app/components/permissions";
import { PageHeader } from "@app/components/v2";
-import { ProjectPermissionSub, useOrganization } from "@app/context";
+import { LookingForOrgPageLink } from "@app/components/v3";
+import { ProjectPermissionSub } from "@app/context";
import { ProjectPermissionSecretScanningConfigActions } from "@app/context/ProjectPermissionContext/types";
import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectGeneralTab } from "@app/pages/project/SettingsPage/components/ProjectGeneralTab";
@@ -14,7 +14,6 @@ import { ProjectScanningConfigTab } from "./components/ProjectScanningConfigTab"
export const SettingsPage = () => {
const { t } = useTranslation();
- const { currentOrg, isSubOrganization } = useOrganization();
const { selectedTab } = useSearch({
from: "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-scanning/$projectId/_secret-scanning-layout/settings"
});
@@ -32,16 +31,7 @@ export const SettingsPage = () => {
title="Project Settings"
description="Configure your Secret Scanning product's configurations."
>
- <Link
- to="/organizations/$orgId/settings"
- params={{
- orgId: currentOrg.id
- }}
- className="flex items-center gap-x-1.5 text-xs whitespace-nowrap text-neutral hover:underline"
- >
- <InfoIcon size={12} /> Looking for {isSubOrganization ? "sub-" : ""}organization
- settings?
- </Link>
+ <LookingForOrgPageLink page="settings" />
</PageHeader>
<div>
{activeTab === "general" && <ProjectGeneralTab />}