Command extension contributions

Aha! Develop

Command extension contributions run in the context of the browser using the permissions of the user who initiated the command.

Click any of the following links to skip ahead:

Definition

A command is a piece of code that runs in response to a user action like a keyboard shortcut or clicking a button. Command contributions can be invoked from within a view, but they can also be used from the Command Window. The command window is displayed by clicking the Search button and selecting the Commands tab or by using the > keyboard shortcut.

Commands can prompt the user for additional input using the aha.commandPrompt API.

Top

API

aha.on("addLink", async ({ record }, { identifier, settings }) => {
const prUrl = await aha.commandPrompt("Link URL", {
placeholder: "Enter the URL to a pull request",
});

if (!validPrUrl(prUrl)) {
throw new Error("Please enter a valid pull request URL");
}

await withGitHubApi(async (api) => {
const pullRequest = await getPrByUrl(api, prUrl);
await linkPullRequestToRecord(pullRequest, record);
});
});
  • record — for a command triggered from a record, this is a model object representing the record.

  • identifier — set to the string identifier of the extension.

  • settings — the settings for the extension as a JSON object.

Top