feat(nix-monitor): add settings to hide the buttons
This commit is contained in:
+19
-18
@@ -74,36 +74,46 @@ local function statLabel(text, glyph: string?)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function render()
|
local function render()
|
||||||
local firstBtn
|
local buttons = {}
|
||||||
|
|
||||||
if getState("isRemoteCheckRunning") then
|
if getState("isRemoteCheckRunning") then
|
||||||
firstBtn = ui.button({
|
table.insert(buttons, ui.button({
|
||||||
text = tr("panel.cancel"),
|
text = tr("panel.cancel"),
|
||||||
glyph = "cancel",
|
glyph = "cancel",
|
||||||
flexGrow = 1,
|
flexGrow = 1,
|
||||||
variant = "destructive",
|
variant = "destructive",
|
||||||
onClick = "onCancelClicked",
|
onClick = "onCancelClicked",
|
||||||
})
|
}))
|
||||||
else
|
else
|
||||||
if getState("isUpdateAvailable") then
|
if getState("isUpdateAvailable") and not cfg("hide_update_button") then
|
||||||
firstBtn = ui.button({
|
table.insert(buttons, ui.button({
|
||||||
text = tr("panel.update"),
|
text = tr("panel.update"),
|
||||||
glyph = "progress-down",
|
glyph = "progress-down",
|
||||||
flexGrow = 1,
|
flexGrow = 1,
|
||||||
variant = "primary",
|
variant = "primary",
|
||||||
onClick = "onUpdateClicked",
|
onClick = "onUpdateClicked",
|
||||||
})
|
}))
|
||||||
else
|
else
|
||||||
firstBtn = ui.button({
|
table.insert(buttons, ui.button({
|
||||||
text = tr("panel.check"),
|
text = tr("panel.check"),
|
||||||
glyph = "search",
|
glyph = "search",
|
||||||
flexGrow = 1,
|
flexGrow = 1,
|
||||||
variant = "outline",
|
variant = "outline",
|
||||||
onClick = "onCheckClicked",
|
onClick = "onCheckClicked",
|
||||||
})
|
}))
|
||||||
end
|
end
|
||||||
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 lastCheckTimeStr = getState("lastRemoteCheckTimeStr")
|
||||||
local generationItems = {
|
local generationItems = {
|
||||||
statLabel(`SYS: {getState("nixosGenerations")}`, "device-desktop"),
|
statLabel(`SYS: {getState("nixosGenerations")}`, "device-desktop"),
|
||||||
@@ -192,16 +202,7 @@ local function render()
|
|||||||
gap = 8,
|
gap = 8,
|
||||||
align = "center",
|
align = "center",
|
||||||
justify = "space_between"
|
justify = "space_between"
|
||||||
}, {
|
}, buttons)
|
||||||
firstBtn,
|
|
||||||
ui.button({
|
|
||||||
text = tr("panel.clean"),
|
|
||||||
glyph = "trash",
|
|
||||||
flexGrow = 1,
|
|
||||||
variant = "destructive",
|
|
||||||
onClick = "onCleanClicked",
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -187,6 +187,20 @@ label_key = "setting.clean_command.label"
|
|||||||
description_key = "setting.clean_command.description"
|
description_key = "setting.clean_command.description"
|
||||||
default = "nix-collect-garbage -d"
|
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]]
|
[[setting]]
|
||||||
key = "close_on_enter"
|
key = "close_on_enter"
|
||||||
type = "bool"
|
type = "bool"
|
||||||
|
|||||||
@@ -52,6 +52,10 @@
|
|||||||
"setting.update_command.description": "Command to run when clicking Update button",
|
"setting.update_command.description": "Command to run when clicking Update button",
|
||||||
"setting.clean_command.label": "Clean command",
|
"setting.clean_command.label": "Clean command",
|
||||||
"setting.clean_command.description": "Command to run when clicking Clean button",
|
"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.label": "Close on press Enter",
|
||||||
"setting.close_on_enter.description": "Add 'Press enter to exit' on the terminal window",
|
"setting.close_on_enter.description": "Add 'Press enter to exit' on the terminal window",
|
||||||
"setting.option.branch.master": "Master",
|
"setting.option.branch.master": "Master",
|
||||||
|
|||||||
Reference in New Issue
Block a user