Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
UI: remove integrations tab for users that don't have it
adilson07174945c035
diff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/IntegrationsListPage.tsx b/frontend/src/pages/secret-manager/IntegrationsListPage/IntegrationsListPage.tsxindex 8956c69741..3a72221692 100644--- a/frontend/src/pages/secret-manager/IntegrationsListPage/IntegrationsListPage.tsx+++ b/frontend/src/pages/secret-manager/IntegrationsListPage/IntegrationsListPage.tsx@@ -12,6 +12,7 @@ import {useProject} from "@app/context";import { ProjectPermissionSecretSyncActions } from "@app/context/ProjectPermissionContext/types";+import { useGetWorkspaceIntegrations } from "@app/hooks/api";import { ProjectType } from "@app/hooks/api/projects/types";import { IntegrationsListPageTabs } from "@app/types/integrations";@@ -33,6 +34,16 @@ export const IntegrationsListPage = () => {from: ROUTE_PATHS.SecretManager.IntegrationsListPage.id});+ const { data: integrations = [] } = useGetWorkspaceIntegrations(currentProject.id, {+ refetchInterval: false+ });++ // Native integrations are deprecated: the tab is only offered to projects that already have one.+ // Keeping it mounted while the user is standing on it avoids an empty page when they delete their+ // last integration.+ const showNativeIntegrations =+ integrations.length > 0 || selectedTab === IntegrationsListPageTabs.NativeIntegrations;+const updateSelectedTab = (tab: string) => {navigate({to: "/organizations/$orgId/projects/secret-management/$projectId/integrations",@@ -70,9 +81,11 @@ export const IntegrationsListPage = () => {<Tab variant="project" value={IntegrationsListPageTabs.InfrastructureIntegrations}>Infrastructure Integrations</Tab>- <Tab variant="project" value={IntegrationsListPageTabs.NativeIntegrations}>- Native Integrations- </Tab>+ {showNativeIntegrations && (+ <Tab variant="project" value={IntegrationsListPageTabs.NativeIntegrations}>+ Native Integrations+ </Tab>+ )}</TabList><TabPanel value={IntegrationsListPageTabs.AppConnections}><AppConnectionsTab />@@ -83,15 +96,17 @@ export const IntegrationsListPage = () => {<TabPanel value={IntegrationsListPageTabs.InfrastructureIntegrations}><InfrastructureIntegrationTab /></TabPanel>- <TabPanel value={IntegrationsListPageTabs.NativeIntegrations}>- <ProjectPermissionCan- renderGuardBanner- I={ProjectPermissionActions.Read}- a={ProjectPermissionSub.Integrations}- >- <NativeIntegrationsTab />- </ProjectPermissionCan>- </TabPanel>+ {showNativeIntegrations && (+ <TabPanel value={IntegrationsListPageTabs.NativeIntegrations}>+ <ProjectPermissionCan+ renderGuardBanner+ I={ProjectPermissionActions.Read}+ a={ProjectPermissionSub.Integrations}+ >+ <NativeIntegrationsTab />+ </ProjectPermissionCan>+ </TabPanel>+ )}<TabPanel value={IntegrationsListPageTabs.SecretSyncs}><ProjectPermissionCanrenderGuardBannerdiff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx b/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsxindex 8c8c13ec50..17cf6c204f 100644--- a/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx+++ b/frontend/src/pages/secret-manager/IntegrationsListPage/route.tsx@@ -30,6 +30,19 @@ export const Route = createFileRoute(component: IntegrationsListPage,validateSearch: zodValidator(IntegrationsListPageQuerySchema),beforeLoad: async ({ context, search, params: { projectId, orgId } }) => {+ const redirectToTab = (selectedTab: IntegrationsListPageTabs) =>+ redirect({+ to: "/organizations/$orgId/projects/secret-management/$projectId/integrations",+ params: { orgId, projectId },+ search: { selectedTab }+ });++ const getIntegrations = () =>+ context.queryClient.ensureQueryData({+ queryKey: projectKeys.getProjectIntegrations(projectId),+ queryFn: () => fetchWorkspaceIntegrations(projectId)+ });+if (!search.selectedTab) {let secretSyncs: TSecretSync[];@@ -39,58 +52,41 @@ export const Route = createFileRoute(queryFn: () => fetchSecretSyncsByProjectId(projectId)});} catch {- throw redirect({- to: "/organizations/$orgId/projects/secret-management/$projectId/integrations",- params: { orgId, projectId },- search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }- });+ throw redirectToTab(IntegrationsListPageTabs.NativeIntegrations);}if (secretSyncs.length) {- throw redirect({- to: "/organizations/$orgId/projects/secret-management/$projectId/integrations",- params: { orgId, projectId },- search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }- });+ throw redirectToTab(IntegrationsListPageTabs.SecretSyncs);}let integrations: TIntegration[];try {- integrations = await context.queryClient.ensureQueryData({- queryKey: projectKeys.getProjectIntegrations(projectId),- queryFn: () => fetchWorkspaceIntegrations(projectId)- });+ integrations = await getIntegrations();} catch {- throw redirect({- to: "/organizations/$orgId/projects/secret-management/$projectId/integrations",- params: {- orgId,- projectId- },- search: { selectedTab: IntegrationsListPageTabs.AppConnections }- });+ throw redirectToTab(IntegrationsListPageTabs.AppConnections);}if (integrations.length) {- throw redirect({- to: "/organizations/$orgId/projects/secret-management/$projectId/integrations",- params: {- orgId,- projectId- },- search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }- });+ throw redirectToTab(IntegrationsListPageTabs.NativeIntegrations);}// Default to App Connections tab if no existing syncs or integrations- throw redirect({- to: "/organizations/$orgId/projects/secret-management/$projectId/integrations",- params: {- orgId,- projectId- },- search: { selectedTab: IntegrationsListPageTabs.AppConnections }- });+ throw redirectToTab(IntegrationsListPageTabs.AppConnections);+ }++ // Native integrations are deprecated: only projects that already have one can access the tab+ if (search.selectedTab === IntegrationsListPageTabs.NativeIntegrations) {+ let integrations: TIntegration[] = [];++ try {+ integrations = await getIntegrations();+ } catch {+ // fall through to the redirect below+ }++ if (!integrations.length) {+ throw redirectToTab(IntegrationsListPageTabs.AppConnections);+ }}return {