aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_key_server_sync/ui/main.lua
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2026-09-24 22:47:57 +0200
committersaturneric <[email protected]>2026-09-24 22:47:57 +0200
commit3f35eadd77b34a5ab13f89772583d153bbebdc70 (patch)
tree14805ea3b65565e5902f77d3b954b33671d0e0b8 /src/m_key_server_sync/ui/main.lua
parentfeat(im): add instant messaging token module (diff)
downloadmodules-3f35eadd77b34a5ab13f89772583d153bbebdc70.tar.gz
modules-3f35eadd77b34a5ab13f89772583d153bbebdc70.zip
fix(key-server): handle missing keys consistently
- normalize 404 and empty responses as plain not-found results - distinguish missing keys from transport failures in publication checks - add key-server not-found helpers and unit coverage - disable batch actions for key groups and empty targets - add publish and refresh actions to the key manager menu - reformat affected C++ declarations and callbacks
Diffstat (limited to 'src/m_key_server_sync/ui/main.lua')
-rw-r--r--src/m_key_server_sync/ui/main.lua33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/m_key_server_sync/ui/main.lua b/src/m_key_server_sync/ui/main.lua
index 5c9c1e9..ef0d17a 100644
--- a/src/m_key_server_sync/ui/main.lua
+++ b/src/m_key_server_sync/ui/main.lua
@@ -37,15 +37,32 @@ ui.action { id = "refresh", anchor = ui.anchor("key.details.actions"),
ui.action { id = "check", anchor = ui.anchor("key.details.actions"),
command = check, update = for_this_key }
--- The same operations on whatever a key list has selected: one key or many,
--- sent as one batch.
-local function for_the_selection(ctx)
- local keys = ctx.keys
- if not keys or #keys == 0 then return { visible = false } end
- return { args = { keys = keys } }
+-- The same operations on the keys a key list acts on: the checked ones, or
+-- else the selection, sent as one batch. A key group is not a key a server
+-- holds, so a target that includes one greys the entries out.
+local function for_the_targets(hide_when_empty)
+ return function(ctx)
+ local keys = ctx.keys
+ local none = not keys or #keys == 0
+ if none and not ctx:has_key_group() then
+ if hide_when_empty then return { visible = false } end
+ return { enabled = false }
+ end
+ if ctx:has_key_group() or none then return { enabled = false } end
+ return { args = { keys = keys } }
+ end
end
+-- Right-clicking a key: shown only when there is something to act on.
ui.action { id = "publish_selected", anchor = ui.anchor("key.list.context"),
- command = publish, update = for_the_selection }
+ command = publish, update = for_the_targets(true) }
ui.action { id = "refresh_selected", anchor = ui.anchor("key.list.context"),
- command = refresh, update = for_the_selection }
+ command = refresh, update = for_the_targets(true) }
+
+-- Key Management's menu bar: always there, greyed until keys are checked.
+ui.action { id = "publish_checked",
+ anchor = ui.anchor("key.manager.menu.operations"),
+ command = publish, update = for_the_targets(false) }
+ui.action { id = "refresh_checked",
+ anchor = ui.anchor("key.manager.menu.operations"),
+ command = refresh, update = for_the_targets(false) }