package systemviews
import (
"github.com/bnema/dumber/internal/application/dto"
"github.com/bnema/dumber/internal/application/port"
)
templ ConfigView(data configRenderData) {
@Alert("success", data.Notice)
@Alert("error", data.Error)
@Section("sv-config-appearance", "Appearance") {
@AppearanceForm(data.Config)
}
@Section("sv-config-search", "Search") {
@SearchSettings(data.Config)
}
@Section("sv-config-performance", "Performance") {
@PerformanceSettings(data.Config)
}
@Section("sv-config-keybindings", "Keybindings") {
@Meta(configKeybindingSummary(data.Keybindings))
@ConfigKeybindings(data.Keybindings)
}
@Section("sv-config-values", "Current payload") {
@KV(flattenValues(data.Config))
}
}
templ AppearanceForm(config dto.SystemviewConfigPayload) {
}
templ PaletteFields(title string, prefix string, palette dto.ColorPalette) {
}
templ SearchSettings(config dto.SystemviewConfigPayload) {
Shortcut URLs must include the %s placeholder for the search query.
{{ shortcuts := searchShortcutRows(config.SearchShortcuts) }}
if len(shortcuts) == 0 {
@EmptyState("No search shortcuts configured")
} else {
for _, shortcut := range shortcuts {
@SearchShortcutItem(shortcut)
}
}
}
templ SearchShortcutItem(shortcut searchShortcutRow) {
}
templ PerformanceSettings(config dto.SystemviewConfigPayload) {
{{ customProfile := performanceProfileSelected(config.Performance.Profile, "custom") }}
{ formatConfigInt(config.Performance.Hardware.CPUThreads) }CPU threads
{ formatConfigInt(config.Performance.Hardware.TotalRAMMB) }RAM MB
{ config.Performance.Hardware.GPUName }GPU
{ config.EngineType }Engine
if !engineIsWebKit(config.EngineType) {
Performance tuning applies only to the WebKit engine.
} else {
Performance profile changes may require restarting the browser to affect existing engine processes.
}
}
templ ConfigKeybindings(keybindings port.KeybindingsConfig) {
{{ groups := configKeybindingGroups(keybindings) }}
if groups == nil {
@EmptyState("Keybindings unavailable")
} else if len(groups) == 0 {
@EmptyState("No keybindings configured")
} else {
for _, group := range groups {
@ConfigKeybindingGroup(group)
}
}
}
templ ConfigKeybindingGroup(group renderedKeybindingGroup) {
if len(group.Bindings) == 0 {
@EmptyState("No bindings in this group")
} else {
for _, binding := range group.Bindings {
@ConfigKeybinding(group, binding)
}
}
}
templ ConfigKeybinding(group renderedKeybindingGroup, binding renderedKeybinding) {
{ keybindingDescription(binding) }
{ keybindingAction(binding) }
@KeyList(binding.Keys)
{ keybindingStatus(binding) }
if keybindingIsCustom(binding) && len(binding.DefaultKeys) > 0 {
default:
@KeyList(binding.DefaultKeys)
}
}