diff --git a/nix-monitor/panel.luau b/nix-monitor/panel.luau index 2b662d4..c2cc753 100644 --- a/nix-monitor/panel.luau +++ b/nix-monitor/panel.luau @@ -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 diff --git a/nix-monitor/plugin.toml b/nix-monitor/plugin.toml index 67fe4d2..413d756 100644 --- a/nix-monitor/plugin.toml +++ b/nix-monitor/plugin.toml @@ -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" diff --git a/nix-monitor/translations/en.json b/nix-monitor/translations/en.json index 3c419ce..c8f5adf 100644 --- a/nix-monitor/translations/en.json +++ b/nix-monitor/translations/en.json @@ -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",