Hide apply-update command until update is available
This commit is contained in:
parent
82d2d0e474
commit
bf69fcbdcf
2 changed files with 22 additions and 3 deletions
|
|
@ -1275,6 +1275,8 @@ struct ContentView: View {
|
|||
static let panelHasCustomName = "panel.hasCustomName"
|
||||
static let panelShouldPin = "panel.shouldPin"
|
||||
static let panelHasUnread = "panel.hasUnread"
|
||||
|
||||
static let updateHasAvailable = "update.hasAvailable"
|
||||
}
|
||||
|
||||
private struct CommandPaletteCommandContribution {
|
||||
|
|
@ -3190,6 +3192,10 @@ struct ContentView: View {
|
|||
snapshot.setBool(CommandPaletteContextKeys.panelHasUnread, hasUnread)
|
||||
}
|
||||
|
||||
if case .updateAvailable = updateViewModel.effectiveState {
|
||||
snapshot.setBool(CommandPaletteContextKeys.updateHasAvailable, true)
|
||||
}
|
||||
|
||||
return snapshot
|
||||
}
|
||||
|
||||
|
|
@ -3335,7 +3341,8 @@ struct ContentView: View {
|
|||
commandId: "palette.applyUpdateIfAvailable",
|
||||
title: constant("Apply Update (If Available)"),
|
||||
subtitle: constant("Global"),
|
||||
keywords: ["apply", "install", "update", "available"]
|
||||
keywords: ["apply", "install", "update", "available"],
|
||||
when: { $0.bool(CommandPaletteContextKeys.updateHasAvailable) }
|
||||
)
|
||||
)
|
||||
contributions.append(
|
||||
|
|
|
|||
|
|
@ -53,8 +53,20 @@ def main() -> int:
|
|||
|
||||
expect_regex(
|
||||
content_view,
|
||||
r'commandId:\s*"palette\.applyUpdateIfAvailable".*?title:\s*constant\("Apply Update \(If Available\)"\).*?keywords:\s*\[[^\]]*"apply"[^\]]*"install"[^\]]*"update"[^\]]*"available"[^\]]*\]',
|
||||
"Missing or incomplete `palette.applyUpdateIfAvailable` contribution",
|
||||
r'static\s+let\s+updateHasAvailable\s*=\s*"update\.hasAvailable"',
|
||||
"Missing `CommandPaletteContextKeys.updateHasAvailable`",
|
||||
failures,
|
||||
)
|
||||
expect_regex(
|
||||
content_view,
|
||||
r'if\s+case\s+\.updateAvailable\s*=\s*updateViewModel\.effectiveState\s*\{\s*snapshot\.setBool\(CommandPaletteContextKeys\.updateHasAvailable,\s*true\)\s*\}',
|
||||
"Command palette context no longer tracks update-available state",
|
||||
failures,
|
||||
)
|
||||
expect_regex(
|
||||
content_view,
|
||||
r'commandId:\s*"palette\.applyUpdateIfAvailable".*?title:\s*constant\("Apply Update \(If Available\)"\).*?keywords:\s*\[[^\]]*"apply"[^\]]*"install"[^\]]*"update"[^\]]*"available"[^\]]*\].*?when:\s*\{\s*\$0\.bool\(CommandPaletteContextKeys\.updateHasAvailable\)\s*\}',
|
||||
"Missing or incomplete `palette.applyUpdateIfAvailable` contribution visibility gating",
|
||||
failures,
|
||||
)
|
||||
expect_regex(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue