Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/update esdocs datasource #59512

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
48dcefa
Initial Commit
maggieghamry Mar 5, 2020
361e8f2
Updates
maggieghamry Mar 6, 2020
6ea9917
Updates II
maggieghamry Mar 6, 2020
352213a
Merge branch 'master' of https://github.com/elastic/kibana into enhan…
maggieghamry Mar 6, 2020
cb85a63
Updates III
maggieghamry Mar 7, 2020
ef3032e
design tweaks
ryankeairns Mar 9, 2020
bc60acb
Merge pull request #2 from ryankeairns/enhancement/update-esdocs-data…
maggieghamry Mar 9, 2020
c1b4884
Adding lucene hyperlink
maggieghamry Mar 9, 2020
2062873
Consollidating datasources to sort
maggieghamry Mar 9, 2020
f4d0074
updates for i18n
maggieghamry Mar 9, 2020
fd77af2
Updates
maggieghamry Mar 17, 2020
b88fd32
Update ui.ts
maggieghamry Mar 17, 2020
6a37a62
Updates for datasource order
maggieghamry Mar 17, 2020
a55d3d8
Update datasource_component.js
maggieghamry Mar 17, 2020
bcecfcb
Update ui.ts
maggieghamry Mar 18, 2020
cd7e713
Update ui.ts
maggieghamry Mar 18, 2020
c96a4b0
Update to Timelion URL
maggieghamry Mar 18, 2020
80f646c
Update ui.ts
maggieghamry Mar 18, 2020
5779d30
Update ui.ts
maggieghamry Mar 18, 2020
f49e3ca
Update ui.ts
maggieghamry Mar 18, 2020
af4694d
Merge branch 'master' into enhancement/update-esdocs-datasource
elasticmachine Mar 18, 2020
7e458a5
i18n updates
maggieghamry Mar 18, 2020
aea06b4
Merge branch 'enhancement/update-esdocs-datasource' of https://github…
maggieghamry Mar 18, 2020
8840013
Merge branch 'master' into enhancement/update-esdocs-datasource
elasticmachine Mar 18, 2020
178704e
Updates
maggieghamry Mar 18, 2020
000ea33
Merge branch 'enhancement/update-esdocs-datasource' of https://github…
maggieghamry Mar 18, 2020
0f4fb1f
Update timelion.js
maggieghamry Mar 18, 2020
5bdb2c1
More i18n updates
maggieghamry Mar 18, 2020
e44347f
Update datasource_component.js
maggieghamry Mar 18, 2020
ba95628
Update ui.ts
maggieghamry Mar 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export const demodata = () => ({
name: 'demodata',
displayName: strings.getDisplayName(),
help: strings.getHelp(),
image: 'logoElasticStack',
image: 'training',
template: templateFromReactComponent(DemodataDatasource),
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@

import React from 'react';
import PropTypes from 'prop-types';
import { EuiFormRow, EuiSelect, EuiTextArea, EuiCallOut, EuiSpacer } from '@elastic/eui';
import { getSimpleArg, setSimpleArg } from '../../lib/arg_helpers';
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 { ExpressionDataSourceStrings } from '../../../i18n';

const { ESDocs: strings } = ExpressionDataSourceStrings;
import {
EuiFormRow,
EuiAccordion,
EuiSelect,
EuiTextArea,
EuiCallOut,
EuiSpacer,
EuiLink,
EuiText,
} from '@elastic/eui';
import { getSimpleArg, setSimpleArg } from '../../../public/lib/arg_helpers';
import { ESFieldsSelect } from '../../../public/components/es_fields_select';
import { ESFieldSelect } from '../../../public/components/es_field_select';
import { ESIndexSelect } from '../../../public/components/es_index_select';
import { templateFromReactComponent } from '../../../public/lib/template_from_react_component';
import { DataSourceStrings, LUCENE_QUERY_URL } from '../../../i18n';

const { ESDocs: strings } = DataSourceStrings;

const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {
const setArg = (name, value) => {
Expand Down Expand Up @@ -74,12 +83,6 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {

return (
<div>
<EuiCallOut size="s" title={strings.getWarningTitle()} iconType="alert" color="warning">
<p>{strings.getWarning()}</p>
</EuiCallOut>

<EuiSpacer size="m" />

<EuiFormRow
label={strings.getIndexTitle()}
helpText={strings.getIndexLabel()}
Expand All @@ -88,18 +91,6 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {
<ESIndexSelect value={index} onChange={index => setArg('index', index)} />
</EuiFormRow>

<EuiFormRow
label={strings.getQueryTitle()}
helpText={strings.getQueryLabel()}
display="rowCompressed"
>
<EuiTextArea
value={getQuery()}
onChange={e => setArg(getArgName(), e.target.value)}
compressed
/>
</EuiFormRow>

<EuiFormRow
label={strings.getFieldsTitle()}
helpText={fields.length <= 10 ? strings.getFieldsLabel() : strings.getFieldsWarningLabel()}
Expand All @@ -112,30 +103,54 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {
/>
</EuiFormRow>

<EuiFormRow
label={strings.getSortFieldTitle()}
helpText={strings.getSortFieldLabel()}
display="columnCompressed"
<EuiSpacer size="s" />
<EuiAccordion
id="accordionAdvancedSettings"
buttonContent="Advanced settings"
className="canvasArg__accordion"
>
<ESFieldSelect
index={index}
value={sortField}
onChange={field => setArg('sort', [field, sortOrder].join(', '))}
/>
</EuiFormRow>
<EuiSpacer size="s" />
<EuiFormRow label={strings.getSortFieldTitle()} display="columnCompressed">
<ESFieldSelect
index={index}
value={sortField}
onChange={field => setArg('sort', [field, sortOrder].join(', '))}
/>
</EuiFormRow>

<EuiFormRow label={strings.getSortOrderTitle()} display="columnCompressed">
<EuiSelect
value={sortOrder.toLowerCase()}
onChange={e => setArg('sort', [sortField, e.target.value].join(', '))}
options={sortOptions}
compressed
/>
</EuiFormRow>

<EuiFormRow
label={strings.getQueryTitle()}
labelAppend={
<EuiText size="xs">
<EuiLink href={LUCENE_QUERY_URL} target="_blank">
{strings.getQueryLabel()}
</EuiLink>
</EuiText>
}
display="rowCompressed"
>
<EuiTextArea
value={getQuery()}
onChange={e => setArg(getArgName(), e.target.value)}
compressed
/>
</EuiFormRow>
</EuiAccordion>

<EuiFormRow
label={strings.getSortOrderTitle()}
helpText={strings.getSortOrderLabel()}
display="columnCompressed"
>
<EuiSelect
value={sortOrder.toLowerCase()}
onChange={e => setArg('sort', [sortField, e.target.value].join(', '))}
options={sortOptions}
compressed
/>
</EuiFormRow>
<EuiSpacer size="m" />

<EuiCallOut size="s" title={strings.getWarningTitle()} iconType="alert" color="warning">
<p>{strings.getWarning()}</p>
</EuiCallOut>
</div>
);
};
Expand All @@ -150,6 +165,6 @@ export const esdocs = () => ({
name: 'esdocs',
displayName: strings.getDisplayName(),
help: strings.getHelp(),
image: 'logoElasticsearch',
image: 'documents',
template: templateFromReactComponent(EsdocsDatasource),
});
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const essql = () => ({
name: 'essql',
displayName: strings.getDisplayName(),
help: strings.getHelp(),
// Replace this with a SQL logo when we have one in EUI
image: 'logoElasticsearch',
image: 'database',
template: templateFromReactComponent(EssqlDatasource),
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { demodata } from './demodata';
import { essql } from './essql';
import { esdocs } from './esdocs';
import { demodata } from './demodata';
import { timelion } from './timelion';

export const datasourceSpecs = [demodata, essql, timelion];
export const datasourceSpecs = [essql, esdocs, demodata, timelion];
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import {
EuiSpacer,
EuiCode,
EuiTextArea,
EuiText,
EuiLink,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getSimpleArg, setSimpleArg } from '../../../public/lib/arg_helpers';
import { templateFromReactComponent } from '../../../public/lib/template_from_react_component';
import { DataSourceStrings, TIMELION, CANVAS } from '../../../i18n';
import { TooltipIcon } from '../../../public/components/tooltip_icon';
import { DataSourceStrings, TIMELION_QUERY_URL, TIMELION, CANVAS } from '../../../i18n';

const { Timelion: strings } = DataSourceStrings;

Expand Down Expand Up @@ -86,8 +87,14 @@ const TimelionDatasource = ({ args, updateArgs, defaultIndex }) => {

<EuiFormRow
label={strings.getQueryLabel()}
helpText={strings.getQueryHelp()}
labelAppend={<TooltipIcon content={strings.getAbout()} />}
labelAppend={
<EuiText size="xs">
<EuiLink href={TIMELION_QUERY_URL} target="_blank">
{strings.queryLabel()}
</EuiLink>
</EuiText>
}
display="rowCompressed"
>
<EuiTextArea
className="canvasTextArea__code"
Expand All @@ -96,6 +103,7 @@ const TimelionDatasource = ({ args, updateArgs, defaultIndex }) => {
rows={15}
/>
</EuiFormRow>

{
// TODO: Time timelion interval picker should be a drop down
}
Expand Down Expand Up @@ -124,6 +132,6 @@ export const timelion = () => ({
name: 'timelion',
displayName: TIMELION,
help: strings.getHelp(),
image: 'timelionApp',
image: 'visTimelion',
template: templateFromReactComponent(TimelionDatasource),
});
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/canvas/i18n/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const JS = 'JavaScript';
export const JSON = 'JSON';
export const KIBANA = 'Kibana';
export const LUCENE = 'Lucene';
export const LUCENE_QUERY_URL = 'https://www.elastic.co/guide/en/kibana/current/lucene-query.html';
export const MARKDOWN = 'Markdown';
export const MOMENTJS = 'MomentJS';
export const MOMENTJS_TIMEZONE_URL = 'https://momentjs.com/timezone/';
Expand All @@ -37,6 +38,7 @@ export const SQL_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-spec.html';
export const SVG = 'SVG';
export const TIMELION = 'Timelion';
export const TIMELION_QUERY_URL = 'https://www.elastic.co/blog/timelion-tutorial-from-zero-to-hero';
export const TINYMATH = '`TinyMath`';
export const TINYMATH_URL =
'https://www.elastic.co/guide/en/kibana/current/canvas-tinymath-functions.html';
Expand Down
84 changes: 0 additions & 84 deletions x-pack/legacy/plugins/canvas/i18n/expression_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import { i18n } from '@kbn/i18n';
import { LUCENE, ELASTICSEARCH } from './constants';

export const ArgTypesStrings = {
Color: {
Expand Down Expand Up @@ -143,86 +142,3 @@ export const ArgTypesStrings = {
}),
},
};

export const ExpressionDataSourceStrings = {
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: 'Query with caution',
}),
getWarning: () =>
i18n.translate('xpack.canvas.expressionTypes.datasources.esdocs.warningDescription', {
defaultMessage: `
This datasource pulls 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.`,
values: {
elasticsearch: ELASTICSEARCH,
},
}),
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',
}),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DemoRows } from '../../../canvas_plugin_src/functions/server/demodata/g
export const help: FunctionHelp<FunctionFactory<typeof demodata>> = {
help: i18n.translate('xpack.canvas.functions.demodataHelpText', {
defaultMessage:
'A mock data set that includes project {ci} times with usernames, countries, and run phases.',
'A sample data set that includes project {ci} times with usernames, countries, and run phases.',
maggieghamry marked this conversation as resolved.
Show resolved Hide resolved
values: {
ci: 'CI',
},
Expand Down
Loading