|
1 | 1 | import { ArrowUturnLeftIcon, BookOpenIcon } from "@heroicons/react/20/solid"; |
2 | 2 | import { type MetaFunction, Outlet, useLocation, useNavigate, useParams } from "@remix-run/react"; |
3 | 3 | import { type LoaderFunctionArgs } from "@remix-run/server-runtime"; |
| 4 | +import { GitBranchIcon } from "lucide-react"; |
4 | 5 | import { useEffect } from "react"; |
5 | 6 | import { typedjson, useTypedLoaderData } from "remix-typedjson"; |
6 | 7 | import { z } from "zod"; |
7 | 8 | import { PromoteIcon } from "~/assets/icons/PromoteIcon"; |
8 | 9 | import { DeploymentsNone, DeploymentsNoneDev } from "~/components/BlankStatePanels"; |
| 10 | +import { OctoKitty } from "~/components/GitHubLoginButton"; |
9 | 11 | import { GitMetadata } from "~/components/GitMetadata"; |
10 | 12 | import { RuntimeIcon } from "~/components/RuntimeIcon"; |
11 | 13 | import { UserAvatar } from "~/components/UserProfilePhoto"; |
@@ -52,6 +54,7 @@ import { requireUserId } from "~/services/session.server"; |
52 | 54 | import { titleCase } from "~/utils"; |
53 | 55 | import { EnvironmentParamSchema, docsPath, v3DeploymentPath } from "~/utils/pathBuilder"; |
54 | 56 | import { createSearchParams } from "~/utils/searchParams"; |
| 57 | +import { BranchTrackingConfigSchema, getTrackedBranchForEnvironment } from "~/v3/github"; |
55 | 58 | import { compareDeploymentVersions } from "~/v3/utils/deploymentVersions"; |
56 | 59 |
|
57 | 60 | export const meta: MetaFunction = () => { |
@@ -122,8 +125,15 @@ export default function Page() { |
122 | 125 | const organization = useOrganization(); |
123 | 126 | const project = useProject(); |
124 | 127 | const environment = useEnvironment(); |
125 | | - const { deployments, currentPage, totalPages, selectedDeployment } = |
| 128 | + const { deployments, currentPage, totalPages, selectedDeployment, connectedGithubRepository } = |
126 | 129 | useTypedLoaderData<typeof loader>(); |
| 130 | + const branchTrackingOrError = |
| 131 | + connectedGithubRepository && |
| 132 | + BranchTrackingConfigSchema.safeParse(connectedGithubRepository.branchTracking); |
| 133 | + const environmentGitHubBranch = |
| 134 | + branchTrackingOrError && branchTrackingOrError.success |
| 135 | + ? getTrackedBranchForEnvironment(branchTrackingOrError.data, environment.type) |
| 136 | + : undefined; |
127 | 137 | const hasDeployments = totalPages > 0; |
128 | 138 |
|
129 | 139 | const { deploymentParam } = useParams(); |
@@ -286,11 +296,27 @@ export default function Page() { |
286 | 296 | )} |
287 | 297 | </TableBody> |
288 | 298 | </Table> |
289 | | - {totalPages > 1 && ( |
290 | | - <div className="-mt-px flex justify-end border-t border-grid-dimmed py-2 pr-2"> |
291 | | - <PaginationControls currentPage={currentPage} totalPages={totalPages} /> |
292 | | - </div> |
293 | | - )} |
| 299 | + <div className="-mt-px flex justify-between gap-2 border-t border-grid-dimmed px-2 py-2"> |
| 300 | + {connectedGithubRepository && environmentGitHubBranch && ( |
| 301 | + <div className="flex flex-nowrap items-center gap-2 whitespace-nowrap text-sm"> |
| 302 | + <OctoKitty className="size-4" /> |
| 303 | + Automatically triggered by pushes to{" "} |
| 304 | + <div className="flex max-w-32 items-center gap-1 truncate rounded bg-grid-dimmed px-1 font-mono"> |
| 305 | + <GitBranchIcon className="size-3 shrink-0" /> |
| 306 | + <span className="max-w-28 truncate">{environmentGitHubBranch}</span> |
| 307 | + </div>{" "} |
| 308 | + in |
| 309 | + <a |
| 310 | + href={connectedGithubRepository.repository.htmlUrl} |
| 311 | + target="_blank" |
| 312 | + className="max-w-52 truncate text-sm text-text-dimmed underline transition-colors hover:text-text-bright" |
| 313 | + > |
| 314 | + {connectedGithubRepository.repository.fullName} |
| 315 | + </a> |
| 316 | + </div> |
| 317 | + )} |
| 318 | + <PaginationControls currentPage={currentPage} totalPages={20} /> |
| 319 | + </div> |
294 | 320 | </div> |
295 | 321 | ) : environment.type === "DEVELOPMENT" ? ( |
296 | 322 | <MainCenteredContainer className="max-w-md"> |
|
0 commit comments