Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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";
import { type PropsWithChildren, createContext, useContext, useEffect, useMemo } from "react";

type ProjectDataContextType = {
projectId: string;
Expand Down Expand Up @@ -43,15 +43,6 @@ export const ProjectDataProvider = ({ children }: PropsWithChildren) => {
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
Expand All @@ -67,6 +58,22 @@ export const ProjectDataProvider = ({ children }: PropsWithChildren) => {
[projectId],
);

const project = projectQuery.data?.at(0);
const domainsQuery = useLiveQuery(
(q) =>
q
.from({ domain: collection.domains })
.where(({ domain }) => eq(domain.projectId, projectId))
.orderBy(({ domain }) => domain.createdAt, "desc"),
[projectId],
);
// refetch domains when live deployment changes
useEffect(() => {
if (project?.liveDeploymentId) {
collection.domains.utils.refetch();
}
}, [project?.liveDeploymentId]);

const environmentsQuery = useLiveQuery(
(q) =>
q.from({ env: collection.environments }).where(({ env }) => eq(env.projectId, projectId)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ export const DeploymentsList = () => {
deployment: Deployment;
environment?: Environment;
}) => {
const liveDeployment = getDeploymentById(deployment.id);
const liveDeployment = project?.liveDeploymentId
? getDeploymentById(project?.liveDeploymentId)
: undefined;
return (
<div className="pl-5">
<DeploymentListTableActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function CustomDomainRow({ domain, onDelete, onRetry }: CustomDomainRowPr
variant="outline"
disabled={isLoading}
onClick={() => setIsConfirmOpen(true)}
className="size-7 text-gray-9 hover:text-error-9 opacity-0 group-hover:opacity-100 transition-opacity"
className="size-7 text-gray-9 hover:text-error-9"
>
<Trash className="!size-[14px]" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export function AddEnvVars({
className="h-[32px] w-[32px] text-gray-9 hover:text-gray-11 hover:bg-gray-3 shrink-0"
>
<Trash className="size-4" iconSize="md-medium" />
</Button>{" "}
</Button>
</div>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,37 @@ export function EnvironmentVariablesSection({
{title} {envVars.length > 0 && `(${envVars.length})`}
</div>
</div>
<Button
size="icon"
variant="ghost"
onClick={toggleExpanded}
className="size-7 bg-gray-3 hover:bg-gray-4 mb-0.5"
>
<ChevronDown
iconSize="sm-regular"
className={cn(
"text-accent-12 !size-3 transition-transform duration-200",
isExpanded && "rotate-180",
)}
/>
</Button>
<div className="flex items-center gap-1.5">
{!isAddingNew && (
<Button
size="icon"
variant="ghost"
onClick={() => {
if (!isExpanded) {
setIsExpanded(true);
}
startAdding();
}}
className="size-7 bg-gray-3 hover:bg-gray-4 mb-0.5"
>
<Plus iconSize="sm-regular" className="text-accent-12 !size-3" />
</Button>
)}
<Button
size="icon"
variant="ghost"
onClick={toggleExpanded}
className="size-7 bg-gray-3 hover:bg-gray-4 mb-0.5"
>
<ChevronDown
iconSize="sm-regular"
className={cn(
"text-accent-12 !size-3 transition-transform duration-200",
isExpanded && "rotate-180",
)}
/>
</Button>
</div>
</div>

{/* Expandable Content */}
Expand Down