mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 10:46:16 +01:00
quiet hours refactoring: change 'future' to 'inactive'
This commit is contained in:
@@ -114,7 +114,7 @@ export function QuietHours() {
|
|||||||
return `${start} - ${end}`
|
return `${start} - ${end}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const getWindowState = (record: QuietHoursRecord): "active" | "past" | "future" => {
|
const getWindowState = (record: QuietHoursRecord): "active" | "past" | "inactive" => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|
||||||
if (record.type === "daily") {
|
if (record.type === "daily") {
|
||||||
@@ -134,9 +134,9 @@ export function QuietHours() {
|
|||||||
|
|
||||||
// Handle cases where window spans midnight
|
// Handle cases where window spans midnight
|
||||||
if (localStartMinutes <= localEndMinutes) {
|
if (localStartMinutes <= localEndMinutes) {
|
||||||
return currentMinutes >= localStartMinutes && currentMinutes < localEndMinutes ? "active" : "future"
|
return currentMinutes >= localStartMinutes && currentMinutes < localEndMinutes ? "active" : "inactive"
|
||||||
} else {
|
} else {
|
||||||
return currentMinutes >= localStartMinutes || currentMinutes < localEndMinutes ? "active" : "future"
|
return currentMinutes >= localStartMinutes || currentMinutes < localEndMinutes ? "active" : "inactive"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// For one-time windows
|
// For one-time windows
|
||||||
@@ -148,7 +148,7 @@ export function QuietHours() {
|
|||||||
} else if (now >= endDate) {
|
} else if (now >= endDate) {
|
||||||
return "past"
|
return "past"
|
||||||
} else {
|
} else {
|
||||||
return "future"
|
return "inactive"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,14 +197,14 @@ export function QuietHours() {
|
|||||||
</TableHead>
|
</TableHead>
|
||||||
<TableHead className="px-4">
|
<TableHead className="px-4">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<ActivityIcon className="size-4" />
|
<CalendarIcon className="size-4" />
|
||||||
<Trans>State</Trans>
|
<Trans>Schedule</Trans>
|
||||||
</span>
|
</span>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableHead className="px-4">
|
<TableHead className="px-4">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<CalendarIcon className="size-4" />
|
<ActivityIcon className="size-4" />
|
||||||
<Trans>Schedule</Trans>
|
<Trans>State</Trans>
|
||||||
</span>
|
</span>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableHead className="px-4 text-right sr-only">
|
<TableHead className="px-4 text-right sr-only">
|
||||||
@@ -221,19 +221,19 @@ export function QuietHours() {
|
|||||||
<TableCell className="px-4 py-3">
|
<TableCell className="px-4 py-3">
|
||||||
{record.type === "daily" ? <Trans>Daily</Trans> : <Trans>One-time</Trans>}
|
{record.type === "daily" ? <Trans>Daily</Trans> : <Trans>One-time</Trans>}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell className="px-4 py-3">{formatDateTime(record)}</TableCell>
|
||||||
<TableCell className="px-4 py-3">
|
<TableCell className="px-4 py-3">
|
||||||
{(() => {
|
{(() => {
|
||||||
const state = getWindowState(record)
|
const state = getWindowState(record)
|
||||||
const stateConfig = {
|
const stateConfig = {
|
||||||
active: { label: <Trans>Active</Trans>, variant: "success" as const },
|
active: { label: <Trans>Active</Trans>, variant: "success" as const },
|
||||||
past: { label: <Trans>Past</Trans>, variant: "danger" as const },
|
past: { label: <Trans>Past</Trans>, variant: "danger" as const },
|
||||||
future: { label: <Trans>Future</Trans>, variant: "default" as const },
|
inactive: { label: <Trans>Inactive</Trans>, variant: "default" as const },
|
||||||
}
|
}
|
||||||
const config = stateConfig[state]
|
const config = stateConfig[state]
|
||||||
return <Badge variant={config.variant}>{config.label}</Badge>
|
return <Badge variant={config.variant}>{config.label}</Badge>
|
||||||
})()}
|
})()}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="px-4 py-3">{formatDateTime(record)}</TableCell>
|
|
||||||
<TableCell className="px-4 py-3 text-right">
|
<TableCell className="px-4 py-3 text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
@@ -285,7 +285,7 @@ function QuietHoursDialog({
|
|||||||
editingRecord: QuietHoursRecord | null
|
editingRecord: QuietHoursRecord | null
|
||||||
systems: SystemRecord[]
|
systems: SystemRecord[]
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
toast: any
|
toast: ReturnType<typeof useToast>["toast"]
|
||||||
}) {
|
}) {
|
||||||
const [selectedSystem, setSelectedSystem] = useState(editingRecord?.system || "")
|
const [selectedSystem, setSelectedSystem] = useState(editingRecord?.system || "")
|
||||||
const [isGlobal, setIsGlobal] = useState(!editingRecord?.system)
|
const [isGlobal, setIsGlobal] = useState(!editingRecord?.system)
|
||||||
|
|||||||
Reference in New Issue
Block a user