Skip to content

Commit

Permalink
Merge branch 'feature/translate-courier' into feature/translate-query…
Browse files Browse the repository at this point in the history
…_bar
  • Loading branch information
Nox911 committed Dec 3, 2018
2 parents 9246e8a + a776bfa commit 2e9f16e
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 22 deletions.
7 changes: 6 additions & 1 deletion src/ui/public/courier/fetch/call_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { IsRequestProvider } from './is_request';
import { MergeDuplicatesRequestProvider } from './merge_duplicate_requests';
import { RequestStatus } from './req_status';
import { SerializeFetchParamsProvider } from './request/serialize_fetch_params';
import { i18n } from '@kbn/i18n';

export function CallClientProvider(Private, Promise, es, config) {
const errorAllowExplicitIndex = Private(ErrorAllowExplicitIndexProvider);
Expand Down Expand Up @@ -95,7 +96,11 @@ export function CallClientProvider(Private, Promise, es, config) {
// handle a request being aborted while being fetched
const requestWasAborted = Promise.method(function (searchRequest, index) {
if (searchRequestsAndStatuses[index] === ABORTED) {
defer.reject(new Error('Request was aborted twice?'));
defer.reject(new Error(
i18n.translate('common.ui.courier.fetch.requestWasAbortedTwiceErrorMessage', {
defaultMessage: 'Request was aborted twice?',
})
));
}

requestsToFetchCount--;
Expand Down
10 changes: 8 additions & 2 deletions src/ui/public/courier/fetch/call_response_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { toastNotifications } from '../../notify';
import { RequestFailure } from '../../errors';
import { RequestStatus } from './req_status';
import { SearchError } from '../search_strategy/search_error';
import { i18n } from '@kbn/i18n';

export function CallResponseHandlersProvider(Private, Promise) {
const ABORTED = RequestStatus.ABORTED;
Expand All @@ -36,13 +37,18 @@ export function CallResponseHandlersProvider(Private, Promise) {

if (response.timed_out) {
toastNotifications.addWarning({
title: 'Data might be incomplete because your request timed out',
title: i18n.translate('common.ui.courier.fetch.requestTimedOutNotificationMessage', {
defaultMessage: 'Data might be incomplete because your request timed out',
})
});
}

if (response._shards && response._shards.failed) {
toastNotifications.addWarning({
title: `${response._shards.failed} of ${response._shards.total} shards failed`,
title: i18n.translate('common.ui.courier.fetch.shardsFailedNotificationMessage', {
defaultMessage: '{shardsFailed} of {shardsTotal} shards failed',
values: { shardsFailed: response._shards.failed, shardsTotal: response._shards.total }
})
});
}

Expand Down
7 changes: 6 additions & 1 deletion src/ui/public/courier/fetch/fetch_now.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { CallClientProvider } from './call_client';
import { CallResponseHandlersProvider } from './call_response_handlers';
import { ContinueIncompleteProvider } from './continue_incomplete';
import { RequestStatus } from './req_status';
import { i18n } from '@kbn/i18n';

/**
* Fetch now provider should be used if you want the results searched and returned immediately.
Expand Down Expand Up @@ -95,7 +96,11 @@ export function FetchNowProvider(Private, Promise) {
return null;
case DUPLICATE:
case INCOMPLETE:
throw new Error('Failed to clear incomplete or duplicate request from responses.');
throw new Error(
i18n.translate('common.ui.courier.fetch.failedToClearRequestErrorMessage', {
defaultMessage: 'Failed to clear incomplete or duplicate request from responses.',
})
);
default:
return resp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ import moment from 'moment';

import { searchRequestQueue } from '../../../search_request_queue';

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

export function SearchRequestProvider(Promise) {
class SearchRequest {
constructor({ source, defer, errorHandler }) {
if (!errorHandler) {
throw new Error('errorHandler is required');
throw new Error(
i18n.translate('common.ui.courier.fetch.requireErrorHandlerErrorMessage', {
defaultMessage: 'errorHandler is required',
})
);
}

this.errorHandler = errorHandler;
Expand Down Expand Up @@ -99,7 +105,11 @@ export function SearchRequestProvider(Promise) {

start() {
if (this.started) {
throw new TypeError('Unable to start request because it has already started');
throw new TypeError(
i18n.translate('common.ui.courier.fetch.unableStartRequestErrorMessage', {
defaultMessage: 'Unable to start request because it has already started',
})
);
}

this.started = true;
Expand Down Expand Up @@ -133,7 +143,12 @@ export function SearchRequestProvider(Promise) {
}

continue() {
throw new Error('Unable to continue ' + this.type + ' request');
throw new Error(
i18n.translate('common.ui.courier.fetch.unableContinueRequestErrorMessage', {
defaultMessage: 'Unable to continue {type} request',
values: { type: this.type }
})
);
}

retry() {
Expand Down
34 changes: 27 additions & 7 deletions src/ui/public/courier/saved_object/saved_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,23 @@ import { SearchSourceProvider } from '../search_source';
import { SavedObjectsClientProvider, findObjectByTitle } from '../../saved_objects';
import { migrateLegacyQuery } from '../../utils/migrate_legacy_query';
import { recentlyAccessed } from '../../persisted_log';
import { i18n } from '@kbn/i18n';

/**
* An error message to be used when the user rejects a confirm overwrite.
* @type {string}
*/
const OVERWRITE_REJECTED = 'Overwrite confirmation was rejected';
const OVERWRITE_REJECTED = i18n.translate('common.ui.courier.savedObject.overwriteRejectedDescription', {
defaultMessage: 'Overwrite confirmation was rejected'
});

/**
* An error message to be used when the user rejects a confirm save with duplicate title.
* @type {string}
*/
const SAVE_DUPLICATE_REJECTED = 'Save with duplicate title confirmation was rejected';
const SAVE_DUPLICATE_REJECTED = i18n.translate('common.ui.courier.savedObject.saveDuplicateRejectedDescription', {
defaultMessage: 'Save with duplicate title confirmation was rejected'
});

/**
* @param error {Error} the error
Expand Down Expand Up @@ -312,9 +317,17 @@ export function SavedObjectProvider(Promise, Private, Notifier, confirmModalProm
.catch(err => {
// record exists, confirm overwriting
if (_.get(err, 'res.status') === 409) {
const confirmMessage = `Are you sure you want to overwrite ${this.title}?`;
const confirmMessage = i18n.translate('common.ui.courier.savedObject.confirmModal.overwriteConfirmationMessage', {
defaultMessage: 'Are you sure you want to overwrite {title}?',
values: { title: this.title }
});

return confirmModalPromise(confirmMessage, { confirmButtonText: `Overwrite ${this.getDisplayName()}` })
return confirmModalPromise(confirmMessage, {
confirmButtonText: i18n.translate('common.ui.courier.savedObject.confirmModal.overwriteButtonLabel', {
defaultMessage: 'Overwrite {name}',
values: { name: this.getDisplayName() }
})
})
.then(() => savedObjectsClient.create(esType, source, this.creationOpts({ overwrite: true })))
.catch(() => Promise.reject(new Error(OVERWRITE_REJECTED)));
}
Expand All @@ -323,10 +336,17 @@ export function SavedObjectProvider(Promise, Private, Notifier, confirmModalProm
};

const displayDuplicateTitleConfirmModal = () => {
const confirmMessage =
`A ${this.getDisplayName()} with the title '${this.title}' already exists. Would you like to save anyway?`;
const confirmMessage = i18n.translate('common.ui.courier.savedObject.confirmModal.saveDuplicateConfirmationMessage', {
defaultMessage: 'A {name} with the title \'{title}\' already exists. Would you like to save anyway?',
values: { title: this.title, name: this.getDisplayName() }
});

return confirmModalPromise(confirmMessage, { confirmButtonText: `Save ${this.getDisplayName()}` })
return confirmModalPromise(confirmMessage, {
confirmButtonText: i18n.translate('common.ui.courier.savedObject.confirmModal.saveDuplicateButtonLabel', {
defaultMessage: 'Save {name}',
values: { name: this.getDisplayName() }
})
})
.catch(() => Promise.reject(new Error(SAVE_DUPLICATE_REJECTED)));
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<div ng-hide="!savedObject.id || savedObject.isSaving">
<div ng-hide="!savedObject.isTitleChanged() || savedObject.copyOnSave" class="kuiLocalDropdownWarning kuiVerticalRhythmSmall">
In previous versions of Kibana, changing the name of a {{savedObject.getDisplayName()}} would make a copy with the new name. Use the 'Save as a new {{savedObject.getDisplayName()}}' checkbox to do this now.
</div>
<div
ng-hide="!savedObject.isTitleChanged() || savedObject.copyOnSave"
class="kuiLocalDropdownWarning kuiVerticalRhythmSmall"
i18n-id="common.ui.courier.savedObject.howToSaveAsNewDescription"
i18n-default-message="In previous versions of Kibana, changing the name of a {savedObjectName} would make a copy with the new name. Use the 'Save as a new {savedObjectName}' checkbox to do this now."
i18n-values="{ savedObjectName: savedObject.getDisplayName() }"
></div>

<label class="kuiCheckBoxLabel kuiVerticalRhythmSmall">
<input
Expand All @@ -12,9 +16,12 @@
ng-checked="savedObject.copyOnSave"
>

<span class="kuiCheckBoxLabel__text">
Save as a new {{savedObject.getDisplayName()}}
</span>
<span
class="kuiCheckBoxLabel__text"
i18n-id="common.ui.courier.savedObject.saveAsNewLabel"
i18n-default-message="Save as a new {savedObjectName}"
i18n-values="{ savedObjectName: savedObject.getDisplayName() }"
></span>
</label>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
*/

import { SearchError } from './search_error';
import { i18n } from '@kbn/i18n';

export const noOpSearchStrategy = {
id: 'noOp',

search: async () => {
const searchError = new SearchError({
status: '418', // "I'm a teapot" error
title: 'No search strategy registered',
message: `Couldn't find a search strategy for the search request`,
title: i18n.translate('common.ui.courier.noSearchStrategyRegisteredErrorMessageTitle', {
defaultMessage: 'No search strategy registered',
}),
message: i18n.translate('common.ui.courier.noSearchStrategyRegisteredErrorMessageDescription', {
defaultMessage: 'Couldn\'t find a search strategy for the search request',
}),
type: 'NO_OP_SEARCH_STRATEGY',
path: '',
});
Expand Down

0 comments on commit 2e9f16e

Please sign in to comment.