Skip to content

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

UI: add new banner for removing native integrations

adilsoneec11e1dc98d
diff --git a/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx b/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx
index 83f980850e..44868402ee 100644
--- a/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx
+++ b/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx
@@ -31,7 +31,7 @@ export const useOrgPermission = () => {
const hasOrgRole = useCallback(
(role: string) =>
memberships?.some((membership) => membership.roles.some((el) => role === el.role)),
- []
+ [memberships]
);
return { permission, memberships, hasOrgRole };
diff --git a/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx b/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx
index 865d31b81d..d8d5e4b7d9 100644
--- a/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx
+++ b/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx
@@ -45,7 +45,7 @@ export const useProjectPermission = () => {
const hasProjectRole = useCallback(
(role: string) =>
memberships?.some((membership) => membership.roles.some((el) => role === el.role)),
- []
+ [memberships]
);
return { permission, memberships, hasProjectRole, assumedPrivilegeDetails };
diff --git a/frontend/src/hooks/api/integrations/index.tsx b/frontend/src/hooks/api/integrations/index.tsx
index 9d43c33ad2..ff1c747693 100644
--- a/frontend/src/hooks/api/integrations/index.tsx
+++ b/frontend/src/hooks/api/integrations/index.tsx
@@ -2,5 +2,6 @@ export {
useCreateIntegration,
useDeleteIntegration,
useGetCloudIntegrations,
- useGetIntegration
+ useGetIntegration,
+ useGetNativeIntegrationDeprecationStatus
} from "./queries";
diff --git a/frontend/src/hooks/api/integrations/queries.tsx b/frontend/src/hooks/api/integrations/queries.tsx
index 69519a5a48..77e062076c 100644
--- a/frontend/src/hooks/api/integrations/queries.tsx
+++ b/frontend/src/hooks/api/integrations/queries.tsx
@@ -13,7 +13,8 @@ import {
export const integrationQueryKeys = {
getIntegrations: () => ["integrations"] as const,
- getIntegration: (id: string) => ["integration", id] as const
+ getIntegration: (id: string) => ["integration", id] as const,
+ getDeprecationStatus: (orgId: string) => ["integration-deprecation-status", orgId] as const
};
const fetchIntegrations = async () => {
@@ -32,12 +33,33 @@ const fetchIntegration = async (id: string) => {
return data.integration;
};
+const fetchDeprecationStatus = async () => {
+ const { data } = await apiRequest.get<{ hasNativeIntegrations: boolean }>(
+ "/api/v1/integration/deprecation-status"
+ );
+
+ return data;
+};
+
export const useGetCloudIntegrations = () =>
useQuery({
queryKey: integrationQueryKeys.getIntegrations(),
queryFn: () => fetchIntegrations()
});
+// Whether the org still has native integrations, which are deprecated. Org admins only — the endpoint
+// rejects everyone else, so callers must gate this on the caller's role. The response is scoped to the
+// org of the caller's token, hence orgId in the query key.
+export const useGetNativeIntegrationDeprecationStatus = (
+ orgId: string,
+ options?: { enabled?: boolean }
+) =>
+ useQuery({
+ queryKey: integrationQueryKeys.getDeprecationStatus(orgId),
+ queryFn: () => fetchDeprecationStatus(),
+ enabled: options?.enabled ?? true
+ });
+
export const useCreateIntegration = () => {
const queryClient = useQueryClient();
diff --git a/frontend/src/hooks/index.ts b/frontend/src/hooks/index.ts
index 8cd9cbba33..39477c1833 100644
--- a/frontend/src/hooks/index.ts
+++ b/frontend/src/hooks/index.ts
@@ -1,3 +1,4 @@
+export { useBannerDismissal } from "./useBannerDismissal";
export {
useCanUseOrgAppConnectionImport,
useCanUseProjectAppConnectionImport
diff --git a/frontend/src/hooks/useBannerDismissal.ts b/frontend/src/hooks/useBannerDismissal.ts
new file mode 100644
index 0000000000..97022eed04
--- /dev/null
+++ b/frontend/src/hooks/useBannerDismissal.ts
@@ -0,0 +1,28 @@
+import { useCallback, useState } from "react";
+
+const ONE_DAY_MS = 24 * 60 * 60 * 1000;
+
+const wasDismissedWithinLastDay = (storageKey: string): boolean => {
+ const dismissedAt = localStorage.getItem(storageKey);
+ if (!dismissedAt) return false;
+ const dismissedTime = parseInt(dismissedAt, 10);
+ return Date.now() - dismissedTime < ONE_DAY_MS;
+};
+
+/**
+ * Dismissal state for a banner, persisted for a day so it survives reloads and navigation but comes back
+ * afterwards. Same behaviour as the network health banner.
+ */
+export const useBannerDismissal = (storageKey: string): [boolean, () => void] => {
+ // localStorage is the source of truth and is read on every render, so a changing storageKey (e.g.
+ // switching project) is picked up without the consumer having to remount. The state only exists to
+ // re-render after a dismissal.
+ const [, setDismissCount] = useState(0);
+
+ const dismiss = useCallback(() => {
+ localStorage.setItem(storageKey, Date.now().toString());
+ setDismissCount((count) => count + 1);
+ }, [storageKey]);
+
+ return [wasDismissedWithinLastDay(storageKey), dismiss];
+};
diff --git a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx
index f29a29ca86..c4f5d2c2ab 100644
--- a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx
+++ b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx
@@ -10,6 +10,7 @@ import { useFetchServerStatus } from "@app/hooks/api";
import { AuditLogBanner } from "./components/AuditLogBanner";
import { InsecureConnectionBanner } from "./components/InsecureConnectionBanner";
+import { NativeIntegrationsBanner } from "./components/NativeIntegrationsBanner";
import { Navbar } from "./components/NavBar";
import { NetworkHealthBanner } from "./components/NetworkHealthBanner";
import { OrgSidebar } from "./components/OrgSidebar";
@@ -46,6 +47,7 @@ export const OrganizationLayout = () => {
{!isLoading && !isInsideProject && subscription.auditLogs && <AuditLogBanner />}
{!window.isSecureContext && !isInsideProject && <InsecureConnectionBanner />}
{!isLoading && !isInsideProject && <NetworkHealthBanner />}
+ {!isInsideProject && <NativeIntegrationsBanner />}
<div
className={twMerge(
"flex-1 overflow-x-hidden bg-bunker-800 dark:scheme-dark",
diff --git a/frontend/src/layouts/OrganizationLayout/components/NativeIntegrationsBanner/NativeIntegrationsBanner.tsx b/frontend/src/layouts/OrganizationLayout/components/NativeIntegrationsBanner/NativeIntegrationsBanner.tsx
new file mode 100644
index 0000000000..1e9a67d813
--- /dev/null
+++ b/frontend/src/layouts/OrganizationLayout/components/NativeIntegrationsBanner/NativeIntegrationsBanner.tsx
@@ -0,0 +1,55 @@
+import { faArrowUpRightFromSquare, faWarning, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { IconButton } from "@app/components/v2";
+import { useOrganization, useOrgPermission } from "@app/context";
+import { OrgMembershipRole } from "@app/helpers/roles";
+import { useBannerDismissal } from "@app/hooks";
+import { useGetNativeIntegrationDeprecationStatus } from "@app/hooks/api";
+
+const DISMISS_STORAGE_KEY = "native-integrations-banner-dismissed-at";
+const SECRET_SYNCS_DOCS_URL = "https://infisical.com/docs/integrations/secret-syncs/overview";
+
+export const NativeIntegrationsBanner = () => {
+ const { currentOrg } = useOrganization();
+ const [isDismissed, dismiss] = useBannerDismissal(DISMISS_STORAGE_KEY);
+ const { hasOrgRole } = useOrgPermission();
+ const isOrgAdmin = hasOrgRole(OrgMembershipRole.Admin);
+
+ const { data } = useGetNativeIntegrationDeprecationStatus(currentOrg.id, {
+ enabled: isOrgAdmin
+ });
+
+ if (isDismissed || !data?.hasNativeIntegrations) return null;
+
+ return (
+ <div className="flex w-full items-center border-b border-yellow/50 bg-yellow/30 px-4 py-2 text-sm text-yellow-200">
+ <FontAwesomeIcon icon={faWarning} className="mr-2.5 text-base text-yellow" />
+ You have projects with native integrations. Native integrations are being deprecated, recreate
+ them as Secret Syncs.
+ <a
+ href={SECRET_SYNCS_DOCS_URL}
+ rel="noopener noreferrer"
+ target="_blank"
+ className="group flex items-center"
+ >
+ <span className="cursor-pointer pl-1 underline underline-offset-2 duration-100 group-hover:text-mineshaft-100 group-hover:decoration-mineshaft-100">
+ Learn more
+ </span>
+ <FontAwesomeIcon
+ className="mt-[0.12rem] ml-1 group-hover:text-mineshaft-100"
+ icon={faArrowUpRightFromSquare}
+ size="xs"
+ />
+ </a>
+ <IconButton
+ className="ml-auto shrink-0 p-0 text-yellow-200"
+ ariaLabel="Dismiss banner"
+ variant="plain"
+ onClick={dismiss}
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ );
+};
diff --git a/frontend/src/layouts/OrganizationLayout/components/NativeIntegrationsBanner/index.ts b/frontend/src/layouts/OrganizationLayout/components/NativeIntegrationsBanner/index.ts
new file mode 100644
index 0000000000..7f0b98fe0e
--- /dev/null
+++ b/frontend/src/layouts/OrganizationLayout/components/NativeIntegrationsBanner/index.ts
@@ -0,0 +1 @@
+export * from "./NativeIntegrationsBanner";
diff --git a/frontend/src/layouts/ProjectLayout/components/NativeIntegrationsMigrationBanner/NativeIntegrationsMigrationBanner.tsx b/frontend/src/layouts/ProjectLayout/components/NativeIntegrationsMigrationBanner/NativeIntegrationsMigrationBanner.tsx
new file mode 100644
index 0000000000..3d8d4b5147
--- /dev/null
+++ b/frontend/src/layouts/ProjectLayout/components/NativeIntegrationsMigrationBanner/NativeIntegrationsMigrationBanner.tsx
@@ -0,0 +1,55 @@
+import { faWarning, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { Link } from "@tanstack/react-router";
+
+import { IconButton } from "@app/components/v2";
+import { ROUTE_PATHS } from "@app/const/routes";
+import { useOrganization, useProject, useProjectPermission } from "@app/context";
+import { useBannerDismissal } from "@app/hooks";
+import { useGetWorkspaceIntegrations } from "@app/hooks/api";
+import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
+import { IntegrationsListPageTabs } from "@app/types/integrations";
+
+export const NativeIntegrationsMigrationBanner = () => {
+ const { currentOrg } = useOrganization();
+ const { currentProject } = useProject();
+ const { hasProjectRole } = useProjectPermission();
+ const isProjectAdmin = hasProjectRole(ProjectMembershipRole.Admin);
+
+ // dismissal is per project — closing it here shouldn't hide it in a different project
+ const [isDismissed, dismiss] = useBannerDismissal(
+ `native-integrations-migration-banner-dismissed-at:${currentProject.id}`
+ );
+
+ const { data: integrations = [] } = useGetWorkspaceIntegrations(currentProject.id, {
+ enabled: isProjectAdmin && !isDismissed,
+ refetchInterval: false
+ });
+
+ if (isDismissed || !isProjectAdmin || integrations.length === 0) return null;
+
+ return (
+ <div className="flex w-full items-center border-b border-yellow/50 bg-yellow/30 px-4 py-2 text-sm text-yellow-200">
+ <FontAwesomeIcon icon={faWarning} className="mr-2.5 text-base text-yellow" />
+ This project has {integrations.length} native integration
+ {integrations.length > 1 ? "s" : ""}. Native integrations are deprecated, recreate them as
+ Secret Syncs.
+ <Link
+ to={ROUTE_PATHS.SecretManager.IntegrationsListPage.path}
+ params={{ orgId: currentOrg.id, projectId: currentProject.id }}
+ search={{ selectedTab: IntegrationsListPageTabs.SecretSyncs }}
+ className="cursor-pointer pl-1 underline underline-offset-2 duration-100 hover:text-mineshaft-100 hover:decoration-mineshaft-100"
+ >
+ Go to Secret Syncs
+ </Link>
+ <IconButton
+ className="ml-auto shrink-0 p-0 text-yellow-200"
+ ariaLabel="Dismiss banner"
+ variant="plain"
+ onClick={dismiss}
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </div>
+ );
+};
diff --git a/frontend/src/layouts/ProjectLayout/components/NativeIntegrationsMigrationBanner/index.ts b/frontend/src/layouts/ProjectLayout/components/NativeIntegrationsMigrationBanner/index.ts
new file mode 100644
index 0000000000..ecd46fe67b
--- /dev/null
+++ b/frontend/src/layouts/ProjectLayout/components/NativeIntegrationsMigrationBanner/index.ts
@@ -0,0 +1 @@
+export * from "./NativeIntegrationsMigrationBanner";
diff --git a/frontend/src/layouts/SecretManagerLayout/SecretManagerLayout.tsx b/frontend/src/layouts/SecretManagerLayout/SecretManagerLayout.tsx
index 411f518ab3..2428682b69 100644
--- a/frontend/src/layouts/SecretManagerLayout/SecretManagerLayout.tsx
+++ b/frontend/src/layouts/SecretManagerLayout/SecretManagerLayout.tsx
@@ -3,6 +3,7 @@ import { Outlet } from "@tanstack/react-router";
import { useProjectPermission } from "@app/context";
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
+import { NativeIntegrationsMigrationBanner } from "../ProjectLayout/components/NativeIntegrationsMigrationBanner";
export const SecretManagerLayout = () => {
const { assumedPrivilegeDetails } = useProjectPermission();
@@ -10,6 +11,7 @@ export const SecretManagerLayout = () => {
return (
<div className="flex h-full w-full flex-col overflow-x-hidden">
{assumedPrivilegeDetails && <AssumePrivilegeModeBanner />}
+ <NativeIntegrationsMigrationBanner />
<div className="flex-1 overflow-x-hidden overflow-y-auto bg-bunker-800 px-12 pt-10 pb-4">
<Outlet />
</div>