From fbf259f22c7645df7cdb52e8e8a6143652ff3216 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:39:21 -0400 Subject: [PATCH] Refactor schedules hooks to accept repoId as parameter Remove repoId from hook closure and pass it explicitly. Improves reusability and makes hooks more flexible. --- .../src/components/schedules/GeneralTab.tsx | 137 ++++++ .../src/components/schedules/PromptTab.tsx | 126 +++++ .../schedules/ScheduleJobDialog.tsx | 464 +++--------------- .../src/components/schedules/SkillsTab.tsx | 65 +++ .../src/components/schedules/TimingTab.tsx | 229 +++++++++ frontend/src/hooks/useSchedules.ts | 63 ++- frontend/src/pages/GlobalSchedules.tsx | 8 +- frontend/src/pages/Schedules.tsx | 19 +- 8 files changed, 665 insertions(+), 446 deletions(-) create mode 100644 frontend/src/components/schedules/GeneralTab.tsx create mode 100644 frontend/src/components/schedules/PromptTab.tsx create mode 100644 frontend/src/components/schedules/SkillsTab.tsx create mode 100644 frontend/src/components/schedules/TimingTab.tsx diff --git a/frontend/src/components/schedules/GeneralTab.tsx b/frontend/src/components/schedules/GeneralTab.tsx new file mode 100644 index 00000000..9e9939cb --- /dev/null +++ b/frontend/src/components/schedules/GeneralTab.tsx @@ -0,0 +1,137 @@ +import { Combobox, type ComboboxOption } from '@/components/ui/combobox' +import { Input } from '@/components/ui/input' +import { Label } from '@/components/ui/label' +import { Switch } from '@/components/ui/switch' +import { TabsContent } from '@/components/ui/tabs' +import { Info } from 'lucide-react' + +type GeneralTabProps = { + name: string + onNameChange: (value: string) => void + description: string + onDescriptionChange: (value: string) => void + agentSlug: string + onAgentSlugChange: (value: string) => void + agentOptions: ComboboxOption[] + model: string + onModelChange: (value: string) => void + modelOptions: ComboboxOption[] + enabled: boolean + onEnabledChange: (value: boolean) => void + showRepoSelector?: boolean + isEditing: boolean + repoId?: number + onRepoChange?: (repoId: number | undefined) => void + repoOptions: ComboboxOption[] +} + +function InfoHint({ text }: { text: string }) { + return ( + + + + ) +} + +export function GeneralTab({ + name, + onNameChange, + description, + onDescriptionChange, + agentSlug, + onAgentSlugChange, + agentOptions, + model, + onModelChange, + modelOptions, + enabled, + onEnabledChange, + showRepoSelector, + isEditing, + repoId, + onRepoChange, + repoOptions, +}: GeneralTabProps) { + return ( + +
+ {showRepoSelector && !isEditing && ( +
+ + onRepoChange?.(value ? Number(value) : undefined)} + options={repoOptions} + placeholder="Select a repository" + allowCustomValue={false} + /> +
+ )} +
+
+ + onNameChange(event.target.value)} + placeholder="Nightly repo health check" + /> +
+ +
+ + onDescriptionChange(event.target.value)} + placeholder="What this job checks or produces" + /> +
+
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ +
+
+
+

Enabled

+ +
+ +
+
+
+
+ ) +} diff --git a/frontend/src/components/schedules/PromptTab.tsx b/frontend/src/components/schedules/PromptTab.tsx new file mode 100644 index 00000000..56184daa --- /dev/null +++ b/frontend/src/components/schedules/PromptTab.tsx @@ -0,0 +1,126 @@ +import { Button } from '@/components/ui/button' +import { Label } from '@/components/ui/label' +import { TabsContent } from '@/components/ui/tabs' +import { Textarea } from '@/components/ui/textarea' +import { Badge } from '@/components/ui/badge' +import { Check, Pencil, Plus, Trash2 } from 'lucide-react' +import type { PromptTemplate } from '@opencode-manager/shared/types' + +type PromptTabProps = { + prompt: string + onPromptChange: (value: string) => void + selectedPromptTemplateId: number | null + onApplyTemplate: (template: PromptTemplate) => void + templates: PromptTemplate[] + onEditTemplate: (template: PromptTemplate) => void + onDeleteTemplate: (templateId: number) => void + onNewTemplate: () => void +} + +export function PromptTab({ + prompt, + onPromptChange, + selectedPromptTemplateId, + onApplyTemplate, + templates, + onEditTemplate, + onDeleteTemplate, + onNewTemplate, +}: PromptTabProps) { + return ( + +
+
+
+ + +
+ +
+ {templates.map((template) => { + const isSelected = selectedPromptTemplateId === template.id + + return ( +
+ +
+ + +
+
+ ) + })} +
+
+ +
+ +