Implement desktop help settings and about
This commit is contained in:
@@ -236,7 +236,13 @@ pub fn shortcut_label(action: UiAction) -> Option<String> {
|
||||
|
||||
pub fn enabled(action: UiAction, context: ActionContext) -> bool {
|
||||
match action {
|
||||
UiAction::About | UiAction::Settings | UiAction::Help => true,
|
||||
UiAction::About | UiAction::Help => !context.modal_open,
|
||||
UiAction::Settings => {
|
||||
context.storage_ready
|
||||
&& !context.saving
|
||||
&& !context.switching_vault
|
||||
&& !context.modal_open
|
||||
}
|
||||
UiAction::CommandPalette => !context.modal_open,
|
||||
// Entry creation is not valid until the dedicated workflow exists.
|
||||
UiAction::NewEntry => false,
|
||||
@@ -269,7 +275,7 @@ pub fn enabled(action: UiAction, context: ActionContext) -> bool {
|
||||
UiAction::CopyEditedField => {
|
||||
context.unlocked && context.editing && !context.switching_vault && context.focused_field
|
||||
}
|
||||
UiAction::TogglePaneFocus => true,
|
||||
UiAction::TogglePaneFocus => !context.modal_open,
|
||||
UiAction::Refresh => {
|
||||
context.storage_ready && !context.tree_loading && !context.switching_vault
|
||||
}
|
||||
@@ -345,11 +351,13 @@ pub fn disabled_reason(action: UiAction, context: ActionContext) -> Option<&'sta
|
||||
UiAction::ToggleReveal => "Wait for vault validation",
|
||||
UiAction::Lock => "The password store is already locked",
|
||||
UiAction::CommandPalette => "Finish the current confirmation first",
|
||||
UiAction::About
|
||||
| UiAction::Settings
|
||||
| UiAction::TogglePaneFocus
|
||||
| UiAction::Minimize
|
||||
| UiAction::Help => "Action is unavailable",
|
||||
UiAction::Settings if !context.storage_ready => "Shared configuration is unavailable",
|
||||
UiAction::Settings if context.saving => "Wait for the active save",
|
||||
UiAction::Settings if context.switching_vault => "Wait for vault validation",
|
||||
UiAction::About | UiAction::Settings | UiAction::TogglePaneFocus | UiAction::Help => {
|
||||
"Close the current screen first"
|
||||
}
|
||||
UiAction::Minimize => "Action is unavailable",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -506,6 +514,7 @@ mod tests {
|
||||
..ready
|
||||
};
|
||||
for action in [
|
||||
UiAction::Settings,
|
||||
UiAction::Save,
|
||||
UiAction::CloseWindow,
|
||||
UiAction::Quit,
|
||||
@@ -544,6 +553,25 @@ mod tests {
|
||||
),
|
||||
Some("Finish the current confirmation first")
|
||||
);
|
||||
let modal = ActionContext {
|
||||
modal_open: true,
|
||||
..ready
|
||||
};
|
||||
for action in [
|
||||
UiAction::About,
|
||||
UiAction::Settings,
|
||||
UiAction::TogglePaneFocus,
|
||||
UiAction::Help,
|
||||
] {
|
||||
assert!(!enabled(action, modal), "{action:?}");
|
||||
}
|
||||
assert!(!enabled(
|
||||
UiAction::Settings,
|
||||
ActionContext {
|
||||
storage_ready: false,
|
||||
..ready
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -567,5 +595,10 @@ mod tests {
|
||||
Some(expected)
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
shortcut_action(&keyboard::Key::Named(Named::F1), keyboard::Modifiers::NONE),
|
||||
Some(UiAction::Help)
|
||||
);
|
||||
assert_eq!(shortcut_label(UiAction::Help).as_deref(), Some("F1"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user