Bug 1965130 - set JSDoc types and providerName for ActionsResult r=urlbar-reviewers,Standard8
Defines and/or updates JSDoc types on all ActionsResult properties. The pre-existing property `ActionsResult.providerName` never gets set. `Query.add` sets a `providerName` on UrlbarResult objects, so to follow that pattern, I made `ProviderGlobalActions.startQuery` responsible for setting `providerName` on already constructed `ActionsResult` instances. Having the provider name available for actions results will make it easier for tests to find relevant actions results within search results. Differential Revision: https://phabricator.services.mozilla.com/D248373
This commit is contained in:
committed by
sthompson@mozilla.com
parent
0bd8d7ae2e
commit
fdf96a1cd2
@@ -10,6 +10,7 @@ export class ActionsProvider {
|
||||
* Unique name for the provider.
|
||||
*
|
||||
* @abstract
|
||||
* @returns {string}
|
||||
*/
|
||||
get name() {
|
||||
return "ActionsProviderBase";
|
||||
@@ -32,7 +33,7 @@ export class ActionsProvider {
|
||||
* Query for actions based on the current users input.
|
||||
*
|
||||
* @param {UrlbarQueryContext} _queryContext The query context object.
|
||||
* @returns {Array} An array of ActionResult's
|
||||
* @returns {Promise<ActionsResult[]>}
|
||||
* @abstract
|
||||
*/
|
||||
async queryActions(_queryContext) {
|
||||
@@ -44,7 +45,7 @@ export class ActionsProvider {
|
||||
*
|
||||
* @param {UrlbarQueryContext} _queryContext The query context object.
|
||||
* @param {UrlbarController} _controller The urlbar controller.
|
||||
* @param {DOMElement} _element The element that was selected.
|
||||
* @param {Element} _element The element that was selected.
|
||||
* @abstract
|
||||
*/
|
||||
pickAction(_queryContext, _controller, _element) {
|
||||
@@ -56,6 +57,10 @@ export class ActionsProvider {
|
||||
* Class used to create an Actions Result.
|
||||
*/
|
||||
export class ActionsResult {
|
||||
/**
|
||||
* @type {string}
|
||||
* The name of the `ActionsProvider` that provided this actions result.
|
||||
*/
|
||||
providerName;
|
||||
|
||||
#key;
|
||||
@@ -70,22 +75,22 @@ export class ActionsResult {
|
||||
/**
|
||||
* @param {object} options
|
||||
* An option object.
|
||||
* @param { string } options.key
|
||||
* @param {string} options.key
|
||||
* A string key used to distinguish between different actions.
|
||||
* @param { string } options.l10nId
|
||||
* @param {string} options.l10nId
|
||||
* The id of the l10n string displayed in the action button.
|
||||
* @param { string } options.l10nArgs
|
||||
* @param {{[arg: string]: any}} [options.l10nArgs]
|
||||
* Arguments passed to construct the above string
|
||||
* @param { string } options.icon
|
||||
* @param {string} options.icon
|
||||
* The icon displayed in the button.
|
||||
* @param {object} options.dataset
|
||||
* @param {{[key: string]: any}} [options.dataset]
|
||||
* An object of properties we set on the action button that
|
||||
* can be used to pass data when it is selected.
|
||||
* @param { Function} options.onPick
|
||||
* @param {(context: UrlbarQueryContext, controller: UrlbarController) => void} options.onPick
|
||||
* A callback function called when the result has been picked.
|
||||
* @param { Function} options.onSelection
|
||||
* @param {(result: UrlbarResult, resultElement: Element) => void} [options.onSelection]
|
||||
* A callback function called when the result has been selected.
|
||||
* @param { Function} options.engine
|
||||
* @param {string} [options.engine]
|
||||
* The name of an installed engine if the action prompts search mode.
|
||||
*/
|
||||
constructor({
|
||||
|
||||
@@ -78,6 +78,7 @@ class ProviderGlobalActions extends UrlbarProvider {
|
||||
// We only allow one action that provides an engine search mode.
|
||||
continue;
|
||||
}
|
||||
action.providerName = provider.name;
|
||||
actionsResults.push(action);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user