rename pipeline webhook to what it is

This commit is contained in:
DaKheera47
2025-12-15 17:23:11 +00:00
parent 8227cabd17
commit 368fe60935
9 changed files with 142 additions and 14 deletions
+4 -1
View File
@@ -98,7 +98,10 @@ export async function getSettings(): Promise<AppSettings> {
return fetchApi<AppSettings>('/settings');
}
export async function updateSettings(update: { model?: string | null }): Promise<AppSettings> {
export async function updateSettings(update: {
model?: string | null
pipelineWebhookUrl?: string | null
}): Promise<AppSettings> {
return fetchApi<AppSettings>('/settings', {
method: 'PATCH',
body: JSON.stringify(update),
+58 -12
View File
@@ -15,6 +15,7 @@ import * as api from "../api"
export const SettingsPage: React.FC = () => {
const [settings, setSettings] = useState<AppSettings | null>(null)
const [modelDraft, setModelDraft] = useState("")
const [pipelineWebhookUrlDraft, setPipelineWebhookUrlDraft] = useState("")
const [isSaving, setIsSaving] = useState(false)
const [isLoading, setIsLoading] = useState(true)
@@ -27,6 +28,7 @@ export const SettingsPage: React.FC = () => {
if (!isMounted) return
setSettings(data)
setModelDraft(data.overrideModel ?? "")
setPipelineWebhookUrlDraft(data.overridePipelineWebhookUrl ?? "")
})
.catch((error) => {
const message = error instanceof Error ? error.message : "Failed to load settings"
@@ -45,22 +47,32 @@ export const SettingsPage: React.FC = () => {
const effectiveModel = settings?.model ?? ""
const defaultModel = settings?.defaultModel ?? ""
const overrideModel = settings?.overrideModel
const effectivePipelineWebhookUrl = settings?.pipelineWebhookUrl ?? ""
const defaultPipelineWebhookUrl = settings?.defaultPipelineWebhookUrl ?? ""
const overridePipelineWebhookUrl = settings?.overridePipelineWebhookUrl
const canSave = useMemo(() => {
if (!settings) return false
const next = modelDraft.trim()
const current = (overrideModel ?? "").trim()
return next !== current
}, [modelDraft, overrideModel, settings])
const nextWebhook = pipelineWebhookUrlDraft.trim()
const currentWebhook = (overridePipelineWebhookUrl ?? "").trim()
return next !== current || nextWebhook !== currentWebhook
}, [modelDraft, overrideModel, settings, pipelineWebhookUrlDraft, overridePipelineWebhookUrl])
const handleSave = async () => {
if (!settings) return
try {
setIsSaving(true)
const trimmed = modelDraft.trim()
const updated = await api.updateSettings({ model: trimmed.length > 0 ? trimmed : null })
const webhookTrimmed = pipelineWebhookUrlDraft.trim()
const updated = await api.updateSettings({
model: trimmed.length > 0 ? trimmed : null,
pipelineWebhookUrl: webhookTrimmed.length > 0 ? webhookTrimmed : null,
})
setSettings(updated)
setModelDraft(updated.overrideModel ?? "")
setPipelineWebhookUrlDraft(updated.overridePipelineWebhookUrl ?? "")
toast.success("Settings saved")
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to save settings"
@@ -73,9 +85,10 @@ export const SettingsPage: React.FC = () => {
const handleReset = async () => {
try {
setIsSaving(true)
const updated = await api.updateSettings({ model: null })
const updated = await api.updateSettings({ model: null, pipelineWebhookUrl: null })
setSettings(updated)
setModelDraft("")
setPipelineWebhookUrlDraft("")
toast.success("Reset to default")
} catch (error) {
const message = error instanceof Error ? error.message : "Failed to reset settings"
@@ -123,18 +136,51 @@ export const SettingsPage: React.FC = () => {
<div className="break-words font-mono text-xs">{defaultModel || "—"}</div>
</div>
</div>
</CardContent>
</Card>
<div className="flex flex-wrap gap-2">
<Button onClick={handleSave} disabled={isLoading || isSaving || !canSave}>
{isSaving ? "Saving..." : "Save"}
</Button>
<Button variant="outline" onClick={handleReset} disabled={isLoading || isSaving || !settings}>
Reset to default
</Button>
<Card>
<CardHeader>
<CardTitle className="text-base">Pipeline Webhook</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-2">
<div className="text-sm font-medium">Pipeline status webhook URL</div>
<Input
value={pipelineWebhookUrlDraft}
onChange={(event) => setPipelineWebhookUrlDraft(event.target.value)}
placeholder={defaultPipelineWebhookUrl || "https://..."}
disabled={isLoading || isSaving}
/>
<div className="text-xs text-muted-foreground">
When set, the server sends a POST on pipeline completion/failure. Leave blank to disable.
</div>
</div>
<Separator />
<div className="grid gap-2 text-sm sm:grid-cols-2">
<div>
<div className="text-xs text-muted-foreground">Effective</div>
<div className="break-words font-mono text-xs">{effectivePipelineWebhookUrl || "—"}</div>
</div>
<div>
<div className="text-xs text-muted-foreground">Default (env)</div>
<div className="break-words font-mono text-xs">{defaultPipelineWebhookUrl || "—"}</div>
</div>
</div>
</CardContent>
</Card>
<div className="flex flex-wrap gap-2">
<Button onClick={handleSave} disabled={isLoading || isSaving || !canSave}>
{isSaving ? "Saving..." : "Save"}
</Button>
<Button variant="outline" onClick={handleReset} disabled={isLoading || isSaving || !settings}>
Reset to default
</Button>
</div>
</main>
)
}