Skip to content

Commit

Permalink
Translations for Management -> Objects (elastic#23905) (elastic#24280)
Browse files Browse the repository at this point in the history
* fix tests and update snapshots

* fix id names

* fix test and update snapshots

* Update unit test snapshots

* fix issues

* Update snapshots

* Fix issues
  • Loading branch information
maryia-lapata authored Oct 19, 2018
1 parent cf149f9 commit cd81a9e
Show file tree
Hide file tree
Showing 20 changed files with 769 additions and 273 deletions.
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"inputControl":"src/core_plugins/input_control_vis",
"kbn": "src/core_plugins/kibana",
"kbnVislibVisTypes": "src/core_plugins/kbn_vislib_vis_types",
"kbn.management.objects": "src/core_plugins/kibana/public/management",
"markdownVis": "src/core_plugins/markdown_vis",
"metricVis": "src/core_plugins/metric_vis",
"statusPage": "src/core_plugins/status_page",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { ObjectsTable } from './components/objects_table';
import { getInAppUrl } from './lib/get_in_app_url';
import { I18nProvider } from '@kbn/i18n/react';

const REACT_OBJECTS_TABLE_DOM_ELEMENT_ID = 'reactSavedObjectsTable';

Expand All @@ -52,31 +53,33 @@ function updateObjectsTable($scope, $injector) {
}

render(
<ObjectsTable
savedObjectsClient={savedObjectsClient}
services={services}
indexPatterns={indexPatterns}
$http={$http}
perPageConfig={config.get('savedObjects:perPage')}
basePath={chrome.getBasePath()}
newIndexPatternUrl={kbnUrl.eval('#/management/kibana/index')}
getEditUrl={(id, type) => {
if (type === 'index-pattern' || type === 'indexPatterns') {
return kbnUrl.eval(`#/management/kibana/indices/${id}`);
}
const serviceName = typeToServiceName(type);
if (!serviceName) {
toastNotifications.addWarning(`Unknown saved object type: ${type}`);
return null;
}
<I18nProvider>
<ObjectsTable
savedObjectsClient={savedObjectsClient}
services={services}
indexPatterns={indexPatterns}
$http={$http}
perPageConfig={config.get('savedObjects:perPage')}
basePath={chrome.getBasePath()}
newIndexPatternUrl={kbnUrl.eval('#/management/kibana/index')}
getEditUrl={(id, type) => {
if (type === 'index-pattern' || type === 'indexPatterns') {
return kbnUrl.eval(`#/management/kibana/indices/${id}`);
}
const serviceName = typeToServiceName(type);
if (!serviceName) {
toastNotifications.addWarning(`Unknown saved object type: ${type}`);
return null;
}

return kbnUrl.eval(`#/management/kibana/objects/${serviceName}/${id}`);
}}
goInApp={(id, type) => {
kbnUrl.change(getInAppUrl(id, type));
$scope.$apply();
}}
/>,
return kbnUrl.eval(`#/management/kibana/objects/${serviceName}/${id}`);
}}
goInApp={(id, type) => {
kbnUrl.change(getInAppUrl(id, type));
$scope.$apply();
}}
/>
</I18nProvider>,
node,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
<!-- Header -->
<div class="kuiViewContentItem kuiBar kuiVerticalRhythm">
<div class="kuiBarSection">
<h1 class="kuiTitle">
Edit {{ title }}
</h1>
<h1
class="kuiTitle"
i18n-id="kbn.management.objects.view.editItemTitle"
i18n-default-message="Edit {title}"
i18n-values="{ title }"
></h1>
</div>

<div class="kuiBarSection">
Expand All @@ -15,7 +18,11 @@ <h1 class="kuiTitle">
>
<span class="kuiButton__inner">
<span class="kuiButton__icon kuiIcon fa-eye"></span>
<span>View {{ title }}</span>
<span
i18n-id="kbn.management.objects.view.viewItemButtonLabel"
i18n-default-message="View {title}"
i18n-values="{ title }"
></span>
</span>
</a>

Expand All @@ -25,7 +32,11 @@ <h1 class="kuiTitle">
>
<span class="kuiButton__inner">
<span class="kuiButton__icon kuiIcon fa-trash-o"></span>
<span>Delete {{ title }}</span>
<span
i18n-id="kbn.management.objects.view.deleteItemButtonLabel"
i18n-default-message="Delete {title}"
i18n-values="{ title }"
></span>
</span>
</button>
</div>
Expand All @@ -39,36 +50,40 @@ <h1 class="kuiTitle">
<div class="kuiInfoPanel kuiInfoPanel--error">
<div class="kuiInfoPanelHeader">
<span class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--error fa-warning"></span>
<span class="kuiInfoPanelHeader__title">
There is a problem with this saved object
</span>
<span
class="kuiInfoPanelHeader__title"
i18n-id="kbn.management.objects.view.savedObjectProblemErrorMessage"
i18n-default-message="There is a problem with this saved object"
></span>
</div>

<div class="kuiInfoPanelBody">
<div
class="kuiInfoPanelBody__message"
ng-if="notFound === 'search'"
>
The saved search associated with this object no longer exists.
</div>
i18n-id="kbn.management.objects.view.savedSearchDoesNotExistErrorMessage"
i18n-default-message="The saved search associated with this object no longer exists."
></div>

<div
class="kuiInfoPanelBody__message"
ng-if="notFound === 'index-pattern'"
>
The index pattern associated with this object no longer exists.
</div>
i18n-id="kbn.management.objects.view.indexPatternDoesNotExistErrorMessage"
i18n-default-message="The index pattern associated with this object no longer exists."
></div>

<div
class="kuiInfoPanelBody__message"
ng-if="notFound === 'index-pattern-field'"
>
A field associated with this object no longer exists in the index pattern.
</div>
i18n-id="kbn.management.objects.view.fieldDoesNotExistErrorMessage"
i18n-default-message="A field associated with this object no longer exists in the index pattern."
></div>

<div class="kuiInfoPanelBody__message">
If you know what this error means, go ahead and fix it &mdash; otherwise click the delete button above.
</div>
<div
class="kuiInfoPanelBody__message"
i18n-id="kbn.management.objects.view.howToFixErrorDescription"
i18n-default-message="If you know what this error means, go ahead and fix it &mdash; otherwise click the delete button above."
></div>
</div>
</div>
</div>
Expand All @@ -78,14 +93,19 @@ <h1 class="kuiTitle">
<div class="kuiInfoPanel kuiInfoPanel--warning">
<div class="kuiInfoPanelHeader">
<span class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--warning fa-bolt"></span>
<span class="kuiInfoPanelHeader__title">
Proceed with caution!
</span>
<span
class="kuiInfoPanelHeader__title"
i18n-id="kbn.management.objects.view.howToModifyObjectTitle"
i18n-default-message="Proceed with caution!"
></span>
</div>

<div class="kuiInfoPanelBody">
<div class="kuiInfoPanelBody__message">
Modifying objects is for advanced users only. Object properties are not validated and invalid objects could cause errors, data loss, or worse. Unless someone with intimate knowledge of the code told you to be in here, you probably shouldn&rsquo;t be.
<div
class="kuiInfoPanelBody__message"
i18n-id="kbn.management.objects.view.howToModifyObjectDescription"
i18n-default-message=" Modifying objects is for advanced users only. Object properties are not validated and invalid objects could cause errors, data loss, or worse. Unless someone with intimate knowledge of the code told you to be in here, you probably shouldn&rsquo;t be."
>
</div>
</div>
</div>
Expand Down Expand Up @@ -143,20 +163,21 @@ <h1 class="kuiTitle">
<div class="kuiButtonGroup">
<button
class="kuiButton kuiButton--primary"
aria-label="Save {{ title }} Object"
aria-label="{{ 'kbn.management.objects.view.saveButtonAriaLabel' | i18n: { defaultMessage: 'Save { title } Object', values: { title } } }}"
ng-click="submit()"
ng-disabled="objectForm.$invalid || aceInvalidEditors.length !==0"
>
Save {{ title }} Object
</button>
i18n-id="kbn.management.objects.view.saveButtonLabel"
i18n-default-message="Save { title } Object"
i18n-values="{ title }"
></button>

<button
class="kuiButton kuiButton--basic"
aria-label="Cancel"
aria-label="{{ 'kbn.management.objects.view.cancelButtonAriaLabel' | i18n: { defaultMessage: 'Cancel'} }}"
ng-click="cancel()"
>
Cancel
</button>
i18n-id="kbn.management.objects.view.cancelButtonLabel"
i18n-default-message="Cancel"
></button>
</div>
</div>
</kbn-management-objects-view>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ uiRoutes
});

uiModules.get('apps/management')
.directive('kbnManagementObjectsView', function (kbnIndex, confirmModal) {
.directive('kbnManagementObjectsView', function (kbnIndex, confirmModal, i18n) {
return {
restrict: 'E',
controller: function ($scope, $injector, $routeParams, $location, $window, $rootScope, Private) {
Expand Down Expand Up @@ -199,11 +199,17 @@ uiModules.get('apps/management')
}
const confirmModalOptions = {
onConfirm: doDelete,
confirmButtonText: 'Delete',
title: 'Delete saved Kibana object?'
confirmButtonText: i18n('kbn.management.objects.confirmModalOptions.deleteButtonLabel', {
defaultMessage: 'Delete',
}),
title: i18n('kbn.management.objects.confirmModalOptions.modalTitle', {
defaultMessage: 'Delete saved Kibana object?'
}),
};
confirmModal(
`You can't recover deleted objects`,
i18n('kbn.management.objects.confirmModalOptions.modalDescription', {
defaultMessage: 'You can\'t recover deleted objects',
}),
confirmModalOptions
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,37 @@
exports[`ObjectsTable delete should show a confirm modal 1`] = `
<EuiConfirmModal
buttonColor="primary"
cancelButtonText="Cancel"
confirmButtonText="Delete"
cancelButtonText={
<FormattedMessage
defaultMessage="Cancel"
id="kbn.management.objects.objectsTable.deleteSavedObjectsConfirmModal.cancelButtonLabel"
values={Object {}}
/>
}
confirmButtonText={
<FormattedMessage
defaultMessage="Delete"
id="kbn.management.objects.objectsTable.deleteSavedObjectsConfirmModal.deleteButtonLabel"
values={Object {}}
/>
}
defaultFocusedButton="confirm"
onCancel={[Function]}
onConfirm={[Function]}
title="Delete saved objects"
title={
<FormattedMessage
defaultMessage="Delete saved objects"
id="kbn.management.objects.objectsTable.deleteSavedObjectsConfirmModalTitle"
values={Object {}}
/>
}
>
<p>
This action will delete the following saved objects:
<FormattedMessage
defaultMessage="This action will delete the following saved objects:"
id="kbn.management.objects.deleteSavedObjectsConfirmModalDescription"
values={Object {}}
/>
</p>
<EuiInMemoryTable
columns={
Expand Down Expand Up @@ -50,15 +72,41 @@ exports[`ObjectsTable delete should show a confirm modal 1`] = `
exports[`ObjectsTable export should allow the user to choose when exporting all 1`] = `
<EuiConfirmModal
buttonColor="primary"
cancelButtonText="Cancel"
confirmButtonText="Export All"
cancelButtonText={
<FormattedMessage
defaultMessage="Cancel"
id="kbn.management.objects.objectsTable.exportObjectsConfirmModal.cancelButtonLabel"
values={Object {}}
/>
}
confirmButtonText={
<FormattedMessage
defaultMessage="Export All"
id="kbn.management.objects.objectsTable.exportObjectsConfirmModal.exportAllButtonLabel"
values={Object {}}
/>
}
defaultFocusedButton="confirm"
onCancel={[Function]}
onConfirm={[Function]}
title="Export 4 objects"
title={
<FormattedMessage
defaultMessage="Export {filteredItemCount, plural, one{# object} other {# objects}}"
id="kbn.management.objects.objectsTable.exportObjectsConfirmModalTitle"
values={
Object {
"filteredItemCount": 4,
}
}
/>
}
>
<p>
Select which types to export. The number in parentheses indicates how many of this type are available to export.
<FormattedMessage
defaultMessage="Select which types to export. The number in parentheses indicates how many of this type are available to export."
id="kbn.management.objects.objectsTable.exportObjectsConfirmModalDescription"
values={Object {}}
/>
</p>
<EuiCheckboxGroup
idToSelectedMap={
Expand Down Expand Up @@ -95,7 +143,7 @@ exports[`ObjectsTable export should allow the user to choose when exporting all
`;

exports[`ObjectsTable import should show the flyout 1`] = `
<Flyout
<InjectIntl(FlyoutUI)
close={[Function]}
done={[Function]}
indexPatterns={
Expand All @@ -111,7 +159,7 @@ exports[`ObjectsTable import should show the flyout 1`] = `
`;

exports[`ObjectsTable relationships should show the flyout 1`] = `
<Relationships
<InjectIntl(RelationshipsUI)
close={[Function]}
getEditUrl={[Function]}
getRelationships={[Function]}
Expand Down Expand Up @@ -150,7 +198,7 @@ exports[`ObjectsTable should render normally 1`] = `
<EuiSpacer
size="xs"
/>
<Table
<InjectIntl(TableUI)
filterOptions={
Array [
Object {
Expand Down
Loading

0 comments on commit cd81a9e

Please sign in to comment.