-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hub): actors and builds filters
- Loading branch information
Showing
24 changed files
with
520 additions
and
164 deletions.
There are no files selected for viewing
This file contains 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
Submodule cloudflare-rs
added at
f14720
Submodule deno
added at
bd9856
Submodule nomad-client
added at
abb66b
Submodule posthog-rs
added at
ef4e80
Submodule redis-rs
added at
ac3e27
Submodule rivet-term
added at
d539a0
Submodule serde_array_query
added at
b9f8bf
Submodule sqlx
added at
e7120f
90 changes: 90 additions & 0 deletions
90
frontend/apps/hub/src/domains/project/components/actors/actors-filters-sheet.tsx
This file contains 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,90 @@ | ||
import * as ActorsFiltersForm from "@/domains/project/forms/actors-filters-form"; | ||
import { | ||
Sheet, | ||
SheetContent, | ||
SheetDescription, | ||
SheetHeader, | ||
SheetTitle, | ||
SheetTrigger, | ||
Skeleton, | ||
} from "@rivet-gg/components"; | ||
import { type ReactNode, Suspense } from "react"; | ||
|
||
interface ActorsFiltersSheetProps { | ||
title: string; | ||
children?: ReactNode; | ||
projectId: string; | ||
environmentId: string; | ||
onFiltersSubmitted: (values: ActorsFiltersForm.FormValues) => void; | ||
tags: Record<string, string>; | ||
showDestroyed: boolean; | ||
} | ||
|
||
export function ActorsFiltersSheet({ | ||
title, | ||
children, | ||
projectId, | ||
environmentId, | ||
tags, | ||
showDestroyed, | ||
onFiltersSubmitted, | ||
}: ActorsFiltersSheetProps) { | ||
return ( | ||
<Sheet> | ||
<SheetTrigger asChild>{children}</SheetTrigger> | ||
<SheetContent> | ||
<SheetHeader> | ||
<SheetTitle>{title}</SheetTitle> | ||
<SheetDescription> | ||
Filter actors by tags and status. | ||
</SheetDescription> | ||
<div className="flex gap-4 flex-col"> | ||
<Suspense | ||
fallback={ | ||
<> | ||
<Skeleton className="w-full h-8" /> | ||
<Skeleton className="w-full h-8" /> | ||
<Skeleton className="w-full h-8" /> | ||
<Skeleton className="w-full h-8" /> | ||
</> | ||
} | ||
> | ||
<ActorsFiltersForm.Form | ||
onSubmit={onFiltersSubmitted} | ||
defaultValues={{ | ||
tags: {}, | ||
showDestroyed: false, | ||
}} | ||
values={{ tags, showDestroyed }} | ||
> | ||
<ActorsFiltersForm.Tags | ||
projectId={projectId} | ||
environmentId={environmentId} | ||
/> | ||
<ActorsFiltersForm.ShowDestroyed /> | ||
<div className="flex gap-2 mt-4 items-center justify-end"> | ||
<ActorsFiltersForm.Submit disablePristine> | ||
Apply | ||
</ActorsFiltersForm.Submit> | ||
|
||
<ActorsFiltersForm.Reset | ||
variant="outline" | ||
type="button" | ||
onClick={() => { | ||
onFiltersSubmitted({ | ||
tags: {}, | ||
showDestroyed: false, | ||
}); | ||
}} | ||
> | ||
Reset | ||
</ActorsFiltersForm.Reset> | ||
</div> | ||
</ActorsFiltersForm.Form> | ||
</Suspense> | ||
</div> | ||
</SheetHeader> | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
} |
This file contains 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
This file contains 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
This file contains 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
83 changes: 83 additions & 0 deletions
83
frontend/apps/hub/src/domains/project/forms/actors-filters-form.tsx
This file contains 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,83 @@ | ||
import { | ||
FormControl, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
createSchemaForm, | ||
} from "@rivet-gg/components"; | ||
import { Switch } from "@rivet-gg/components"; | ||
import { type UseFormReturn, useFormContext } from "react-hook-form"; | ||
import z from "zod"; | ||
import { TagsSelect } from "../components/tags-select"; | ||
|
||
const allowedTypes = ["image/png", "image/jpeg"]; | ||
|
||
export const formSchema = z.object({ | ||
tags: z.record(z.string()), | ||
showDestroyed: z.boolean().default(false), | ||
}); | ||
|
||
export type FormValues = z.infer<typeof formSchema>; | ||
export type SubmitHandler = ( | ||
values: FormValues, | ||
form: UseFormReturn<FormValues>, | ||
) => Promise<void>; | ||
|
||
const { Form, Submit, Reset } = createSchemaForm(formSchema); | ||
export { Form, Submit, Reset }; | ||
|
||
export const Tags = ({ | ||
projectId, | ||
environmentId, | ||
}: { projectId: string; environmentId: string }) => { | ||
const { control } = useFormContext<FormValues>(); | ||
return ( | ||
<FormField | ||
control={control} | ||
name="tags" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Tags</FormLabel> | ||
<FormControl> | ||
<TagsSelect | ||
value={field.value} | ||
projectId={projectId} | ||
environmentId={environmentId} | ||
onValueChange={field.onChange} | ||
showSelectedOptions={1} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export function ShowDestroyed() { | ||
const { control } = useFormContext<FormValues>(); | ||
return ( | ||
<FormField | ||
control={control} | ||
name="showDestroyed" | ||
render={({ field }) => ( | ||
<FormItem className="space-y-0"> | ||
<div className="flex justify-between items-center"> | ||
<FormLabel>Show destroyed?</FormLabel> | ||
<FormControl> | ||
<Switch | ||
className="mt-0" | ||
{...field} | ||
checked={field.value} | ||
onCheckedChange={field.onChange} | ||
value="show-destroyed" | ||
/> | ||
</FormControl> | ||
</div> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
); | ||
} |
This file contains 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.