Files
ServerKit/frontend/src/components/JournalControls.jsx
T
Juan DenisandClaude Opus 4.8 b70277ef67 fix(frontend): Phase 5 §8.2 A3 — add type="button" to raw action buttons
Raw <button> elements default to type="submit" inside a form, causing accidental
submits. Added an explicit type="button" to the 234 raw buttons (across 60
files) that have an onClick and no type — i.e. action buttons, which are never
the intended default-submit. Default-submit buttons (no onClick) and the shadcn
ui/* wrappers were left untouched. Applied via a brace/quote-aware scan so
multi-line tags and style={{...}} attrs are handled correctly.

Verified: npm run build passes; dashboard/services/settings screenshots render
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 10:42:47 -04:00

92 lines
3.1 KiB
React

import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
const PRIORITY_OPTIONS = [
{ value: '', label: 'All' },
{ value: '0', label: 'Emergency' },
{ value: '1', label: 'Alert' },
{ value: '2', label: 'Critical' },
{ value: '3', label: 'Error' },
{ value: '4', label: 'Warning' },
{ value: '5', label: 'Notice' },
{ value: '6', label: 'Info' },
{ value: '7', label: 'Debug' },
];
export function JournalControls({
unit = '',
onUnitChange,
unitLabel = 'Service/Unit',
unitPlaceholder = 'All services',
quickUnits = [],
showQuickUnits = true,
lineCount,
onLineCountChange,
lineCountOptions = [50, 100, 200, 500],
priority,
onPriorityChange,
showPriority = true,
loading = false,
onLoad,
loadLabel = 'Load Logs',
}) {
return (
<div className="journal-controls">
<div className="control-group">
<label>{unitLabel}</label>
<div className="input-with-suggestions">
<Input
type="text"
value={unit}
onChange={(e) => onUnitChange?.(e.target.value)}
placeholder={unitPlaceholder}
/>
{showQuickUnits && quickUnits.length > 0 && (
<div className="quick-units">
{quickUnits.map(u => (
<button type="button"
key={u}
className={`unit-chip ${unit === u ? 'active' : ''}`}
onClick={() => onUnitChange?.(unit === u ? '' : u)}
>
{u}
</button>
))}
</div>
)}
</div>
</div>
{onLineCountChange && (
<div className="control-group">
<label>Lines</label>
<select value={lineCount} onChange={(e) => onLineCountChange(parseInt(e.target.value, 10))}>
{lineCountOptions.map(n => (
<option key={n} value={n}>{n}</option>
))}
</select>
</div>
)}
{showPriority && onPriorityChange && (
<div className="control-group">
<label>Priority</label>
<select value={priority ?? ''} onChange={(e) => onPriorityChange(e.target.value)}>
{PRIORITY_OPTIONS.map(o => (
<option key={o.value} value={o.value}>{o.label}</option>
))}
</select>
</div>
)}
{onLoad && (
<Button onClick={onLoad} disabled={loading}>
{loading ? 'Loading...' : loadLabel}
</Button>
)}
</div>
);
}
export default JournalControls;