Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c7ec189
Merge pull request #1 from elastic/master
Nox911 Sep 24, 2018
fa01b88
Merge pull request #2 from elastic/master
Nox911 Sep 27, 2018
70f6c7e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 27, 2018
68587a0
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 28, 2018
42aa7d3
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
efeaefe
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
5763cbf
translate canvas public lib
Nox911 Oct 3, 2018
9bc28a5
minor fix
Nox911 Oct 3, 2018
5231492
minor fix
Nox911 Oct 3, 2018
f7525fa
minor fix
Nox911 Oct 3, 2018
7641e4d
Fix id names
Nox911 Oct 4, 2018
8a054ed
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 8, 2018
5c0db2f
Merge branch 'master' into feature/translate-canvas-public-lib
Nox911 Oct 9, 2018
b0d1660
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 16, 2018
62b6ad1
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 17, 2018
db3f1fe
Merge branch 'master' into feature/translate-canvas-public-lib
Nox911 Oct 17, 2018
acbad4b
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 18, 2018
a850650
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 22, 2018
0a200ce
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 25, 2018
ed32584
Merge branch 'master' into feature/translate-canvas-public-lib
Nox911 Oct 25, 2018
51958d6
Fix issues
Nox911 Oct 25, 2018
7d5cb7b
Merge branch 'master' into feature/translate-canvas-public-lib
pavel06081991 Nov 2, 2018
c7f9816
Merge branch 'master' into feature/translate-canvas-public-lib
pavel06081991 Nov 6, 2018
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
10 changes: 9 additions & 1 deletion x-pack/plugins/canvas/public/lib/aeroelastic_kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import aero from './aeroelastic';

const stores = new Map();
Expand Down Expand Up @@ -35,7 +36,14 @@ export const aeroelastic = {

getStore(page) {
const store = stores.get(page);
if (!store) throw new Error('An aeroelastic store should exist for page ' + page);
if (!store) {
throw new Error(
i18n.translate('xpack.canvas.aeroelasticKibana.storeDoesNotExistForPageErrorMessage', {
defaultMessage: 'An aeroelastic store should exist for page {page}',
values: { page },
})
);
}

return store.getCurrentState();
},
Expand Down
9 changes: 8 additions & 1 deletion x-pack/plugins/canvas/public/lib/arg_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { includes } from 'lodash';
import { i18n } from '@kbn/i18n';
import { getType } from '../../common/lib/get_type';

/*
Expand All @@ -17,7 +18,13 @@ import { getType } from '../../common/lib/get_type';
// TODO: With the removal of objectified literals in the AST I don't think we need this anymore.

const allowedTypes = ['string', 'number', 'boolean'];
const badType = () => new Error(`Arg setting helpers only support ${allowedTypes.join(',')}`);
const badType = () =>
new Error(
i18n.translate('xpack.canvas.argHelpers.allowedTypesErrorMessage', {
defaultMessage: 'Arg setting helpers only support {allowedTypes}',
values: { allowedTypes: allowedTypes.join(',') },
})
);

const isAllowed = type => includes(allowedTypes, type);

Expand Down
9 changes: 8 additions & 1 deletion x-pack/plugins/canvas/public/lib/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import defaultHeader from './default_header.png';

export function Element(config) {
Expand All @@ -19,7 +20,13 @@ export function Element(config) {
// A sentence or few about what this element does
this.help = config.help;

if (!config.expression) throw new Error('Element types must have a default expression');
if (!config.expression) {
throw new Error(
i18n.translate('xpack.canvas.element.elementTypesDefaultExpressionErrorMessage', {
defaultMessage: 'Element types must have a default expression',
})
);
}
this.expression = config.expression;
this.filter = config.filter;
this.width = config.width || 500;
Expand Down
16 changes: 14 additions & 2 deletions x-pack/plugins/canvas/public/lib/es_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import chrome from 'ui/chrome';
import { i18n } from '@kbn/i18n';
import { API_ROUTE } from '../../common/lib/constants';
import { fetch } from '../../common/lib/fetch';
import { notify } from './notify';
Expand All @@ -21,13 +22,24 @@ export const getFields = (index = '_all') => {
.sort()
)
.catch(err =>
notify.error(err, { title: `Couldn't fetch Elasticsearch fields for '${index}'` })
notify.error(err, {
title: i18n.translate('xpack.canvas.esService.fetchElasticsearchFieldsErrorMessageTitle', {
defaultMessage: "Couldn't fetch Elasticsearch fields for '{index}'",
values: { index },
}),
})
);
};

export const getIndices = () => {
return fetch
.get(`${apiPath}/es_indices`)
.then(({ data: indices }) => indices)
.catch(err => notify.error(err, { title: `Couldn't fetch Elasticsearch indices` }));
.catch(err =>
notify.error(err, {
title: i18n.translate('xpack.canvas.esService.fetchElasticsearchIndicesErrorMessageTitle', {
defaultMessage: "Couldn't fetch Elasticsearch indices",
}),
})
);
};
13 changes: 12 additions & 1 deletion x-pack/plugins/canvas/public/lib/find_expression_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import { datasourceRegistry } from '../expression_types/datasource';
import { transformRegistry } from '../expression_types/transform';
import { modelRegistry } from '../expression_types/model';
Expand Down Expand Up @@ -36,6 +37,16 @@ export function findExpressionType(name, type) {
}
}, []);

if (matches.length > 1) throw new Error(`Found multiple expressions with name "${name}"`);
if (matches.length > 1) {
throw new Error(
i18n.translate(
'xpack.canvas.findExpressionType.multipleExpressionWithTheSameNameErrorMessage',
{
defaultMessage: 'Found multiple expressions with name "{name}"',
values: { name },
}
)
);
}
return matches[0] || null;
}
8 changes: 7 additions & 1 deletion x-pack/plugins/canvas/public/lib/history_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import chrome from 'ui/chrome';
import lzString from 'lz-string';
import { i18n } from '@kbn/i18n';
import { createBrowserHistory, createMemoryHistory, parsePath, createPath } from 'history';
import { get } from 'lodash';
import { APP_ROUTE } from '../../common/lib/constants';
Expand Down Expand Up @@ -52,7 +53,12 @@ function wrapHistoryInstance(history) {
const stateJSON = JSON.stringify(state);
return lzString.compress(stateJSON);
} catch (e) {
throw new Error('Could not encode state: ', e.message);
throw new Error(
i18n.translate('xpack.canvas.historyProvider.encodeStateErrorMessage', {
defaultMessage: 'Could not encode state: {errorMessage}',
values: { errorMessage: e.message },
})
);
}
},

Expand Down
22 changes: 17 additions & 5 deletions x-pack/plugins/canvas/public/lib/legend_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,37 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';

export const legendOptions = [
{
name: 'Hidden',
name: i18n.translate('xpack.canvas.legendOptions.hiddenNameText', {
defaultMessage: 'Hidden',
}),
value: false,
},
{
name: 'Top Left',
name: i18n.translate('xpack.canvas.legendOptions.topLeftNameText', {
defaultMessage: 'Top Left',
}),
value: 'nw',
},
{
name: 'Top Right',
name: i18n.translate('xpack.canvas.legendOptions.topRightNameText', {
defaultMessage: 'Top Right',
}),
value: 'ne',
},
{
name: 'Bottom Left',
name: i18n.translate('xpack.canvas.legendOptions.bottomLeftNameText', {
defaultMessage: 'Bottom Left',
}),
value: 'sw',
},
{
name: 'Bottom Right',
name: i18n.translate('xpack.canvas.legendOptions.bottomRightNameText', {
defaultMessage: 'Bottom Right',
}),
value: 'se',
},
];
12 changes: 11 additions & 1 deletion x-pack/plugins/canvas/public/lib/parse_single_function_chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { get, mapValues, map } from 'lodash';
import { i18n } from '@kbn/i18n';
import { fromExpression } from '../../common/lib/ast';

export function parseSingleFunctionChain(filterString) {
Expand All @@ -13,7 +14,16 @@ export function parseSingleFunctionChain(filterString) {
// Check if the current column is what we expect it to be. If the user changes column this will be called again,
// but we don't want to run setFilter() unless we have to because it will cause a data refresh
const name = get(ast, 'chain[0].function');
if (!name) throw new Error('Could not find function name in chain');
if (!name) {
throw new Error(
i18n.translate(
'xpack.canvas.parseSingleFunctionChain.functionNameInChainNotFindErrorMessage',
{
defaultMessage: 'Could not find function name in chain',
}
)
);
}

const args = mapValues(get(ast, 'chain[0].arguments'), val => {
// TODO Check for literals only
Expand Down
13 changes: 11 additions & 2 deletions x-pack/plugins/canvas/public/lib/router_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import createRouter from '@scant/router';
import { i18n } from '@kbn/i18n';
import { getWindow } from './get_window';
import { historyProvider } from './history_provider';

Expand Down Expand Up @@ -51,8 +52,16 @@ export function routerProvider(routes) {
updateLocation(name, params, state, true);
},
onPathChange(fn) {
if (componentListener != null)
throw new Error('Only one route component listener is allowed');
if (componentListener != null) {
throw new Error(
i18n.translate(
'xpack.canvas.routerProvider.multipleRouteComponentListenersErrorMessage',
{
defaultMessage: 'Only one route component listener is allowed',
}
)
);
}

const execOnMatch = location => {
const { pathname } = location;
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/canvas/public/lib/run_interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import { fromExpression } from '../../common/lib/ast';
import { getType } from '../../common/lib/get_type';
import { interpretAst } from './interpreter';
Expand All @@ -30,7 +31,12 @@ export function runInterpreter(ast, context = null, options = {}) {
});
}

return new Error(`Ack! I don't know how to render a '${getType(renderable)}'`);
return new Error(
i18n.translate('xpack.canvas.runInterpreter.unknownTypeForRenderErrorMessage', {
defaultMessage: "Unknown type '{getType}' for render",
values: { getType: getType(renderable) },
})
);
})
.catch(err => {
notify.error(err);
Expand Down
26 changes: 23 additions & 3 deletions x-pack/plugins/canvas/public/lib/window_error_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import * as knownErrors from '../../common/lib/errors';

const oldHandler = window.onerror;
Expand All @@ -21,10 +22,21 @@ function showError(err) {
};
notice.appendChild(close);

notice.insertAdjacentHTML('beforeend', '<h3>Uncaught error swallowed in dev mode</h3>');
const uncaughtErrorMessage = i18n.translate(
'xpack.canvas.windowErrorHandler.uncaughtErrorIgnoredInDevModeMessage',
{
defaultMessage: 'Uncaught error ignored in dev mode',
}
);

// eslint-disable-next-line no-unsanitized/method
notice.insertAdjacentHTML('beforeend', `<h3>${uncaughtErrorMessage}</h3>`);

const message = document.createElement('p');
message.textContent = `Error: ${err.message}`;
message.textContent = i18n.translate('xpack.canvas.windowErrorHandler.errorMessage', {
defaultMessage: 'Error: {errorMessage}',
values: { errorMessage: err.message },
});
notice.appendChild(message);

if (err.stack) {
Expand All @@ -37,7 +49,15 @@ function showError(err) {
notice.appendChild(stack);
}

notice.insertAdjacentHTML('beforeend', `<p>Check console for more information</p>`);
const checkConsoleMessage = i18n.translate(
'xpack.canvas.windowErrorHandler.checkConsoleMessage',
{
defaultMessage: 'Check console for more information',
}
);

// eslint-disable-next-line no-unsanitized/method
notice.insertAdjacentHTML('beforeend', `<p>${checkConsoleMessage}</p>`);
body.appendChild(notice);
}

Expand Down