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 @@ -2,13 +2,27 @@ import { DatetimePopover } from "@/components/logs/datetime/datetime-popover";
import { cn } from "@/lib/utils";
import { Calendar } from "@unkey/icons";
import { Button } from "@unkey/ui";
import { useState } from "react";
import { useEffect, useState } from "react";
import { useFilters } from "../../../../hooks/use-filters";

const TITLE_EMPTY_DEFAULT = "Select Time Range";

export const DeploymentListDatetime = () => {
const [title, setTitle] = useState<string | null>("Last 12 hours");
const [title, setTitle] = useState<string | null>(TITLE_EMPTY_DEFAULT);
const { filters, updateFilters } = useFilters();

// If none of the filters are set anymore we should reset the title
// This can happen when the user manually clears a filter in the url
// or in the filter cloud
useEffect(() => {
for (const filter of filters) {
if (["startTime", "endTime", "since"].includes(filter.field)) {
return;
}
}
setTitle(TITLE_EMPTY_DEFAULT);
}, [filters]);

const timeValues = filters
.filter((f) => ["startTime", "endTime", "since"].includes(f.field))
.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,28 @@ type StatusOption = {
id: number;
status: GroupedDeploymentStatus;
display: string;
checked: boolean;
};

const baseOptions: StatusOption[] = [
{
id: 1,
status: "pending",
display: "Pending",
checked: false,
},
{
id: 2,
status: "building",
display: "Building",
checked: false,
status: "deploying",
display: "Deploying",
},
{
id: 3,
status: "completed",
status: "ready",
display: "Ready",
checked: false,
},
{
id: 4,
status: "failed",
display: "Failed",
checked: false,
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox";
import { collection } from "@/lib/collections";
import { useLiveQuery } from "@tanstack/react-db";
import { useFilters } from "../../../../../hooks/use-filters";

type EnvironmentOption = {
id: number;
environment: string;
checked: boolean;
};

const options: EnvironmentOption[] = [
{ id: 1, environment: "production", checked: false },
{ id: 2, environment: "preview", checked: false },
] as const;

export const EnvironmentFilter = () => {
const { filters, updateFilters } = useFilters();

const environments = useLiveQuery((q) => q.from({ environment: collection.environments }));

return (
<FilterCheckbox
options={options}
options={environments.data.map((environment, i) => ({
id: i,
slug: environment.slug,
}))}
Comment on lines 6 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Verify scope of environments.

Are environments workspace-wide or project-scoped? If workspace-wide, consider filtering by current project to avoid irrelevant options or slug collisions.

Also applies to: 18-25

🤖 Prompt for AI Agents
In
apps/dashboard/app/(app)/projects/[projectId]/deployments/components/controls/components/deployment-list-filters/components/environment-filter.tsx
around lines 6–16 (and similarly lines 18–25), verify whether environments are
workspace-wide or project-scoped; if environments are workspace-wide, change the
live query to filter environments by the current projectId (obtain projectId
from route params or parent props) so only relevant options are returned, and
ensure option identifiers avoid slug collisions by including a stable unique key
(e.g., environment ID or project-scoped composite) rather than relying solely on
index or slug.

filterField="environment"
checkPath="environment"
checkPath="slug"
selectionMode="single"
renderOptionContent={(checkbox) => (
<div className="text-accent-12 text-xs capitalize">{checkbox.environment}</div>
<div className="text-accent-12 text-xs capitalize">{checkbox.slug}</div>
)}
createFilterValue={(option) => ({
value: option.environment,
value: option.slug,
})}
filters={filters}
updateFilters={updateFilters}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useFilters } from "../../../../hooks/use-filters";
export const DeploymentListSearch = () => {
const { filters, updateFilters } = useFilters();

const queryLLMForStructuredOutput = trpc.deploy.project.deployment.search.useMutation({
const queryLLMForStructuredOutput = trpc.deployment.search.useMutation({
onSuccess(data) {
if (data?.filters.length === 0 || !data) {
toast.error(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import { type MenuItem, TableActionPopover } from "@/components/logs/table-action.popover";
import type { Deployment } from "@/lib/trpc/routers/deploy/project/deployment/list";
import type { Deployment } from "@/lib/collections";
import { PenWriting3 } from "@unkey/icons";
import type { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { useRouter } from "next/navigation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
import {
ArrowDotAntiClockwise,
CircleCheck,
CircleDotted,
CircleHalfDottedClock,
CircleWarning,
Cloud,
CloudUp,
HalfDottedCirclePlay,
Nut,
} from "@unkey/icons";
Expand All @@ -32,55 +29,31 @@ const statusConfigs: Record<DeploymentStatus, StatusConfig> = {
textColor: "text-grayA-11",
iconColor: "text-gray-11",
},
downloading_docker_image: {
icon: Cloud,
label: "Downloading",
bgColor: "bg-gradient-to-r from-infoA-5 to-transparent",
textColor: "text-infoA-11",
iconColor: "text-info-11",
animated: true,
},
building_rootfs: {
building: {
icon: Nut,
label: "Building",
bgColor: "bg-gradient-to-r from-infoA-5 to-transparent",
textColor: "text-infoA-11",
iconColor: "text-info-11",
animated: true,
},
uploading_rootfs: {
icon: CloudUp,
label: "Uploading",
bgColor: "bg-gradient-to-r from-infoA-5 to-transparent",
textColor: "text-infoA-11",
iconColor: "text-info-11",
animated: true,
},
creating_vm: {
icon: CircleDotted,
label: "Creating VM",
bgColor: "bg-gradient-to-r from-infoA-5 to-transparent",
textColor: "text-infoA-11",
iconColor: "text-info-11",
animated: true,
},
booting_vm: {
deploying: {
icon: HalfDottedCirclePlay,
label: "Booting",
label: "Deploying",
bgColor: "bg-gradient-to-r from-infoA-5 to-transparent",
textColor: "text-infoA-11",
iconColor: "text-info-11",
animated: true,
},
assigning_domains: {
network: {
icon: ArrowDotAntiClockwise,
label: "Assigning Domains",
bgColor: "bg-gradient-to-r from-infoA-5 to-transparent",
textColor: "text-infoA-11",
iconColor: "text-info-11",
animated: true,
},
completed: {
ready: {
icon: CircleCheck,
label: "Ready",
bgColor: "bg-successA-3",
Expand Down
Loading