Skip to main content

Actions

Overview

Action is a piece of code executed on some kind of user action, be it mouse click or shortcut press.

In UI list of actions is displayed in the Action Panel.

Actions can be executed using shortcuts, custom and predefined ones. First and second actions in Action Panel become primary and secondary actions respectively. Primary action gets automatically assigned Enter shortcut and secondary - Shift + Enter. Even though it is still possible to assign custom shortcuts to primary and secondary actions, they will not be visible in action panel in UI

Actions can be defined for entrypoints or views.

Actions in Generated Entrypoints

See Entrypoint Generator

Actions in View and Command Entrypoints

For "view" and "command" entrypoints, currently, it is not possible to define additional actions. The file referenced in manifest becomes primary action

Actions inside Views

Actions in views are often context-aware, e.g. based on the selected list item. Actions in Action Panel can be grouped into semantic sections and have keyboard shortcuts assigned.

View Api Reference

ActionPanel

Props

NameIs RequiredTypeDescription
titleOptionalstringText displayed in UI on top of the popup

Children components (order-sensitive)

Available order-sensitive React children components. The order in which these elements are be placed in code will be reflected in UI

NameReact Component TypeAmount
Action<Action/>Zero or More
Section<ActionPanelSection/>Zero or More

ActionPanel.Action

Adds action entry to the action panel. Can be executed either by clicking the button or by pressing the shortcut

Example

import { ReactElement } from "react";
import { ActionPanel, List } from "@project-gauntlet/api/components";

export default function View(): ReactElement {
return (
<List actions={
<ActionPanel title={"Title"}>
<ActionPanel.Action
label={"Primary action"}
onAction={id => {
console.log(`Primary action for item with id '${id}' was executed`)
// returning object with close property set to true will close the window
return { close: true }
}}
/>
<ActionPanel.Action
label={"Secondary action"}
onAction={id => console.log(`Secondary action for item with id '${id}' was executed`)}
/>
<ActionPanel.Action
id="actionId"
label={"Another action"}
onAction={id => console.log(`Another action for item with id '${id}' was executed`)}
/>
</ActionPanel>
}>
<List.Item id={"item"} title={"Item"}/>
</List>
)
}

Gauntlet Screenshot

Props

NameIs RequiredTypeDescription
idOptionalstringThe identifier of an action. Referenced in plugin manifest to assign shortcut to button in UI
labelRequiredstringText displayed in UI on button
onActionRequired() => voidFunction that is called when action button is clicked or the shortcut is pressed (including primary and secondary shortcuts). ID parameter is an id of currently focused grid or list item. Returning `{ close: true }` object from the action will close the window

ActionPanel.Section

Action Panel Section groups multiple Actions together under the one name

Props

NameIs RequiredTypeDescription
titleOptionalstringText displayed in UI in popup on top of the section

Children components (order-sensitive)

Available order-sensitive React children components. The order in which these elements are be placed in code will be reflected in UI

NameReact Component TypeAmount
Action<Action/>Zero or More

ActionPanel.Section.Action

Example

import { ReactElement } from "react";
import { ActionPanel, List } from "@project-gauntlet/api/components";

export default function View(): ReactElement {
return (
<List actions={
<ActionPanel title="Action Panel Title">
<ActionPanel.Action
label="Primary action"
onAction={id => console.log(`Primary action for item with id '${id}' was executed`)}
/>
<ActionPanel.Section title="Section title">
<ActionPanel.Action
label="Secondary action"
onAction={id => console.log(`Secondary action for item with id '${id}' was executed`)}
/>
<ActionPanel.Action
label="Another action"
onAction={id => console.log(`Another action for item with id '${id}' was executed`)}
/>
</ActionPanel.Section>
<ActionPanel.Section title="Another Section title">
<ActionPanel.Action
label="Yet another action"
onAction={id => console.log(`Yet another action for item with id '${id}' was executed`)}
/>
</ActionPanel.Section>
</ActionPanel>
}>
<List.Item id={"item"} title={"Item"}/>
</List>
)
}
Gauntlet Screenshot