[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationQuick actions

Quick actions

A quick action is a shortcut a backend module adds to the dashboard's command palette and header menu. Categories, actions, targets, and how access is computed.

A quick action is a shortcut a backend module adds to the dashboard. The command palette and the quick actions menu in the dashboard header both list it. Each action has a label, belongs to a category, and points at a registered page. Running it opens that page, opens a table's creation form, presses a table toolbar button, or emits an event. Actions register when their file is imported. Access follows the target page, and for a form or a button, the permission of what it opens.

Both functions live in @antelopejs/interface-dms/quick-actions.

Declare a category and its actions

QuickActionCategory(id, info) registers a category, and QuickAction(id, info) registers an action in it. Both return the registered record. Register the category first, because registering an action whose category is unknown throws QuickAction category "<id>" is not registered. Register the category before its actions.

This example assumes your application exports a registered TasksPage from ./pages/tasks.

typescript
import { TasksPage } from "./pages/tasks";
import {
  QuickAction,
  QuickActionCategory,
} from "@antelopejs/interface-dms/quick-actions";

const tasks = QuickActionCategory("tasks", {
  displayName: "$my_app.quick_actions.tasks",
  icon: "i-ph-check-square",
  order: 10,
});

QuickAction("tasks-new", {
  category: tasks,
  displayName: "$my_app.quick_actions.tasks_new",
  icon: "i-ph-plus",
  target: { type: "navigate", page: TasksPage },
});

An action's key is its category id and its own id, so the same action id may appear under two categories. Registering a category id or an action key that is already taken keeps the first registration.

Declare quick actions in a file your module imports, next to the pages they point at, so the registrations run at import time.

QuickActionCategoryInfo

FieldTypeDescription
idstringCategory id. Passed as the first argument of QuickActionCategory, not inside info.
displayNamestringCategory label. Required.
iconstringIcon name.
ordernumberSort order among categories, ascending. A missing order counts as 0.

QuickActionInfo

FieldTypeDescription
idstringAction id. Passed as the first argument of QuickAction, not inside info.
categoryQuickActionCategoryInfoThe record QuickActionCategory returned. Required.
displayNamestringAction label. Required.
iconstringIcon name. Required.
ordernumberSort order within the category, ascending. A missing order counts as 0.
targetQuickActionTargetWhat running the action does. Required.

Access

The DMS computes access per caller from the target page, including its permission and its tenant access gate (Permissions). An openForm target also checks the permission of the selected table's add action. A button target also checks the button's own permission, and a button with no permission adds no check. A quick action has no permission property of its own. Configure access on the page, the table or the button it points at.

The DMS leaves out an action the caller cannot run, and a category whose actions were all left out. It also leaves out, with a server warning, an action whose target cannot be resolved:

  • The target page is not a registered page.
  • An explicit component is not mounted on the page.
  • component is omitted and the page has no matching component or several of them.
  • The button is not declared by the selected component.

QuickActionTarget

Every target requires page, the registered page controller class. The DMS derives the frontend route from that page, so a renamed route does not leave a stale URL in the action.

VariantFieldsEffect
"navigate"page, optional queryNavigates to the page, with optional string query parameters.
"openForm"page, optional componentNavigates to the page and opens a table's creation form. Pass component when the page mounts more than one component that can create a row.
"button"page, button, optional componentNavigates to the page and presses the table toolbar button whose id is button, for example to open the modal it opens. Pass component when several components of the page declare that button id.
"event"page, name, optional payloadDispatches a window CustomEvent named name on the current page, with payload as its detail. It does not navigate. page only sets who can see the action.

The following examples assume a registered BooksPage with a TableView in its static table field. For a nested table, pass a target such as BooksPage.content.targetChild("table") instead.

typescript
import { BooksPage } from "./pages/books";
import {
  QuickAction,
  QuickActionCategory,
} from "@antelopejs/interface-dms/quick-actions";

const catalog = QuickActionCategory("catalog", {
  displayName: "$my_app.quick_actions.catalog",
  icon: "i-ph-books",
});

QuickAction("catalog-new-book", {
  category: catalog,
  displayName: "$my_app.quick_actions.new_book",
  icon: "i-ph-plus",
  target: { type: "openForm", page: BooksPage, component: BooksPage.table },
});

QuickAction("catalog-import", {
  category: catalog,
  displayName: "$my_app.quick_actions.import_books",
  icon: "i-ph-upload",
  target: { type: "button", page: BooksPage, button: "import" },
});

QuickAction("catalog-refresh", {
  category: catalog,
  displayName: "$my_app.quick_actions.refresh",
  icon: "i-ph-arrows-clockwise",
  target: { type: "event", page: BooksPage, name: "catalog:refresh", payload: { force: true } },
});

The catalog-import action assumes that BooksPage.table declares a custom button with id: "import" in its customButtons.

Layout banners covers messages under the dashboard header, the other global place a backend module adds to.