pub struct HeaderActionDef { /* private fields */ }Expand description
What a HeaderAction declares besides its name, input and body: how
its button reads, whether it asks first, and who it runs for beyond the policy or the page’s
access. Every setting has a default, so HeaderActionDef::new alone is a gray button
labelled after the action’s NAME.
let def = HeaderActionDef::new()
.icon(tablo_ui::icons::CHECK)
.color(Color::Warning)
.confirm();Implementations§
Source§impl HeaderActionDef
impl HeaderActionDef
Sourcepub fn new() -> HeaderActionDef
pub fn new() -> HeaderActionDef
Every default: a gray button labelled after the action’s NAME, running without
confirmation for whoever the policy or the page’s access admits.
Sourcepub fn confirm(self) -> HeaderActionDef
pub fn confirm(self) -> HeaderActionDef
Asks first, through a confirmation dialog with destructive wording.
An action with input confirms in its input dialog, or on its input page, instead. An unconfirmed POST that would write answers 400.
Sourcepub fn confirmation(self, question: impl Into<Text>) -> HeaderActionDef
pub fn confirmation(self, question: impl Into<Text>) -> HeaderActionDef
Asks first, as confirm does, with question in place of the message
tablo-confirm-run, “Run this action?”. An action with input confirms in its input
dialog instead, which its label titles.
Sourcepub fn icon(self, icon: IconData) -> HeaderActionDef
pub fn icon(self, icon: IconData) -> HeaderActionDef
The icon before the button’s label. Defaults to none.
Sourcepub fn color(self, color: Color) -> HeaderActionDef
pub fn color(self, color: Color) -> HeaderActionDef
The colour the button is tinted in, as Delete’s is in Color::Danger. Defaults to
Color::Gray, the untinted button.
It changes how the button looks, not what it asks: confirm asks first.
Sourcepub fn label(self, label: impl Into<Text>) -> HeaderActionDef
pub fn label(self, label: impl Into<Text>) -> HeaderActionDef
The button text. Defaults to the message action-{NAME} of the panel’s catalogs, else
NAME in sentence case: "recount-tags" reads “Recount tags”.
Sourcepub fn can_run(
self,
check: impl Fn(&Cx) -> bool + Send + Sync + 'static,
) -> HeaderActionDef
pub fn can_run( self, check: impl Fn(&Cx) -> bool + Send + Sync + 'static, ) -> HeaderActionDef
Whether the request may run the action, beyond the policy or the page’s access: a feature flag, a role the policy does not model. Defaults to every request.
Sourcepub fn success(self, message: impl Into<Text>) -> HeaderActionDef
pub fn success(self, message: impl Into<Text>) -> HeaderActionDef
The success notification after a commit. Defaults to the label: "Recount tags: done".