feat(nix-monitor): add settings to hide the buttons

This commit is contained in:
avivbintangaringga
2026-07-16 11:21:30 +07:00
parent 829da23ebb
commit 9279cdc84a
3 changed files with 37 additions and 18 deletions
+19 -18
View File
@@ -74,36 +74,46 @@ local function statLabel(text, glyph: string?)
end
local function render()
local firstBtn
local buttons = {}
if getState("isRemoteCheckRunning") then
firstBtn = ui.button({
table.insert(buttons, ui.button({
text = tr("panel.cancel"),
glyph = "cancel",
flexGrow = 1,
variant = "destructive",
onClick = "onCancelClicked",
})
}))
else
if getState("isUpdateAvailable") then
firstBtn = ui.button({
if getState("isUpdateAvailable") and not cfg("hide_update_button") then
table.insert(buttons, ui.button({
text = tr("panel.update"),
glyph = "progress-down",
flexGrow = 1,
variant = "primary",
onClick = "onUpdateClicked",
})
}))
else
firstBtn = ui.button({
table.insert(buttons, ui.button({
text = tr("panel.check"),
glyph = "search",
flexGrow = 1,
variant = "outline",
onClick = "onCheckClicked",
})
}))
end
end
if not cfg("hide_clean_button") then
table.insert(buttons, ui.button({
text = tr("panel.clean"),
glyph = "trash",
flexGrow = 1,
variant = "destructive",
onClick = "onCleanClicked",
}))
end
local lastCheckTimeStr = getState("lastRemoteCheckTimeStr")
local generationItems = {
statLabel(`SYS: {getState("nixosGenerations")}`, "device-desktop"),
@@ -192,16 +202,7 @@ local function render()
gap = 8,
align = "center",
justify = "space_between"
}, {
firstBtn,
ui.button({
text = tr("panel.clean"),
glyph = "trash",
flexGrow = 1,
variant = "destructive",
onClick = "onCleanClicked",
}),
})
}, buttons)
})
)
end
+14
View File
@@ -187,6 +187,20 @@ label_key = "setting.clean_command.label"
description_key = "setting.clean_command.description"
default = "nix-collect-garbage -d"
[[setting]]
key = "hide_update_button"
type = "bool"
label_key = "setting.hide_update_button.label"
description_key = "setting.hide_update_button.description"
default = false
[[setting]]
key = "hide_clean_button"
type = "bool"
label_key = "setting.hide_clean_button.label"
description_key = "setting.hide_clean_button.description"
default = false
[[setting]]
key = "close_on_enter"
type = "bool"
+4
View File
@@ -52,6 +52,10 @@
"setting.update_command.description": "Command to run when clicking Update button",
"setting.clean_command.label": "Clean command",
"setting.clean_command.description": "Command to run when clicking Clean button",
"setting.hide_update_button.label": "Hide update button",
"setting.hide_update_button.description": "Whether to hide the update button on the panel",
"setting.hide_clean_button.label": "Hide clean button",
"setting.hide_clean_button.description": "Whether to hide the clean button on the panel",
"setting.close_on_enter.label": "Close on press Enter",
"setting.close_on_enter.description": "Add 'Press enter to exit' on the terminal window",
"setting.option.branch.master": "Master",