Actions are automation or workflow tasks that can be triggered by users.
Custom Actions#
These actions are defined on the main configuration object. (Model and field objects should be applied to schema definitions or extensions within the models
property.)
actions
#
Defines a bulk or global custom action.
Required
No
Allowed Values
An array of action definitions, as documented below.
Action Properties#
Each action has a number of properties that can be used to configure it. They are documented below.
name
Unique name for the action. Used as as the default label for the trigger button.
Required
Yes
Allowed Values
String representing the name.
type
Tells the visual editor which type of action should be run. See the feature guide for more information on identifying the appropriate action to use.
Required
Yes
Allowed Values
global
, bulk
run
Function to run when the action is triggered by an editor.
Required
Yes
Allowed Values
A function that optionally returns a result object.
Result object:
state
(optional): State value, as specified above.success
(optional): Message to show on success.error
(optional): Message to show on error.
The function parameters are a single options
object. This object includes all the properties in ConfigDelegate
(documented here as documented hook options), along with the following action properties:
actionId
: Unique ID for the action.currentLocale
(optional): Active locale string, if using localization.currentUser
(optional): Current user object, if available.currentPageUrl
(optional): Path URL path, if known.currentPageDocument
(optional): Document associated with the current page, if known.
label
Display label for the trigger button.
Required
No
Allowed Values
String representing the label.
Default Value
Human-friendly version of the name
property.
icon
Icon to show to the left of the trigger button. If not defined, no icon is shown.
Required
No
Allowed Values
String for the name of the icon.
Fields presented to the user when triggering the action. The value for the fields are available as the inputData
object on the arguments sent to the run
function.
Required
No
Allowed Values
Field definition, matching the visual editor's expected field properties.
The following field types are supported:
string
url
slug
text
markdown
html
number
boolean
date
datetime
color
enum
reference
state
Informs the visual editor of the state of the action, which affects the appearance of the trigger button in the visual editor. This is useful for long-running tasks.
Required
No
Allowed Values
A function that returns a string value designating the proper state.
Supported states:
enabled
running
disabled
hidden
The function parameters match those in run
.