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

Rollups i18n fixes and renamed ES interval errors #23796

Merged
merged 4 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -87,7 +87,7 @@ export const Header = ({
<EuiSpacer size="s" />
{prompt}
</Fragment>
) : ''
) : null
}
<EuiSpacer size="m"/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,18 @@ export class StepIndexPatternComponent extends Component {
if (!query || !query.length || query === '.' || query === '..') {
// This is an error scenario but do not report an error
containsErrors = true;
}
else if (containsIllegalCharacters(query, ILLEGAL_CHARACTERS)) {
} else if (containsIllegalCharacters(query, ILLEGAL_CHARACTERS)) {
const errorMessage = intl.formatMessage(
{
id: 'kbn.management.createIndexPattern.step.invalidCharactersErrorMessage',
defaultMessage: 'A {indexPatternName} cannot contain spaces or the characters: {characterList}'
},
{ characterList, indexPatternName });
{ characterList, indexPatternName }
);

errors.push(errorMessage);
containsErrors = true;
} else if(checkIndices) {
} else if (checkIndices) {
errors.push(...checkIndices);
containsErrors = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ export function updateIndexPatternList(
);
}

export function destroyIndexPatternList() {
export const destroyIndexPatternList = () => {
const node = document.getElementById(INDEX_PATTERN_LIST_DOM_ELEMENT_ID);
node && unmountComponentAtNode(node);
}

};

const indexPatternsResolutions = {
indexPatterns: function (Private) {
Expand Down Expand Up @@ -132,7 +131,7 @@ uiModules.get('apps/management')
updateIndexPatternList($scope, indexPatternCreationOptions, $scope.defaultIndex, $scope.indexPatternList);
};

$scope.$on('$destroy', () => destroyIndexPatternList());
$scope.$on('$destroy', destroyIndexPatternList);
$scope.editingId = $route.current.params.indexPatternId;
$scope.$watch('defaultIndex', () => renderList());
config.bindToScope($scope, 'defaultIndex');
Expand Down
9 changes: 5 additions & 4 deletions src/ui/public/agg_types/buckets/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import _ from 'lodash';

import { i18n } from '@kbn/i18n';
import { toastNotifications } from 'ui/notify';
import '../../validate_date_interval';
import chrome from '../../chrome';
Expand Down Expand Up @@ -98,10 +99,10 @@ export const histogramBucketAgg = new BucketAggType({
});
})
.catch(() => {
toastNotifications.addWarning(`
Unable to retrieve max and min values to auto-scale histogram buckets.
This may lead to poor visualization performance.
`);
toastNotifications.addWarning(i18n.translate('ui.aggTypes.histogram.missingMaxMinValuesWarning', {
defaultMessage: 'Unable to retrieve max and min values to auto-scale histogram buckets.'
+ ' This may lead to poor visualization performance.'
}));
});
},
write: function (aggConfig, output) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import { i18n } from '@kbn/i18n';

const indexPatternTypeName = i18n.translate('common.ui.management.editIndexPattern.createIndex.defaultTypeName',
{ defaultMessage: 'index pattern' });

const indexPatternButtonText = i18n.translate('common.ui.management.editIndexPattern.createIndex.defaultButtonText',
{ defaultMessage: 'Standard index pattern' });

const indexPatternButtonDescription = i18n.translate('common.ui.management.editIndexPattern.createIndex.defaultButtonDescription',
{ defaultMessage: 'Can perform full aggregations against any data' });

Expand Down
6 changes: 2 additions & 4 deletions src/ui/public/utils/parse_es_interval/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
*/

export { parseEsInterval } from './parse_es_interval';
export {
ParseEsIntervalInvalidCalendarIntervalError,
} from './parse_es_interval_invalid_calendar_interval_error';
export { ParseEsIntervalInvalidFormatError } from './parse_es_interval_invalid_format_error';
export { InvalidEsCalendarIntervalError } from './invalid_es_calendar_interval_error';
export { InvalidEsIntervalFormatError } from './invalid_es_interval_format_error';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

export class ParseEsIntervalInvalidCalendarIntervalError extends Error {
export class InvalidEsCalendarIntervalError extends Error {
constructor(
public readonly interval: string,
public readonly value: number,
Expand All @@ -26,19 +26,19 @@ export class ParseEsIntervalInvalidCalendarIntervalError extends Error {
) {
super(`Invalid calendar interval: ${interval}, value must be 1`);

this.name = 'ParseEsIntervalInvalidCalendarIntervalError';
this.name = 'InvalidEsCalendarIntervalError';
this.value = value;
this.unit = unit;
this.type = type;

// captureStackTrace is only available in the V8 engine, so any browser using
// a different JS engine won't have access to this method.
if (Error.captureStackTrace) {
Error.captureStackTrace(this, ParseEsIntervalInvalidCalendarIntervalError);
Error.captureStackTrace(this, InvalidEsCalendarIntervalError);
}

// Babel doesn't support traditional `extends` syntax for built-in classes.
// https://babeljs.io/docs/en/caveats/#classes
Object.setPrototypeOf(this, ParseEsIntervalInvalidCalendarIntervalError.prototype);
Object.setPrototypeOf(this, InvalidEsCalendarIntervalError.prototype);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
* under the License.
*/

export class ParseEsIntervalInvalidFormatError extends Error {
export class InvalidEsIntervalFormatError extends Error {
constructor(public readonly interval: string) {
super(`Invalid interval format: ${interval}`);
this.name = 'ParseEsIntervalInvalidFormatError';
this.name = 'InvalidEsIntervalFormatError';

// captureStackTrace is only available in the V8 engine, so any browser using
// a different JS engine won't have access to this method.
if (Error.captureStackTrace) {
Error.captureStackTrace(this, ParseEsIntervalInvalidFormatError);
Error.captureStackTrace(this, InvalidEsIntervalFormatError);
}

// Babel doesn't support traditional `extends` syntax for built-in classes.
// https://babeljs.io/docs/en/caveats/#classes
Object.setPrototypeOf(this, ParseEsIntervalInvalidFormatError.prototype);
Object.setPrototypeOf(this, InvalidEsIntervalFormatError.prototype);
}
}
12 changes: 6 additions & 6 deletions src/ui/public/utils/parse_es_interval/parse_es_interval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

import { parseEsInterval } from './parse_es_interval';
import { ParseEsIntervalInvalidCalendarIntervalError } from './parse_es_interval_invalid_calendar_interval_error';
import { ParseEsIntervalInvalidFormatError } from './parse_es_interval_invalid_format_error';
import { InvalidEsCalendarIntervalError } from './invalid_es_calendar_interval_error';
import { InvalidEsIntervalFormatError } from './invalid_es_interval_format_error';

describe('parseEsInterval', () => {
it('should correctly parse an interval containing unit and single value', () => {
Expand All @@ -41,28 +41,28 @@ describe('parseEsInterval', () => {
expect(parseEsInterval('7d')).toEqual({ value: 7, unit: 'd', type: 'fixed' });
});

it('should throw a ParseEsIntervalInvalidCalendarIntervalError for intervals containing calendar unit and multiple value', () => {
it('should throw a InvalidEsCalendarIntervalError for intervals containing calendar unit and multiple value', () => {
const intervals = ['4w', '12M', '10y'];
expect.assertions(intervals.length);

intervals.forEach(interval => {
try {
parseEsInterval(interval);
} catch (error) {
expect(error instanceof ParseEsIntervalInvalidCalendarIntervalError).toBe(true);
expect(error instanceof InvalidEsCalendarIntervalError).toBe(true);
}
});
});

it('should throw a ParseEsIntervalInvalidFormatError for invalid interval formats', () => {
it('should throw a InvalidEsIntervalFormatError for invalid interval formats', () => {
const intervals = ['1', 'h', '0m', '0.5h'];
expect.assertions(intervals.length);

intervals.forEach(interval => {
try {
parseEsInterval(interval);
} catch (error) {
expect(error instanceof ParseEsIntervalInvalidFormatError).toBe(true);
expect(error instanceof InvalidEsIntervalFormatError).toBe(true);
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/utils/parse_es_interval/parse_es_interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import dateMath from '@kbn/datemath';

import { ParseEsIntervalInvalidCalendarIntervalError } from './parse_es_interval_invalid_calendar_interval_error';
import { ParseEsIntervalInvalidFormatError } from './parse_es_interval_invalid_format_error';
import { InvalidEsCalendarIntervalError } from './invalid_es_calendar_interval_error';
import { InvalidEsIntervalFormatError } from './invalid_es_interval_format_error';

const ES_INTERVAL_STRING_REGEX = new RegExp(
'^([1-9][0-9]*)\\s*(' + dateMath.units.join('|') + ')$'
Expand Down Expand Up @@ -51,15 +51,15 @@ export function parseEsInterval(interval: string): { value: number; unit: string
.match(ES_INTERVAL_STRING_REGEX);

if (!matches) {
throw new ParseEsIntervalInvalidFormatError(interval);
throw new InvalidEsIntervalFormatError(interval);
}

const value = matches && parseFloat(matches[1]);
const unit = matches && matches[2];
const type = unit && dateMath.unitsMap[unit].type;

if (type === 'calendar' && value !== 1) {
throw new ParseEsIntervalInvalidCalendarIntervalError(interval, value, unit, type);
throw new InvalidEsCalendarIntervalError(interval, value, unit, type);
}

return {
Expand Down
9 changes: 0 additions & 9 deletions src/ui/public/vis/editors/default/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
</div>

<nav class="navbar navbar-default subnav visEditorSidebar__nav">
<div class="visEditorSidebarError" ng-if="sidebar.persistentError">
<call-out
color="'danger'"
iconType="'alert'"
title="sidebar.persistentError"
size="'s'"
/>
</div>

<div class="container-fluid">

<!-- tabs -->
Expand Down
19 changes: 0 additions & 19 deletions src/ui/public/vis/editors/default/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import './vis_options';
import { uiModules } from '../../../modules';
import sidebarTemplate from './sidebar.html';

import './sidebar.less';

uiModules
.get('app/visualize')
.directive('visEditorSidebar', function () {
Expand All @@ -34,8 +32,6 @@ uiModules
scope: true,
controllerAs: 'sidebar',
controller: function ($scope) {
this.persistentError = undefined;

$scope.$watch('vis.type', (visType) => {
if (visType) {
this.showData = visType.schemas.buckets || visType.schemas.metrics;
Expand All @@ -50,21 +46,6 @@ uiModules
this.section = this.section || (this.showData ? 'data' : _.get(visType, 'editorConfig.optionTabs[0].name'));
}
});

// TODO: This doesn't update when requestError is set.
$scope.$watch('vis.requestError', (requestError) => {
if (requestError && requestError.messsage) {
const { message } = requestError;
const isRollupError = message.includes('rollup');

if (isRollupError) {
this.persistentError = message;
return;
}
}

this.persistentError = undefined;
});
}
};
});
3 changes: 0 additions & 3 deletions src/ui/public/vis/editors/default/sidebar.less

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class TabSummaryUi extends Component {
<EuiTitle size="s">
<h3>
<FormattedMessage
id="xpack.rollupJobs.jobDetails.tabSummary.sectionStats.title"
id="xpack.rollupJobs.jobDetails.tabSummary.sectionStatsTitle"
defaultMessage="Stats"
/>
</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import PropTypes from 'prop-types';
import mapValues from 'lodash/object/mapValues';
import cloneDeep from 'lodash/lang/cloneDeep';
import debounce from 'lodash/function/debounce';
import { i18n } from '@kbn/i18n';
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';

import {
Expand Down Expand Up @@ -55,12 +56,24 @@ import {
} from './steps_config';

const stepIdToTitleMap = {
[STEP_LOGISTICS]: 'Logistics',
[STEP_DATE_HISTOGRAM]: 'Date histogram',
[STEP_TERMS]: 'Terms',
[STEP_HISTOGRAM]: 'Histogram',
[STEP_METRICS]: 'Metrics',
[STEP_REVIEW]: 'Review and save',
[STEP_LOGISTICS]: i18n.translate('xpack.rollupJobs.create.stepLogisticsTitle', {
defaultMessage: 'Logistics',
}),
[STEP_DATE_HISTOGRAM]: i18n.translate('xpack.rollupJobs.create.stepDateHistogramTitle', {
defaultMessage: 'Date histogram',
}),
[STEP_TERMS]: i18n.translate('xpack.rollupJobs.create.stepTermsTitle', {
defaultMessage: 'Terms',
}),
[STEP_HISTOGRAM]: i18n.translate('xpack.rollupJobs.create.stepHistogramTitle', {
defaultMessage: 'Histogram',
}),
[STEP_METRICS]: i18n.translate('xpack.rollupJobs.create.stepMetricsTitle', {
defaultMessage: 'Metrics',
}),
[STEP_REVIEW]: i18n.translate('xpack.rollupJobs.create.stepReviewTitle', {
defaultMessage: 'Review and save',
}),
};

export class JobCreateUi extends Component {
Expand Down Expand Up @@ -463,7 +476,7 @@ export class JobCreateUi extends Component {
<EuiTitle size="l">
<h1>
<FormattedMessage
id="xpack.rollupJobs.create.title"
id="xpack.rollupJobs.createTitle"
defaultMessage="Create rollup job"
/>
</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class StepDateHistogramUi extends Component {
<EuiTitle>
<h3>
<FormattedMessage
id="xpack.rollupJobs.create.stepDateHistogram.title"
id="xpack.rollupJobs.create.stepDateHistogramTitle"
defaultMessage="Date histogram"
/>
</h3>
Expand Down Expand Up @@ -337,7 +337,7 @@ export class StepDateHistogramUi extends Component {
<EuiCallOut
title={(
<FormattedMessage
id="xpack.rollupJobs.create.stepDateHistogram.stepError.title"
id="xpack.rollupJobs.create.stepDateHistogram.stepErrorTitle"
defaultMessage="Fix errors before going to next step"
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class StepHistogramUi extends Component {
<EuiTitle>
<h3>
<FormattedMessage
id="xpack.rollupJobs.create.stepHistogram.title"
id="xpack.rollupJobs.create.stepHistogramTitle"
defaultMessage="Histogram (optional)"
/>
</h3>
Expand Down Expand Up @@ -181,7 +181,7 @@ export class StepHistogramUi extends Component {
<EuiTitle size="s">
<h4>
<FormattedMessage
id="xpack.rollupJobs.create.stepHistogram.sectionHistogramInterval.title"
id="xpack.rollupJobs.create.stepHistogram.sectionHistogramIntervalTitle"
defaultMessage="Histogram interval"
/>
</h4>
Expand Down Expand Up @@ -236,7 +236,7 @@ export class StepHistogramUi extends Component {
<EuiCallOut
title={(
<FormattedMessage
id="xpack.rollupJobs.create.stepGroups.stepError.title"
id="xpack.rollupJobs.create.stepGroups.stepErrorTitle"
defaultMessage="Fix errors before going to next step"
/>
)}
Expand Down
Loading