Skip to main content

RowAction

Struct RowAction 

Source
pub struct RowAction { /* private fields */ }
Expand description

One action on each row of a resource’s list, as Filament’s Action::make($name) in recordActions(). See the module documentation.

Implementations§

Source§

impl RowAction

Source

pub fn make(name: impl Into<String>) -> Self

An action named name, as Filament’s Action::make('restore'). The name is the last segment of the action’s address, so it should be a slug such as delete_permanently. Its label defaults to the name with _ and - as spaces and a capital first letter: “Delete permanently”.

Source

pub fn label(self, label: impl Into<String>) -> Self

The button’s text, as Filament’s label().

Source

pub fn url(self, template: impl Into<String>) -> Self

Makes the action a link to template, as Filament’s url(). Each {key} in it is replaced by the record’s value for key, URL-encoded, such as "/blog/{slug}?preview=1" or "/admin/posts/{id}/revisions"; a key the record does not have is replaced by nothing. A link needs no authorize: the page it opens checks access, as Filament says of url().

Source

pub fn action<F>(self, handler: F) -> Self
where F: for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Row) -> RuntimeFuture<'a, ActionResult> + Send + Sync + 'static,

Makes the action a POST that runs handler, as Filament’s action(). The handler is given the database, the signed-in user, the record’s id and the record, and answers Ok(Ok(())) when done, Ok(Err(message)) to refuse with a message, or Err(error) for a database error (a server error). Write it as |db, user, id, record| Box::pin(async move { ... }).

Source

pub fn requires_confirmation(self) -> Self

Asks the user before the action runs, as Filament’s requiresConfirmation(), with Filament’s default text, “Are you sure you would like to do this?”.

Source

pub fn modal_description(self, text: impl Into<String>) -> Self

The question the confirmation asks, as Filament’s modalDescription(). It also turns the confirmation on.

Source

pub fn visible( self, rule: impl Fn(&Row) -> bool + Send + Sync + 'static, ) -> Self

Shows the action only on the rows for which rule holds, as Filament’s visible() with a $record closure. The panel also refuses to run it on another record. Several rules must all hold.

Source

pub fn hidden(self, rule: impl Fn(&Row) -> bool + Send + Sync + 'static) -> Self

Hides the action on the rows for which rule holds, as Filament’s hidden().

Source

pub fn visible_when(self, filter: ListFilter) -> Self

Shows the action only on the rows that meet filter, such as ListFilter::new().where_eq("status", "trash"): visible for a rule that is data, as a runtime resource loads it.

Source

pub fn color(self, color: BadgeColor) -> Self

The button’s colour, as Filament’s color(). Danger renders the panel’s danger button; the others render its plain button, with the class ig-action-<color> for a theme. The default is none.

Source

pub fn authorize(self, ability: ActionAbility) -> Self

The ability the action needs, as Filament’s authorize('update') or authorize('delete'). The default is ActionAbility::Update.

Source

pub fn success_notification_title(self, title: impl Into<String>) -> Self

The message shown after the action ran, as Filament’s successNotificationTitle(). The default is none: the list shows again without a message.

Source

pub fn name(&self) -> &str

The action’s name.

Source

pub fn get_label(&self) -> String

The button’s text: the label, or the name made readable.

Source

pub fn is_post(&self) -> bool

Whether the action posts to the panel: it has a handler.

Source

pub fn url_for(&self, record: &Row) -> Option<String>

The link of the action for record, when it is a link.

Source

pub fn confirmation(&self) -> Option<&str>

The confirmation’s text, when the action asks first.

Source

pub fn is_visible(&self, record: &Row) -> bool

Whether the action shows on record: every visibility rule holds.

Source

pub fn get_color(&self) -> Option<BadgeColor>

The button’s colour, if set.

Source

pub fn ability(&self) -> ActionAbility

The ability the action needs.

Source

pub fn success_message(&self) -> Option<&str>

The message shown after the action ran, if set.

Source

pub async fn run( &self, db: &Database, user: &ActingUser, id: i64, record: &Row, ) -> Result<ActionResult, Error>

Runs the handler on the record id. An action without a handler (a link) answers Ok(Err(..)); the panel does not call it then.

Trait Implementations§

Source§

impl Clone for RowAction

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RowAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for RowAction

§

impl !UnwindSafe for RowAction

§

impl Forget for RowAction

§

impl Freeze for RowAction
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>>: Freeze, PhantomData<Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>>: Freeze,

§

impl Move for RowAction

§

impl Send for RowAction
where RawVecInner: Send, Arc<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>: Send, Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>: Send,

§

impl Sync for RowAction
where RawVecInner: Sync, Arc<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>: Sync, Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>: Sync,

§

impl Unpin for RowAction
where *const u8 is !null: Unpin, Arc<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>: Unpin, Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>: Unpin,

§

impl UnsafeUnpin for RowAction
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>>: UnsafeUnpin, PhantomData<Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more