From 1284ade8f349ae42ebe775ef40c9f895fc781d2b Mon Sep 17 00:00:00 2001 From: Aditya Choudhari Date: Wed, 12 Mar 2025 10:07:24 -0700 Subject: [PATCH 1/3] fix: Consolidate cell styles --- .../DeploymentPageContent.tsx | 28 ++--- .../release-cell/ReleaseEnvironmentCell.tsx | 106 +++++++++++++----- .../[deploymentSlug]/(sidebar)/page.tsx | 2 +- 3 files changed, 91 insertions(+), 45 deletions(-) rename apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/{_components/release-cell => }/DeploymentPageContent.tsx (93%) diff --git a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentPageContent.tsx b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx similarity index 93% rename from apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentPageContent.tsx rename to apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx index ff772a13f..28a09cb91 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentPageContent.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx @@ -46,9 +46,9 @@ import { useReleaseFilter } from "~/app/[workspaceSlug]/(appv2)/_components/rele import { DeploymentDirectoryCell } from "~/app/[workspaceSlug]/(appv2)/(deploy)/_components/deployments/DeploymentDirectoryCell"; import { urls } from "~/app/urls"; import { api } from "~/trpc/react"; -import { JobHistoryPopover } from "./JobHistoryPopover"; -import { ReleaseDistributionGraphPopover } from "./ReleaseDistributionPopover"; -import { LazyReleaseEnvironmentCell } from "./ReleaseEnvironmentCell"; +import { JobHistoryPopover } from "./_components/release-cell/JobHistoryPopover"; +import { ReleaseDistributionGraphPopover } from "./_components/release-cell/ReleaseDistributionPopover"; +import { LazyReleaseEnvironmentCell } from "./_components/release-cell/ReleaseEnvironmentCell"; type Deployment = NonNullable; @@ -312,7 +312,7 @@ export const DeploymentPageContent: React.FC = ({ router.push(releaseUrl(release.id).baseUrl()) } > - + @@ -341,7 +341,7 @@ export const DeploymentPageContent: React.FC = ({ {environments.map((env) => ( e.stopPropagation()} key={env.id} > @@ -355,15 +355,17 @@ export const DeploymentPageContent: React.FC = ({ {directories.map((dir) => ( - +
+ +
))} diff --git a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx index 7dba341cf..63cc82749 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ReleaseEnvironmentCell.tsx @@ -4,10 +4,12 @@ import type * as SCHEMA from "@ctrlplane/db/schema"; import type { ReleaseStatusType } from "@ctrlplane/validators/releases"; import type { ResourceCondition } from "@ctrlplane/validators/resources"; import { useParams } from "next/navigation"; +import { IconAlertCircle } from "@tabler/icons-react"; import { useInView } from "react-intersection-observer"; import { isPresent } from "ts-is-present"; import { Button } from "@ctrlplane/ui/button"; +import { Skeleton } from "@ctrlplane/ui/skeleton"; import { ComparisonOperator, FilterType, @@ -17,6 +19,7 @@ import { ReleaseStatus } from "@ctrlplane/validators/releases"; import { useReleaseChannelDrawer } from "~/app/[workspaceSlug]/(app)/_components/release-channel-drawer/useReleaseChannelDrawer"; import { ApprovalDialog } from "~/app/[workspaceSlug]/(appv2)/(deploy)/_components/release/ApprovalDialog"; +import { ReleaseDropdownMenu } from "~/app/[workspaceSlug]/(appv2)/(deploy)/_components/release/ReleaseDropdownMenu"; import { api } from "~/trpc/react"; import { DeployButton } from "./DeployButton"; import { Release } from "./TableCells"; @@ -24,6 +27,7 @@ import { Release } from "./TableCells"; type Release = { id: string; version: string; + name: string; createdAt: Date; status: ReleaseStatusType; deploymentId: string; @@ -35,15 +39,11 @@ type ReleaseEnvironmentCellProps = { release: Release; }; -const ReleaseEnvironmentCell: React.FC = ({ - environment, - deployment, - release, -}) => { - const { workspaceSlug, systemSlug } = useParams<{ - workspaceSlug: string; - systemSlug: string; - }>(); +const useGetResourceCount = ( + environment: SCHEMA.Environment, + deployment: SCHEMA.Deployment, +) => { + const { workspaceSlug } = useParams<{ workspaceSlug: string }>(); const { data: workspace, isLoading: isWorkspaceLoading } = api.workspace.bySlug.useQuery(workspaceSlug); @@ -66,6 +66,27 @@ const ReleaseEnvironmentCell: React.FC = ({ { enabled: workspace != null && filter != null }, ); + return { + resourceCount: resources?.total ?? 0, + isResourceCountLoading: isResourcesLoading || isWorkspaceLoading, + }; +}; + +const ReleaseEnvironmentCell: React.FC = ({ + environment, + deployment, + release, +}) => { + const { workspaceSlug, systemSlug } = useParams<{ + workspaceSlug: string; + systemSlug: string; + }>(); + + const { resourceCount, isResourceCountLoading } = useGetResourceCount( + environment, + deployment, + ); + const { data: blockedEnvsResult, isLoading: isBlockedEnvsLoading } = api.release.blocked.useQuery([release.id]); @@ -91,13 +112,20 @@ const ReleaseEnvironmentCell: React.FC = ({ isStatusesLoading || isBlockedEnvsLoading || isApprovalLoading || - isWorkspaceLoading || - isResourcesLoading; + isResourceCountLoading; if (isLoading) - return

Loading...

; + return ( +
+ +
+ + +
+
+ ); - if ((resources?.total ?? 0) === 0) + if (resourceCount === 0) return (
No resources @@ -120,17 +148,19 @@ const ReleaseEnvironmentCell: React.FC = ({ if (showRelease) return ( - s.job.status)} - /> +
+ s.job.status)} + /> +
); if (release.status === ReleaseStatus.Building) @@ -176,13 +206,27 @@ const ReleaseEnvironmentCell: React.FC = ({ release={release} environmentId={environment.id} > - +
+
+
+ +
+
+
+ {release.version} +
+
+ Approval required +
+
+
+ + +
); diff --git a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx index 7eb104018..667d699c3 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/page.tsx @@ -4,7 +4,7 @@ import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { api } from "~/trpc/server"; -import { DeploymentPageContent } from "./_components/release-cell/DeploymentPageContent"; +import { DeploymentPageContent } from "./DeploymentPageContent"; type PageProps = { params: Promise<{ From bed9d636c413461a7a2df1d807158188d045a0fe Mon Sep 17 00:00:00 2001 From: Aditya Choudhari Date: Wed, 12 Mar 2025 10:14:10 -0700 Subject: [PATCH 2/3] linting --- apps/webservice/tsconfig.json | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/webservice/tsconfig.json b/apps/webservice/tsconfig.json index 8ca8c26c7..7fc3f46b4 100644 --- a/apps/webservice/tsconfig.json +++ b/apps/webservice/tsconfig.json @@ -1,17 +1,34 @@ { "extends": "@ctrlplane/tsconfig/base.json", "compilerOptions": { - "lib": ["es2022", "dom", "dom.iterable"], + "lib": [ + "es2022", + "dom", + "dom.iterable" + ], "jsx": "preserve", "baseUrl": ".", "paths": { - "~/*": ["./src/*"] + "~/*": [ + "./src/*" + ] }, - "plugins": [{ "name": "next" }], + "plugins": [ + { + "name": "next" + } + ], "tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json", "module": "esnext" // "skipLibCheck": true }, - "include": ["next-env.d.ts", "src/**/*.ts", "src/**/*.tsx"], - "exclude": ["node_modules"] + "include": [ + "next-env.d.ts", + "src/**/*.ts", + "src/**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] } From b8f96db1e0c95bd8f9e5cc55eceb08ce2b729546 Mon Sep 17 00:00:00 2001 From: Aditya Choudhari Date: Wed, 12 Mar 2025 10:31:22 -0700 Subject: [PATCH 3/3] format --- apps/webservice/tsconfig.json | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/webservice/tsconfig.json b/apps/webservice/tsconfig.json index 7fc3f46b4..d1ffb7206 100644 --- a/apps/webservice/tsconfig.json +++ b/apps/webservice/tsconfig.json @@ -1,17 +1,11 @@ { "extends": "@ctrlplane/tsconfig/base.json", "compilerOptions": { - "lib": [ - "es2022", - "dom", - "dom.iterable" - ], + "lib": ["es2022", "dom", "dom.iterable"], "jsx": "preserve", "baseUrl": ".", "paths": { - "~/*": [ - "./src/*" - ] + "~/*": ["./src/*"] }, "plugins": [ { @@ -28,7 +22,5 @@ "src/**/*.tsx", ".next/types/**/*.ts" ], - "exclude": [ - "node_modules" - ] + "exclude": ["node_modules"] }