diff --git a/apps/webapp/app/presenters/IntegrationsPresenter.server.ts b/apps/webapp/app/presenters/IntegrationsPresenter.server.ts index bde5fbd1b..04a24c637 100644 --- a/apps/webapp/app/presenters/IntegrationsPresenter.server.ts +++ b/apps/webapp/app/presenters/IntegrationsPresenter.server.ts @@ -5,6 +5,7 @@ import { Organization, getOrganizationFromSlug, } from "~/models/organization.server"; +import { Project } from "~/models/project.server"; import { apiAuthenticationRepository } from "~/services/externalApis/apiAuthenticationRepository.server"; import { integrationCatalog } from "~/services/externalApis/integrationCatalog.server"; import { OAuthClientSchema } from "~/services/externalApis/types"; @@ -19,9 +20,11 @@ export class IntegrationsPresenter { public async call({ userId, + projectSlug, organizationSlug, }: { userId: User["id"]; + projectSlug: Project["slug"]; organizationSlug: Organization["slug"]; }) { const clients = await this.#prismaClient.apiConnectionClient.findMany({ @@ -43,7 +46,16 @@ export class IntegrationsPresenter { _count: { select: { connections: true, - jobIntegrations: true, + jobIntegrations: { + where: { + job: { + project: { + slug: projectSlug, + }, + internal: false, + }, + }, + }, }, }, }, diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx index ca725e260..1ea81d6b8 100644 --- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx +++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.integrations/route.tsx @@ -47,15 +47,22 @@ import { IntegrationsPresenter } from "~/presenters/IntegrationsPresenter.server import { requireUser } from "~/services/session.server"; import { formatDateTime } from "~/utils"; import { Handle } from "~/utils/handle"; -import { docsPath, integrationClientPath } from "~/utils/pathBuilder"; +import { + ProjectParamSchema, + docsPath, + integrationClientPath, +} from "~/utils/pathBuilder"; export const loader = async ({ request, params }: LoaderArgs) => { const user = await requireUser(request); - const { organizationSlug } = params; - invariant(organizationSlug, "organizationSlug not found"); + const { organizationSlug, projectParam } = ProjectParamSchema.parse(params); const presenter = new IntegrationsPresenter(); - const data = await presenter.call({ userId: user.id, organizationSlug }); + const data = await presenter.call({ + userId: user.id, + organizationSlug, + projectSlug: projectParam, + }); return typedjson(data); };