pub struct Impersonate;Expand description
Acts as the record’s user: an Action for a resource whose model is the panel’s user type,
placed on its rows and record pages.
Its button shows only on a user the signed-in user may act as under the panel’s
Impersonation rule, and never while they act as someone already.
Running it lands on the panel root as that user. The resource’s policy must also allow
Ability::Run on the record.
struct Users;
impl Resource for Users {
type Model = AdminUser;
type Form = NoForm<AdminUser>;
fn declare() -> ResourceDef<Self> {
ResourceDef::new().policy(Allow).action::<Impersonate>()
}
}Trait Implementations§
Source§impl<R: Resource> Action<R> for Impersonate
impl<R: Resource> Action<R> for Impersonate
Source§const NAME: &'static str = "impersonate"
const NAME: &'static str = "impersonate"
The action’s URL segment, distinct among the resource’s actions. Read more
Source§const PLACES: Places = Places::RECORD
const PLACES: Places = Places::RECORD
Where the action’s button renders. Defaults to
Places::ALL: each row, the detail and
edit pages’ headers, and the bulk bar. Read moreSource§const ICON: Option<IconData>
const ICON: Option<IconData>
The icon before the button’s label, in every place. Defaults to none. Read more
Source§type Input = ()
type Input = ()
What the action asks for before it runs:
() for nothing, or an
FormInput struct, such as a rejection’s reason.Source§fn label() -> Text
fn label() -> Text
The button text. Defaults to the message
action-{NAME} of the panel’s catalogs, else
NAME in sentence case: "publish" reads “Publish”, and "send-invite"
reads “Send invite”.Source§fn can_run(cx: &Cx, record: &R::Model) -> bool
fn can_run(cx: &Cx, record: &R::Model) -> bool
Whether
record’s state lets the action run on it: a published post refuses “publish”.
Defaults to true. Read moreSource§async fn run(
cx: &Cx,
records: &[R::Model],
__arg2: (),
ex: &mut dyn Executor,
) -> Result<Outcome, WriteError<Infallible>>
async fn run( cx: &Cx, records: &[R::Model], __arg2: (), ex: &mut dyn Executor, ) -> Result<Outcome, WriteError<Infallible>>
Perform the action on
records, the records of the row or selection that
passed Ability::Run and can_run, with the parsed input, through
the framework’s transaction ex, and say what the response does once it commits:
Outcome::done for the success notification,
landing back where the action ran from. filter_keys writes one
change to every record in one statement. Read moreSource§fn success(_count: usize) -> Text
fn success(_count: usize) -> Text
The success notification after a commit. Defaults to the label and
the record count:
"Publish: 3 records". A bulk run the action refused
on some records appends their count out of the selection:
"Publish: 3 records (2 of 5 skipped)".Source§const CONFIRM: bool = false
const CONFIRM: bool = false
Whether the action asks first through a confirmation dialog sharing the
delete dialog’s mechanism and destructive wording. Defaults to
false. Read moreSource§const COLOR: Color = Color::Gray
const COLOR: Color = Color::Gray
The colour the button is tinted in, as Delete’s is in
Color::Danger. Defaults to
Color::Gray, the untinted button. Read moreSource§fn confirmation() -> Text
fn confirmation() -> Text
The question the confirmation dialog asks when
CONFIRM is set. Defaults
to the message tablo-confirm-run, “Run this action?”. An action with input confirms in
its input dialog instead, which its label titles.Source§fn icon_for(_cx: &Cx, _record: &R::Model) -> Option<IconData>
fn icon_for(_cx: &Cx, _record: &R::Model) -> Option<IconData>
The icon of the button on one
record, in its row and on its record page. Defaults to
ICON.Source§fn tooltip() -> Option<Text>
fn tooltip() -> Option<Text>
The hint a row’s button shows on hover, for an action whose label says too little.
Defaults to none. Read more
Source§impl Clone for Impersonate
impl Clone for Impersonate
impl Copy for Impersonate
Auto Trait Implementations§
impl Forget for Impersonate
impl Freeze for Impersonate
impl RefUnwindSafe for Impersonate
impl Send for Impersonate
impl Sync for Impersonate
impl Unpin for Impersonate
impl UnsafeUnpin for Impersonate
impl UnwindSafe for Impersonate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more