From 9187941d05045b2f6a149a516d428be54fed1ee2 Mon Sep 17 00:00:00 2001 From: Corey Robertson Date: Wed, 9 Oct 2019 13:58:13 -0400 Subject: [PATCH] [Canvas] Translate More Expression Arguments (#47028) * Translate other canvas arguments * Update Snapshot * Fix incorrect i18n key --- .../canvas/canvas_plugin_src/strings/ui.ts | 18 ++ .../canvas_plugin_src/uis/models/math.js | 9 +- .../canvas_plugin_src/uis/views/metric.js | 2 +- .../plugins/canvas/i18n/expression_types.ts | 221 ++++++++++++++++++ x-pack/legacy/plugins/canvas/i18n/index.ts | 1 + .../expression_types/arg_types/color.js | 7 +- .../container_style/appearance_form.tsx | 12 +- .../arg_types/container_style/border_form.tsx | 11 +- .../container_style/extended_template.tsx | 7 +- .../arg_types/container_style/index.ts | 6 +- .../public/expression_types/arg_types/font.js | 7 +- .../simple_template.examples.storyshot | 15 +- .../series_style/extended_template.tsx | 14 +- .../arg_types/series_style/index.ts | 9 +- .../series_style/simple_template.tsx | 15 +- .../expression_types/datasources/esdocs.js | 41 ++-- 16 files changed, 335 insertions(+), 60 deletions(-) create mode 100644 x-pack/legacy/plugins/canvas/i18n/expression_types.ts diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/strings/ui.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/strings/ui.ts index 776b0738a162..43f204c766bf 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/strings/ui.ts +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/strings/ui.ts @@ -389,6 +389,20 @@ export const DataSourceStrings = { }; export const ModelStrings = { + Math: { + getDisplayName: () => + i18n.translate('xpack.canvas.uis.models.mathTitle', { + defaultMessage: 'Measure', + }), + getValueDisplayName: () => + i18n.translate('xpack.canvas.uis.models.math.args.valueTitle', { + defaultMessage: 'Value', + }), + getValueHelp: () => + i18n.translate('xpack.canvas.uis.models.math.args.valueLabel', { + defaultMessage: 'Function and column to use in extracting a value from the datasource', + }), + }, PointSeries: { getColorDisplayName: () => i18n.translate('xpack.canvas.uis.models.pointSeries.args.colorTitle', { @@ -594,6 +608,10 @@ export const ViewStrings = { i18n.translate('xpack.canvas.uis.views.metricTitle', { defaultMessage: 'Metric', }), + getNumberDisplayName: () => + i18n.translate('xpack.canvas.uis.views.numberArgTitle', { + defaultMessage: 'Number', + }), getLabelDisplayName: () => i18n.translate('xpack.canvas.uis.views.metric.args.labelArgTitle', { defaultMessage: 'Label', diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/models/math.js b/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/models/math.js index 47c43da4a5da..47edded025cd 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/models/math.js +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/models/math.js @@ -6,15 +6,18 @@ import { get } from 'lodash'; import { getState, getValue } from '../../../public/lib/resolved_arg'; +import { ModelStrings } from '../../strings'; + +const { Math: strings } = ModelStrings; export const math = () => ({ name: 'math', - displayName: 'Measure', + displayName: strings.getDisplayName(), args: [ { name: '_', - displayName: 'Value', - help: 'Function and column to use in extracting a value from the datasource', + displayName: strings.getValueDisplayName(), + help: strings.getValueHelp(), argType: 'datacolumn', options: { onlyMath: false, diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/views/metric.js b/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/views/metric.js index b485146272be..6aa7d795ecc3 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/views/metric.js +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/uis/views/metric.js @@ -13,7 +13,7 @@ const { Metric: strings } = ViewStrings; export const metric = () => ({ name: 'metric', displayName: strings.getDisplayName(), - modelArgs: [['_', { label: 'Number' }]], + modelArgs: [['_', { label: strings.getNumberDisplayName() }]], requiresContext: false, args: [ { diff --git a/x-pack/legacy/plugins/canvas/i18n/expression_types.ts b/x-pack/legacy/plugins/canvas/i18n/expression_types.ts new file mode 100644 index 000000000000..8060b49ef1ec --- /dev/null +++ b/x-pack/legacy/plugins/canvas/i18n/expression_types.ts @@ -0,0 +1,221 @@ +/* + * 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 { i18n } from '@kbn/i18n'; +import { LUCENE } from './constants'; + +export const ArgTypesStrings = { + Color: { + getDisplayName: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.colorDisplayName', { + defaultMessage: 'Color', + }), + getHelp: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.colorHelp', { + defaultMessage: 'Color picker', + }), + }, + ContainerStyle: { + getDisplayName: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyleTitle', { + defaultMessage: 'Container style', + }), + getHelp: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyleLabel', { + defaultMessage: 'Tweak the appearance of the element container', + }), + getAppearanceTitle: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.appearanceTitle', { + defaultMessage: 'Appearance', + }), + getBorderTitle: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.borderTitle', { + defaultMessage: 'Border', + }), + getPaddingLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.paddingLabel', { + defaultMessage: 'Padding', + }), + getOpacityLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.opacityLabel', { + defaultMessage: 'Opacity', + }), + getOverflowLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.overflowLabel', { + defaultMessage: 'Overflow', + }), + getOverflowHiddenOption: () => + i18n.translate( + 'xpack.canvas.expressionTypes.argTypes.containerStyle.overflowHiddenDropDown', + { + defaultMessage: 'Hidden', + } + ), + getOverflowVisibleOption: () => + i18n.translate( + 'xpack.canvas.expressionTypes.argTypes.containerStyle.overflowVisibleDropDown', + { + defaultMessage: 'Visible', + } + ), + getThicknessLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.thicknessLabel', { + defaultMessage: 'Thickness', + }), + getStyleLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.styleLabel', { + defaultMessage: 'Style', + }), + getRadiusLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.radiusLabel', { + defaultMessage: 'Radius', + }), + getColorLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.containerStyle.colorLabel', { + defaultMessage: 'Color', + }), + }, + Font: { + getDisplayName: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.fontTitle', { + defaultMessage: 'Text settings', + }), + getHelp: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.fontHelpLabel', { + defaultMessage: 'Set the font, size and color', + }), + }, + SeriesStyle: { + getDisplayName: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyleTitle', { + defaultMessage: 'Series style', + }), + getHelp: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyleLabel', { + defaultMessage: 'Set the style for a selected named series', + }), + getColorLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.colorLabel', { + defaultMessage: 'Color', + }), + getStyleLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.styleLabel', { + defaultMessage: 'Style', + }), + getRemoveAriaLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.removeAriaLabel', { + defaultMessage: 'Remove Series Color', + }), + getNoSeriesTooltip: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.noSeriesTooltip', { + defaultMessage: 'Data has no series to style, add a color dimension', + }), + getSeriesIdentifierLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.seriesIdentifierLabel', { + defaultMessage: 'Series Identifier', + }), + getSelectSeriesOption: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.selectSeriesDropDown', { + defaultMessage: 'Select Series', + }), + getLineLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.lineLabel', { + defaultMessage: 'Line', + }), + getBarLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.barLabel', { + defaultMessage: 'Bar', + }), + getPointLabel: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.pointLabel', { + defaultMessage: 'Point', + }), + getNoneOption: () => + i18n.translate('xpack.canvas.expressionTypes.argTypes.seriesStyle.noneDropDown', { + defaultMessage: 'None', + }), + }, +}; + +export const DataSourceStrings = { + ESDocs: { + getDisplayName: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocsTitle', { + defaultMessage: 'Elasticsearch raw documents', + }), + getHelp: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocsLabel', { + defaultMessage: 'Pull back raw documents from elasticsearch', + }), + getWarningTitle: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.warningTitle', { + defaultMessage: 'Be careful', + }), + getWarning: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.warningDescription', { + defaultMessage: ` + The Elasticsearch Docs datasource is used to pull documents directly from Elasticsearch + without the use of aggregations. It is best used with low volume datasets and in + situations where you need to view raw documents or plot exact, non-aggregated values on a + chart.`, + }), + getIndexTitle: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.indexTitle', { + defaultMessage: 'Index', + }), + getIndexLabel: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.indexLabel', { + defaultMessage: 'Enter an index name or select an index pattern', + }), + getQueryTitle: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.queryTitle', { + defaultMessage: 'Query', + }), + getQueryLabel: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.queryLabel', { + defaultMessage: '{lucene} query string syntax', + values: { + lucene: LUCENE, + }, + }), + getSortFieldTitle: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.sortFieldTitle', { + defaultMessage: 'Sort Field', + }), + getSortFieldLabel: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.sortFieldLabel', { + defaultMessage: 'Document sort field', + }), + getSortOrderTitle: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.sortOrderTitle', { + defaultMessage: 'Sort Order', + }), + getSortOrderLabel: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.sortOrderLabel', { + defaultMessage: 'Document sort order', + }), + getFieldsTitle: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.fieldsTitle', { + defaultMessage: 'Fields', + }), + getFieldsLabel: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.fieldsLabel', { + defaultMessage: 'The fields to extract. Kibana scripted fields are not currently available', + }), + getFieldsWarningLabel: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.fieldsWarningLabel', { + defaultMessage: 'This datasource performs best with 10 or fewer fields', + }), + getAscendingOption: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.ascendingDropDown', { + defaultMessage: 'Ascending', + }), + getDescendingOption: () => + i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.descendingDropDown', { + defaultMessage: 'Descending', + }), + }, +}; diff --git a/x-pack/legacy/plugins/canvas/i18n/index.ts b/x-pack/legacy/plugins/canvas/i18n/index.ts index 5b01bb228bfa..e0cd736dac07 100644 --- a/x-pack/legacy/plugins/canvas/i18n/index.ts +++ b/x-pack/legacy/plugins/canvas/i18n/index.ts @@ -10,6 +10,7 @@ export * from './angular'; export * from './components'; export * from './constants'; export * from './errors'; +export * from './expression_types'; export * from './shortcuts'; export * from './units'; diff --git a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/color.js b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/color.js index 9bb7995ad03f..2a47150b4a1b 100644 --- a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/color.js +++ b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/color.js @@ -9,6 +9,9 @@ import PropTypes from 'prop-types'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { templateFromReactComponent } from '../../lib/template_from_react_component'; import { ColorPickerPopover } from '../../components/color_picker_popover'; +import { ArgTypesStrings } from '../../../i18n'; + +const { Color: strings } = ArgTypesStrings; const ColorArgInput = ({ onValueChange, argValue, workpad }) => ( @@ -28,8 +31,8 @@ ColorArgInput.propTypes = { export const color = () => ({ name: 'color', - displayName: 'Color', - help: 'Color picker', + displayName: strings.getDisplayName(), + help: strings.getHelp(), simpleTemplate: templateFromReactComponent(ColorArgInput), default: '#000000', }); diff --git a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/appearance_form.tsx b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/appearance_form.tsx index 1218f9274c91..98ee007e8d3b 100644 --- a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/appearance_form.tsx +++ b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/appearance_form.tsx @@ -7,7 +7,9 @@ import React, { FunctionComponent, ChangeEvent } from 'react'; import PropTypes from 'prop-types'; import { EuiFieldNumber, EuiFlexGroup, EuiFlexItem, EuiFormRow, EuiSelect } from '@elastic/eui'; +import { ArgTypesStrings } from '../../../../i18n'; +const { ContainerStyle: strings } = ArgTypesStrings; type Overflow = 'hidden' | 'visible'; export interface Arguments { @@ -23,8 +25,8 @@ interface Props extends Arguments { } const overflows: Array<{ value: Overflow; text: string }> = [ - { value: 'hidden', text: 'Hidden' }, - { value: 'visible', text: 'Visible' }, + { value: 'hidden', text: strings.getOverflowHiddenOption() }, + { value: 'visible', text: strings.getOverflowVisibleOption() }, ]; const opacities = [ @@ -59,12 +61,12 @@ export const AppearanceForm: FunctionComponent = ({ return ( - + - + = ({ - + (arg: T, val: ArgumentTypes[T]) => void; value: string; @@ -72,7 +75,7 @@ export const BorderForm: FunctionComponent = ({ return ( - + = ({ - + = ({ - + = ({ - + ; export type Argument = keyof ArgumentTypes; +const { ContainerStyle: strings } = ArgTypesStrings; + interface Props { getArgValue: (arg: T) => Arguments[T]; setArgValue: (arg: T, val: ArgumentTypes[T]) => void; @@ -32,7 +35,7 @@ export const ExtendedTemplate: FunctionComponent = ({ }) => (
-
Appearance
+
{strings.getAppearanceTitle()}
@@ -44,7 +47,7 @@ export const ExtendedTemplate: FunctionComponent = ({ /> -
Border
+
{strings.getBorderTitle()}
diff --git a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/index.ts b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/index.ts index c465c3fa35c3..d7a2001c5d87 100644 --- a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/index.ts +++ b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/container_style/index.ts @@ -11,8 +11,10 @@ import { get } from 'lodash'; import { templateFromReactComponent } from '../../../lib/template_from_react_component'; import { Arguments as SimpleArguments, SimpleTemplate } from './simple_template'; import { Arguments as ExtendedArguments, ExtendedTemplate } from './extended_template'; +import { ArgTypesStrings } from '../../../../i18n'; const { set } = immutable; +const { ContainerStyle: strings } = ArgTypesStrings; interface Arguments extends SimpleArguments, ExtendedArguments {} type ArgumentTypes = Partial; @@ -43,8 +45,8 @@ const wrap = (Component: ComponentType) => export const containerStyle = () => ({ name: 'containerStyle', - displayName: 'Container style', - help: 'Tweak the appearance of the element container', + displayName: strings.getDisplayName(), + help: strings.getHelp(), default: '{containerStyle}', simpleTemplate: templateFromReactComponent(wrap(SimpleTemplate)), template: templateFromReactComponent(wrap(ExtendedTemplate)), diff --git a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/font.js b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/font.js index ed1bf29e2514..893caba1465b 100644 --- a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/font.js +++ b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/font.js @@ -10,6 +10,9 @@ import { get, mapValues, set } from 'lodash'; import { openSans } from '../../../common/lib/fonts'; import { templateFromReactComponent } from '../../lib/template_from_react_component'; import { TextStylePicker } from '../../components/text_style_picker'; +import { ArgTypesStrings } from '../../../i18n'; + +const { Font: strings } = ArgTypesStrings; export const FontArgInput = props => { const { onValueChange, argValue, workpad } = props; @@ -53,8 +56,8 @@ FontArgInput.displayName = 'FontArgInput'; export const font = () => ({ name: 'font', - displayName: 'Text settings', - help: 'Set the font, size and color', + displayName: strings.getDisplayName(), + help: strings.getHelp(), template: templateFromReactComponent(FontArgInput), default: `{font size=14 family="${openSans.value}" color="#000000" align=left}`, }); diff --git a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot index 0ad9e8879b41..6a27d784ef06 100644 --- a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot +++ b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/__examples__/__snapshots__/simple_template.examples.storyshot @@ -19,7 +19,8 @@ exports[`Storyshots arguments/SeriesStyle simple 1`] = `
- Color  + Color +  
- Color  + Color +  
- Color  + Color +  
- Color  + Color +  
- Color  + Color +  
= props => { // TODO: add fill and stack options // TODO: add label name auto-complete const values = [ - { value: 0, text: 'None' }, + { value: 0, text: strings.getNoneOption() }, { value: 1, text: '1' }, { value: 2, text: '2' }, { value: 3, text: '3' }, @@ -67,14 +69,14 @@ export const ExtendedTemplate: FunctionComponent = props => { { value: 5, text: '5' }, ]; - const labelOptions = [{ value: '', text: 'Select Series' }]; + const labelOptions = [{ value: '', text: strings.getSelectSeriesOption() }]; labels.sort().forEach(val => labelOptions.push({ value: val, text: val })); return (
{name !== 'defaultStyle' && ( - + = props => { {fields.includes('lines') && ( - + = props => { )} {fields.includes('bars') && ( - + = props => { )} {fields.includes('points') && ( - + { if (typeof label !== 'string') { props.renderError(); } - return `Style: ${label}`; + return `${strings.getStyleLabel()}: ${label}`; }; const EnhancedExtendedTemplate = compose( @@ -51,8 +54,8 @@ EnhancedExtendedTemplate.propTypes = { export const seriesStyle = () => ({ name: 'seriesStyle', - displayName: 'Series style', - help: 'Set the style for a selected named series', + displayName: strings.getDisplayName(), + help: strings.getHelp(), template: templateFromReactComponent(EnhancedExtendedTemplate), simpleTemplate: templateFromReactComponent(SimpleTemplate), default: '{seriesStyle}', diff --git a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/simple_template.tsx b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/simple_template.tsx index 4d51f9a656b0..941878dc11c3 100644 --- a/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/simple_template.tsx +++ b/x-pack/legacy/plugins/canvas/public/expression_types/arg_types/series_style/simple_template.tsx @@ -12,8 +12,10 @@ import { get } from 'lodash'; import { ColorPickerPopover } from '../../../components/color_picker_popover'; import { TooltipIcon, IconType } from '../../../components/tooltip_icon'; import { ExpressionAST, CanvasWorkpad } from '../../../../types'; +import { ArgTypesStrings } from '../../../../i18n'; const { set, del } = immutable; +const { SeriesStyle: strings } = ArgTypesStrings; interface Arguments { color: string; @@ -48,11 +50,14 @@ export const SimpleTemplate: FunctionComponent = props => { {!color || color.length === 0 ? ( - Color  + {strings.getColorLabel()}  - handleChange('color', '#000000')}> + handleChange('color', '#000000')} + > Auto @@ -62,7 +67,7 @@ export const SimpleTemplate: FunctionComponent = props => { @@ -78,7 +83,7 @@ export const SimpleTemplate: FunctionComponent = props => { iconType="cross" color="danger" onClick={() => handleChange('color', '')} - aria-label="Remove Series Color" + aria-label={strings.getRemoveAriaLabel()} /> @@ -88,7 +93,7 @@ export const SimpleTemplate: FunctionComponent = props => { )} diff --git a/x-pack/legacy/plugins/canvas/public/expression_types/datasources/esdocs.js b/x-pack/legacy/plugins/canvas/public/expression_types/datasources/esdocs.js index ced1c51496d4..57ae8c28835e 100644 --- a/x-pack/legacy/plugins/canvas/public/expression_types/datasources/esdocs.js +++ b/x-pack/legacy/plugins/canvas/public/expression_types/datasources/esdocs.js @@ -12,6 +12,9 @@ import { ESFieldsSelect } from '../../components/es_fields_select'; import { ESFieldSelect } from '../../components/es_field_select'; import { ESIndexSelect } from '../../components/es_index_select'; import { templateFromReactComponent } from '../../lib/template_from_react_component'; +import { DataSourceStrings } from '../../../i18n'; + +const { ESDocs: strings } = DataSourceStrings; const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => { const setArg = (name, value) => { @@ -64,36 +67,38 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => { setArg('index', defaultIndex); } - const sortOptions = [{ value: 'asc', text: 'Ascending' }, { value: 'desc', text: 'Descending' }]; + const sortOptions = [ + { value: 'asc', text: strings.getAscendingOption() }, + { value: 'desc', text: strings.getDescendingOption() }, + ]; return (
- -

- The Elasticsearch Docs datasource is used to pull documents directly from Elasticsearch - without the use of aggregations. It is best used with low volume datasets and in - situations where you need to view raw documents or plot exact, non-aggregated values on a - chart. -

+ +

{strings.getWarning()}

- + setArg('index', index)} /> - + setArg(getArgName(), e.target.value)} /> - + setArg('sort', [field, sortOrder].join(', '))} /> - + setArg('sort', [sortField, e.target.value].join(', '))} @@ -101,12 +106,8 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => { /> ({ name: 'esdocs', - displayName: 'Elasticsearch raw documents', - help: 'Pull back raw documents from elasticsearch', + displayName: strings.getDisplayName(), + help: strings.getHelp(), image: 'logoElasticsearch', template: templateFromReactComponent(EsdocsDatasource), });