From ff58925606a4f68ff341218aa9524ed979054ddd Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Wed, 12 Jul 2023 15:44:13 +0100 Subject: [PATCH] The Project side menu now shows an error icon on Triggers and Integrations if action is required --- .../components/navigation/ProjectSideMenu.tsx | 16 +++++++++---- .../app/presenters/ProjectPresenter.server.ts | 24 +++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/apps/webapp/app/components/navigation/ProjectSideMenu.tsx b/apps/webapp/app/components/navigation/ProjectSideMenu.tsx index 1e0b3c0ad..e46fa3e7b 100644 --- a/apps/webapp/app/components/navigation/ProjectSideMenu.tsx +++ b/apps/webapp/app/components/navigation/ProjectSideMenu.tsx @@ -1,25 +1,23 @@ import { useMatches } from "@remix-run/react"; import { motion } from "framer-motion"; -import { useOptionalIntegrationClient } from "~/hooks/useIntegrationClient"; import { useOptionalJob } from "~/hooks/useJob"; import { useOrganization } from "~/hooks/useOrganizations"; import { useProject } from "~/hooks/useProject"; import { cn } from "~/utils/cn"; +import { Handle } from "~/utils/handle"; import { accountPath, organizationBillingPath, organizationTeamPath, projectEnvironmentsPath, projectIntegrationsPath, - projectTriggersPath, projectPath, + projectTriggersPath, } from "~/utils/pathBuilder"; import { UserProfilePhoto } from "../UserProfilePhoto"; import { NavLinkButton } from "../primitives/Buttons"; -import type { IconNames } from "../primitives/NamedIcon"; +import { NamedIcon, type IconNames } from "../primitives/NamedIcon"; import { SimpleTooltip } from "../primitives/Tooltip"; -import { usePathName } from "~/hooks/usePathName"; -import { Handle } from "~/utils/handle"; export function SideMenuContainer({ children }: { children: React.ReactNode }) { return ( @@ -82,6 +80,7 @@ export function ProjectSideMenu() { icon="integration" to={projectIntegrationsPath(organization, project)} isCollapsed={isCollapsed} + hasWarning={project.hasUnconfiguredIntegrations} data-action="integrations" /> ; name: string; to: string; isCollapsed: boolean; + hasWarning?: boolean; forceActive?: boolean; }) { return ( @@ -163,6 +165,7 @@ function SideMenuItem({ isActive = forceActive; } return cn( + "relative", isActive ? "bg-slate-800 text-bright group-hover:bg-slate-800" : "text-dimmed group-hover:bg-slate-850 group-hover:text-bright" @@ -177,6 +180,9 @@ function SideMenuItem({ > {name} + {hasWarning && ( + + )} } content={name} diff --git a/apps/webapp/app/presenters/ProjectPresenter.server.ts b/apps/webapp/app/presenters/ProjectPresenter.server.ts index 851898525..41cbf98ca 100644 --- a/apps/webapp/app/presenters/ProjectPresenter.server.ts +++ b/apps/webapp/app/presenters/ProjectPresenter.server.ts @@ -90,6 +90,28 @@ export class ProjectPresenter { }, orderBy: [{ title: "asc" }], }, + _count: { + select: { + sources: { + where: { + active: false, + }, + }, + }, + }, + organization: { + select: { + _count: { + select: { + integrations: { + where: { + setupStatus: "MISSING_FIELDS", + }, + }, + }, + }, + }, + }, environments: { select: { id: true, @@ -207,6 +229,8 @@ export class ProjectPresenter { }; }) .filter(Boolean), + hasInactiveExternalTriggers: project._count.sources > 0, + hasUnconfiguredIntegrations: project.organization._count.integrations > 0, environments: project.environments.map((environment) => ({ id: environment.id, slug: environment.slug,