mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 09:28:06 +00:00
fix: refine try/catch
This commit is contained in:
@@ -3,7 +3,12 @@ import { zodValidator } from "@tanstack/zod-adapter";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { workspaceKeys } from "@app/hooks/api";
|
import { workspaceKeys } from "@app/hooks/api";
|
||||||
import { fetchSecretSyncsByProjectId, secretSyncKeys } from "@app/hooks/api/secretSyncs";
|
import { TIntegration } from "@app/hooks/api/integrations/types";
|
||||||
|
import {
|
||||||
|
fetchSecretSyncsByProjectId,
|
||||||
|
secretSyncKeys,
|
||||||
|
TSecretSync
|
||||||
|
} from "@app/hooks/api/secretSyncs";
|
||||||
import { fetchWorkspaceIntegrations } from "@app/hooks/api/workspace/queries";
|
import { fetchWorkspaceIntegrations } from "@app/hooks/api/workspace/queries";
|
||||||
import { IntegrationsListPageTabs } from "@app/types/integrations";
|
import { IntegrationsListPageTabs } from "@app/types/integrations";
|
||||||
|
|
||||||
@@ -20,44 +25,13 @@ 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) {
|
||||||
|
let secretSyncs: TSecretSync[];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const secretSyncs = await context.queryClient.ensureQueryData({
|
secretSyncs = await context.queryClient.ensureQueryData({
|
||||||
queryKey: secretSyncKeys.list(projectId),
|
queryKey: secretSyncKeys.list(projectId),
|
||||||
queryFn: () => fetchSecretSyncsByProjectId(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 }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
throw redirect({
|
|
||||||
to: "/secret-manager/$projectId/integrations",
|
|
||||||
params: {
|
|
||||||
projectId
|
|
||||||
},
|
|
||||||
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
|
|
||||||
});
|
|
||||||
} catch {
|
} catch {
|
||||||
throw redirect({
|
throw redirect({
|
||||||
to: "/secret-manager/$projectId/integrations",
|
to: "/secret-manager/$projectId/integrations",
|
||||||
@@ -67,6 +41,50 @@ export const Route = createFileRoute(
|
|||||||
search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
|
search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (secretSyncs.length) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/secret-manager/$projectId/integrations",
|
||||||
|
params: {
|
||||||
|
projectId
|
||||||
|
},
|
||||||
|
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let integrations: TIntegration[];
|
||||||
|
try {
|
||||||
|
integrations = await context.queryClient.ensureQueryData({
|
||||||
|
queryKey: workspaceKeys.getWorkspaceIntegrations(projectId),
|
||||||
|
queryFn: () => fetchWorkspaceIntegrations(projectId)
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
throw redirect({
|
||||||
|
to: "/secret-manager/$projectId/integrations",
|
||||||
|
params: {
|
||||||
|
projectId
|
||||||
|
},
|
||||||
|
search: { selectedTab: IntegrationsListPageTabs.SecretSyncs }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (integrations.length) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/secret-manager/$projectId/integrations",
|
||||||
|
params: {
|
||||||
|
projectId
|
||||||
|
},
|
||||||
|
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