kibana/examples/expressions_explorer/public/functions/button.ts
Luke Elmers b6287708f6
Adds AGPL 3.0 license (#192025)
Updates files outside of x-pack to be triple-licensed under Elastic
License 2.0, AGPL 3.0, or SSPL 1.0.
2024-09-06 19:02:41 -06:00

57 lines
1.5 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { i18n } from '@kbn/i18n';
import { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
interface Arguments {
color: string;
href: string;
name: string;
}
export type ExpressionFunctionButton = ExpressionFunctionDefinition<
'button',
unknown,
Arguments,
unknown
>;
export const buttonFn: ExpressionFunctionButton = {
name: 'button',
args: {
color: {
help: i18n.translate('expressions.functions.button.args.color', {
defaultMessage: 'Color of the button',
}),
},
href: {
help: i18n.translate('expressions.functions.button.args.href', {
defaultMessage: 'Link to which to navigate',
}),
types: ['string'],
required: true,
},
name: {
help: i18n.translate('expressions.functions.button.args.name', {
defaultMessage: 'Name of the button',
}),
types: ['string'],
default: 'button',
},
},
help: 'Configures the button',
fn: (input: unknown, args: Arguments) => {
return {
type: 'render',
as: 'button',
value: args,
};
},
};