mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 21:27:31 +00:00
fix (temp): wrap integrations before load in try/catch, fix render banner guard
This commit is contained in:
@@ -57,6 +57,10 @@ export const ProjectPermissionCan: FunctionComponent<Props<ProjectPermissionSet>
|
|||||||
const finalChild =
|
const finalChild =
|
||||||
typeof children === "function" ? children(isAllowed, ability as any) : children;
|
typeof children === "function" ? children(isAllowed, ability as any) : children;
|
||||||
|
|
||||||
|
if (!isAllowed && renderGuardBanner) {
|
||||||
|
return <ProjectPermissionGuardBanner />;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isAllowed && passThrough) {
|
if (!isAllowed && passThrough) {
|
||||||
return <Tooltip content={label}>{finalChild}</Tooltip>;
|
return <Tooltip content={label}>{finalChild}</Tooltip>;
|
||||||
}
|
}
|
||||||
@@ -65,10 +69,6 @@ export const ProjectPermissionCan: FunctionComponent<Props<ProjectPermissionSet>
|
|||||||
return <Tooltip content={allowedLabel}>{finalChild}</Tooltip>;
|
return <Tooltip content={allowedLabel}>{finalChild}</Tooltip>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAllowed && renderGuardBanner) {
|
|
||||||
return <ProjectPermissionGuardBanner />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAllowed) return null;
|
if (!isAllowed) return null;
|
||||||
|
|
||||||
return finalChild;
|
return finalChild;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ProjectPermissionCan } from "@app/components/permissions";
|
|||||||
import { Badge, PageHeader, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
import { Badge, PageHeader, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
||||||
import { ROUTE_PATHS } from "@app/const/routes";
|
import { ROUTE_PATHS } from "@app/const/routes";
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||||
|
import { ProjectPermissionSecretSyncActions } from "@app/context/ProjectPermissionContext/types";
|
||||||
import { IntegrationsListPageTabs } from "@app/types/integrations";
|
import { IntegrationsListPageTabs } from "@app/types/integrations";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -100,8 +101,7 @@ export const IntegrationsListPage = () => {
|
|||||||
<TabPanel value={IntegrationsListPageTabs.SecretSyncs}>
|
<TabPanel value={IntegrationsListPageTabs.SecretSyncs}>
|
||||||
<ProjectPermissionCan
|
<ProjectPermissionCan
|
||||||
renderGuardBanner
|
renderGuardBanner
|
||||||
passThrough={false}
|
I={ProjectPermissionSecretSyncActions.Read}
|
||||||
I={ProjectPermissionActions.Read}
|
|
||||||
a={ProjectPermissionSub.SecretSyncs}
|
a={ProjectPermissionSub.SecretSyncs}
|
||||||
>
|
>
|
||||||
<SecretSyncsTab />
|
<SecretSyncsTab />
|
||||||
@@ -110,7 +110,6 @@ export const IntegrationsListPage = () => {
|
|||||||
<TabPanel value={IntegrationsListPageTabs.NativeIntegrations}>
|
<TabPanel value={IntegrationsListPageTabs.NativeIntegrations}>
|
||||||
<ProjectPermissionCan
|
<ProjectPermissionCan
|
||||||
renderGuardBanner
|
renderGuardBanner
|
||||||
passThrough={false}
|
|
||||||
I={ProjectPermissionActions.Read}
|
I={ProjectPermissionActions.Read}
|
||||||
a={ProjectPermissionSub.Integrations}
|
a={ProjectPermissionSub.Integrations}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -20,12 +20,37 @@ export const Route = createFileRoute(
|
|||||||
validateSearch: zodValidator(IntegrationsListPageQuerySchema),
|
validateSearch: zodValidator(IntegrationsListPageQuerySchema),
|
||||||
beforeLoad: async ({ context, search, params: { projectId } }) => {
|
beforeLoad: async ({ context, search, params: { projectId } }) => {
|
||||||
if (!search.selectedTab) {
|
if (!search.selectedTab) {
|
||||||
const secretSyncs = await context.queryClient.ensureQueryData({
|
try {
|
||||||
queryKey: secretSyncKeys.list(projectId),
|
const secretSyncs = await context.queryClient.ensureQueryData({
|
||||||
queryFn: () => fetchSecretSyncsByProjectId(projectId)
|
queryKey: secretSyncKeys.list(projectId),
|
||||||
});
|
queryFn: () => fetchSecretSyncsByProjectId(projectId)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (secretSyncs.length) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/secret-manager/$projectId/integrations",
|
||||||
|
params: {
|
||||||
|
projectId
|
||||||
|
},
|
||||||
|
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const integrations = await context.queryClient.ensureQueryData({
|
||||||
|
queryKey: workspaceKeys.getWorkspaceIntegrations(projectId),
|
||||||
|
queryFn: () => fetchWorkspaceIntegrations(projectId)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (integrations.length) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/secret-manager/$projectId/integrations",
|
||||||
|
params: {
|
||||||
|
projectId
|
||||||
|
},
|
||||||
|
search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (secretSyncs.length) {
|
|
||||||
throw redirect({
|
throw redirect({
|
||||||
to: "/secret-manager/$projectId/integrations",
|
to: "/secret-manager/$projectId/integrations",
|
||||||
params: {
|
params: {
|
||||||
@@ -33,14 +58,7 @@ export const Route = createFileRoute(
|
|||||||
},
|
},
|
||||||
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
|
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
|
||||||
});
|
});
|
||||||
}
|
} catch {
|
||||||
|
|
||||||
const integrations = await context.queryClient.ensureQueryData({
|
|
||||||
queryKey: workspaceKeys.getWorkspaceIntegrations(projectId),
|
|
||||||
queryFn: () => fetchWorkspaceIntegrations(projectId)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (integrations.length) {
|
|
||||||
throw redirect({
|
throw redirect({
|
||||||
to: "/secret-manager/$projectId/integrations",
|
to: "/secret-manager/$projectId/integrations",
|
||||||
params: {
|
params: {
|
||||||
@@ -49,14 +67,6 @@ export const Route = createFileRoute(
|
|||||||
search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
|
search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
throw redirect({
|
|
||||||
to: "/secret-manager/$projectId/integrations",
|
|
||||||
params: {
|
|
||||||
projectId
|
|
||||||
},
|
|
||||||
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user