kibana/x-pack/legacy/plugins/canvas/public/functions/asset.js
Catherine Liu 0166246fb8
[Canvas][Docs] Merge Canvas function references (#38300)
* Synced up docs with function defs

* Updated docs with changes from PR #37305

* Merged canvas function ref into a single doc

* Fixed arg order

* Fixed typo

* Added alphabet links

* Added alphabet headers

* Removed B header

* Added missing args from

* Added edits from PR #37614

* Updated containerStyle

* Removed metafields. ESSQL doesn't support retrieving metafields

* Edits to function copy

* More edits

* More edits

* Final round of edits

* Fixed i18n errors

* Addressing feedback

* Fixed jest test

* Fixed missing import

* Fixed i18n error

* Restored metaFields arg in esdocs

* Extracted i18n string constants

* Fixed i18n errors

* Updated translation files
2019-07-11 14:47:56 -07:00

35 lines
959 B
JavaScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getState } from '../state/store';
import { getAssetById } from '../state/selectors/assets';
export const asset = () => ({
name: 'asset',
aliases: [],
type: 'string',
help: 'Retrieves Canvas workpad asset objects to provide as argument values. Usually images.',
context: {
types: ['null'],
},
args: {
id: {
aliases: ['_'],
types: ['string'],
help: 'The ID of the asset to retrieve.',
required: true,
},
},
fn: (_context, args) => {
const assetId = args.id;
const asset = getAssetById(getState(), assetId);
if (asset !== undefined) {
return asset.value;
}
throw new Error('Could not get the asset by ID: ' + assetId);
},
});