-
Notifications
You must be signed in to change notification settings - Fork 609
refactor: deploy UI issues and way we access data #4995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
be8985e
fix: deploy ui issues
ogzhanolguncu 0d1c9cc
fix: organize frequently used queries
ogzhanolguncu 76d5848
feat: move frequently used queries to provider
ogzhanolguncu 6dd3b09
fix: typo
ogzhanolguncu 9473f8e
fix: data access
ogzhanolguncu 1e2509d
Merge branch 'main' of github.com:unkeyed/unkey into deploy-ui-issues
ogzhanolguncu 0450a49
fix: lint issues and minors
ogzhanolguncu 3c875f5
fix: build issues
ogzhanolguncu b62f98f
Merge branch 'main' of github.com:unkeyed/unkey into deploy-ui-issues
ogzhanolguncu dfcc56a
Merge branch 'main' into deploy-ui-issues
ogzhanolguncu fd152f4
chore: use unkey/ui empty component
ogzhanolguncu 425b04d
fix: typo
ogzhanolguncu e1db159
Merge branch 'main' into deploy-ui-issues
ogzhanolguncu 40d345a
chore: move shimmer to tailwind
ogzhanolguncu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...rd/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/components/empty-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| "use client"; | ||
|
|
||
| import { cn } from "@/lib/utils"; | ||
| import { Link4 } from "@unkey/icons"; | ||
| import { Empty } from "@unkey/ui"; | ||
| import type { PropsWithChildren, ReactNode } from "react"; | ||
|
|
||
| type EmptySectionProps = PropsWithChildren<{ | ||
| title: string; | ||
| description: string; | ||
| icon?: ReactNode; | ||
| className?: string; | ||
| }>; | ||
|
|
||
| export const EmptySection = ({ | ||
| title, | ||
| description, | ||
| children, | ||
| icon = <Link4 className="size-6" />, | ||
| className, | ||
| }: EmptySectionProps) => ( | ||
| <Empty | ||
| className={cn( | ||
| "min-h-[150px] rounded-[14px] border border-dashed border-gray-4 bg-gray-1/50", | ||
| className, | ||
| )} | ||
| > | ||
| <Empty.Icon>{icon}</Empty.Icon> | ||
| <Empty.Title>{title}</Empty.Title> | ||
| <Empty.Description className="max-w-sm">{description}</Empty.Description> | ||
| {children && <Empty.Actions>{children}</Empty.Actions>} | ||
| </Empty> | ||
| ); |
127 changes: 127 additions & 0 deletions
127
...pps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/data-provider.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| "use client"; | ||
|
|
||
| import { collection } from "@/lib/collections"; | ||
| import type { Deployment } from "@/lib/collections/deploy/deployments"; | ||
| import type { Domain } from "@/lib/collections/deploy/domains"; | ||
| import type { Environment } from "@/lib/collections/deploy/environments"; | ||
| import type { Project } from "@/lib/collections/deploy/projects"; | ||
| import { eq, useLiveQuery } from "@tanstack/react-db"; | ||
| import { useParams } from "next/navigation"; | ||
| import { type PropsWithChildren, createContext, useContext, useMemo } from "react"; | ||
|
|
||
| type ProjectDataContextType = { | ||
| projectId: string; | ||
|
|
||
| project: Project | undefined; | ||
| isProjectLoading: boolean; | ||
|
|
||
| domains: Domain[]; | ||
| deployments: Deployment[]; | ||
| environments: Environment[]; | ||
|
|
||
| isDomainsLoading: boolean; | ||
| isDeploymentsLoading: boolean; | ||
| isEnvironmentsLoading: boolean; | ||
|
|
||
| getDomainsForDeployment: (deploymentId: string) => Domain[]; | ||
| getLiveDomains: () => Domain[]; | ||
| getEnvironmentOrLiveDomains: () => Domain[]; | ||
| getDeploymentById: (id: string) => Deployment | undefined; | ||
|
|
||
| refetchDomains: () => void; | ||
| refetchDeployments: () => void; | ||
| refetchAll: () => void; | ||
| }; | ||
|
|
||
| const ProjectDataContext = createContext<ProjectDataContextType | null>(null); | ||
|
|
||
| export const ProjectDataProvider = ({ children }: PropsWithChildren) => { | ||
| const params = useParams(); | ||
| const projectId = params?.projectId; | ||
|
|
||
| if (!projectId || typeof projectId !== "string") { | ||
| throw new Error("ProjectDataProvider must be used within a project route"); | ||
| } | ||
|
|
||
| const domainsQuery = useLiveQuery( | ||
| (q) => | ||
| q | ||
| .from({ domain: collection.domains }) | ||
| .where(({ domain }) => eq(domain.projectId, projectId)) | ||
| .orderBy(({ domain }) => domain.createdAt, "desc"), | ||
| [projectId], | ||
| ); | ||
|
|
||
| const deploymentsQuery = useLiveQuery( | ||
| (q) => | ||
| q | ||
| .from({ deployment: collection.deployments }) | ||
| .where(({ deployment }) => eq(deployment.projectId, projectId)) | ||
| .orderBy(({ deployment }) => deployment.createdAt, "desc"), | ||
| [projectId], | ||
| ); | ||
|
|
||
| const projectQuery = useLiveQuery( | ||
| (q) => | ||
| q.from({ project: collection.projects }).where(({ project }) => eq(project.id, projectId)), | ||
| [projectId], | ||
| ); | ||
|
|
||
| const environmentsQuery = useLiveQuery( | ||
| (q) => | ||
| q.from({ env: collection.environments }).where(({ env }) => eq(env.projectId, projectId)), | ||
| [projectId], | ||
| ); | ||
|
|
||
| const value = useMemo(() => { | ||
| const domains = domainsQuery.data ?? []; | ||
| const deployments = deploymentsQuery.data ?? []; | ||
| const environments = environmentsQuery.data ?? []; | ||
| const project = projectQuery.data?.at(0); | ||
|
|
||
| return { | ||
| projectId, | ||
|
|
||
| project, | ||
| isProjectLoading: projectQuery.isLoading, | ||
|
|
||
| domains, | ||
| isDomainsLoading: domainsQuery.isLoading, | ||
|
|
||
| deployments, | ||
| isDeploymentsLoading: deploymentsQuery.isLoading, | ||
|
|
||
| environments, | ||
| isEnvironmentsLoading: environmentsQuery.isLoading, | ||
|
|
||
| getDomainsForDeployment: (deploymentId: string) => | ||
| domains.filter((d) => d.deploymentId === deploymentId), | ||
|
|
||
| getLiveDomains: () => domains.filter((d) => d.sticky === "live"), | ||
|
|
||
| getEnvironmentOrLiveDomains: () => | ||
| domains.filter((d) => d.sticky === "environment" || d.sticky === "live"), | ||
|
|
||
| getDeploymentById: (id: string) => deployments.find((d) => d.id === id), | ||
|
|
||
| refetchDomains: () => collection.domains.utils.refetch(), | ||
| refetchDeployments: () => collection.deployments.utils.refetch(), | ||
| refetchAll: () => { | ||
| collection.projects.utils.refetch(); | ||
| collection.deployments.utils.refetch(); | ||
| collection.domains.utils.refetch(); | ||
| collection.environments.utils.refetch(); | ||
| }, | ||
| }; | ||
| }, [projectId, domainsQuery, deploymentsQuery, projectQuery, environmentsQuery]); | ||
|
|
||
| return <ProjectDataContext.Provider value={value}>{children}</ProjectDataContext.Provider>; | ||
| }; | ||
|
|
||
| export const useProjectData = () => { | ||
| const context = useContext(ProjectDataContext); | ||
| if (!context) { | ||
| throw new Error("useProjectData must be used within ProjectDataProvider"); | ||
| } | ||
| return context; | ||
| }; |
47 changes: 47 additions & 0 deletions
47
...]/(overview)/deployments/[deploymentId]/(overview)/components/scroll-to-bottom-button.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| "use client"; | ||
| import { ChevronDown } from "@unkey/icons"; | ||
| import { cn } from "@unkey/ui/src/lib/utils"; | ||
| import { useProjectData } from "../../../../data-provider"; | ||
| import { useDeployment } from "../../layout-provider"; | ||
|
|
||
| export function ScrollToBottomButton() { | ||
| const { deploymentId } = useDeployment(); | ||
| const { getDeploymentById } = useProjectData(); | ||
|
|
||
| const deployment = getDeploymentById(deploymentId); | ||
| const isVisible = deployment?.status !== "ready"; | ||
|
|
||
| const handleScrollToBottom = () => { | ||
| const container = document.getElementById("deployment-scroll-container"); | ||
| if (container) { | ||
| container.scrollTo({ | ||
| top: container.scrollHeight, | ||
| behavior: "smooth", | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <button | ||
| type="button" | ||
| onClick={handleScrollToBottom} | ||
| className={cn( | ||
| "fixed bottom-6 right-6 z-20", | ||
| "flex items-center gap-2 px-4 py-2.5 rounded-full", | ||
| "shadow-lg hover:shadow-xl hover:scale-105", | ||
| "border border-grayA-4", | ||
| "transition-all duration-300 ease-out", | ||
| "overflow-hidden", | ||
| "before:absolute before:inset-0 before:bg-gradient-to-r before:from-infoA-5 before:to-transparent before:-z-10", | ||
| "after:absolute after:inset-0 after:bg-gray-1 after:dark:bg-black after:-z-20", | ||
| isVisible ? "opacity-100 translate-y-0" : "opacity-0 translate-y-4 pointer-events-none", | ||
| )} | ||
| aria-label="Scroll to bottom of build logs" | ||
| > | ||
| {/* Shimmer animation overlay */} | ||
| <div className="absolute inset-0 bg-gradient-to-r from-transparent via-white/40 to-transparent w-[150%] animate-shimmer" /> | ||
| <span className="text-xs text-infoA-11 font-medium relative z-10">Building...</span> | ||
| <ChevronDown iconSize="sm-regular" className="text-info-11 relative z-10" /> | ||
| </button> | ||
| ); | ||
| } | ||
35 changes: 14 additions & 21 deletions
35
.../deployments/[deploymentId]/(overview)/components/sections/deployment-domains-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 7 additions & 15 deletions
22
...ew)/deployments/[deploymentId]/(overview)/components/sections/deployment-info-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 11 additions & 25 deletions
36
...ew)/deployments/[deploymentId]/(overview)/components/sections/deployment-logs-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@perkinsjr @chronark This is kinda experimental if we don't like it we can kill it. lemme know how you feel