Skip to content

Commit

Permalink
Feature/translate watcher(part_1) (elastic#23989)
Browse files Browse the repository at this point in the history
* translate watcher(pad_1)

* fix test

* fix issues

* fix the same id name

* fix default message

* fix issues
  • Loading branch information
Nox911 authored and maryia-lapata committed Oct 19, 2018
1 parent 3c15067 commit 6247189
Show file tree
Hide file tree
Showing 28 changed files with 466 additions and 232 deletions.
3 changes: 2 additions & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"metricVis": "src/core_plugins/metric_vis",
"statusPage": "src/core_plugins/status_page",
"tagCloud": "src/core_plugins/tagcloud",
"xpack.idxMgmt": "x-pack/plugins/index_management"
"xpack.idxMgmt": "x-pack/plugins/index_management",
"xpack.watcher": "x-pack/plugins/watcher"
},
"exclude": [
"src/ui/ui_render/bootstrap/app_bootstrap.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sort-field="actionStatusTable.sortField"
sort-reverse="actionStatusTable.sortReverse"
>
Action
{{ 'xpack.watcher.sections.watchDetail.actionStatusTable.actionColumnLabel' | i18n: { defaultMessage: 'Action' } }}
</sortable-column>
</th>
<th scope="col" class="kuiTableHeaderCell">
Expand All @@ -18,7 +18,7 @@
sort-field="actionStatusTable.sortField"
sort-reverse="actionStatusTable.sortReverse"
>
State
{{ 'xpack.watcher.sections.watchDetail.actionStatusTable.stateColumnLabel' | i18n: { defaultMessage: 'State' } }}
</sortable-column>
</th>
<th scope="col" class="kuiTableHeaderCell">
Expand All @@ -45,12 +45,15 @@
<button
class="kuiMenuButton kuiMenuButton--basic kuiMenuButton--iconText"
ng-click="actionStatusTable.onActionAcknowledge(actionStatus)"
title="Acknowledge"
title="{{ 'xpack.watcher.sections.watchDetail.actionStatusTable.acknowledgeButtonTitle' | i18n: { defaultMessage: 'Acknowledge' } }}"
ng-if="actionStatus.isAckable"
data-test-subj="btnActionAcknowledge-{{ actionStatus.id }}"
>
<span class="kuiMenuButton__icon kuiIcon fa-thumbs-up"></span>
<span>Acknowledge</span>
<span
i18n-id="xpack.watcher.sections.watchDetail.actionStatusTable.acknowledgeButtonLabel"
i18n-default-message="Acknowledge"
></span>
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

<!-- Watch Details -->
<div class="kuiBarSection">
<h1 class="kuiTitle">
Current Status
</h1>
<h1
class="kuiTitle"
i18n-id="xpack.watcher.sections.watchDetail.currentStatusTitle"
i18n-default-message="Current Status"
></h1>
</div>

<div class="kuiBarSection">
Expand All @@ -22,24 +24,24 @@ <h1 class="kuiTitle">
ng-click="watchDetail.onWatchDeactivate()"
class="kuiButton kuiButton--basic"
data-test-subj="btnDeactivateWatch"
>
Deactivate
</button>
i18n-id="xpack.watcher.sections.watchDetail.deactivateButtonLabel"
i18n-default-message="Deactivate"
></button>
<button
ng-if="!watchDetail.watch.watchStatus.isActive"
ng-click="watchDetail.onWatchActivate()"
class="kuiButton kuiButton--basic"
data-test-subj="btnActivateWatch"
>
Activate
</button>
i18n-id="xpack.watcher.sections.watchDetail.activateButtonLabel"
i18n-default-message="Activate"
></button>
<button
ng-click="watchDetail.onWatchDelete()"
class="kuiButton kuiButton--danger"
data-test-subj="btnDeleteWatch"
>
Delete
</button>
i18n-id="xpack.watcher.sections.watchDetail.deleteButtonLabel"
i18n-default-message="Delete"
></button>
</div>
</div>
</div>
Expand All @@ -56,14 +58,18 @@ <h1 class="kuiTitle">
sort-reverse="watchDetail.actionStatusTableSortReverse"
on-sort-change="watchDetail.onActionSortChange"
></action-status-table>
<table-info ng-show="!watchDetail.hasActionStatusTableActions">No actions found.</table-info>
<table-info ng-show="!watchDetail.hasActionStatusTableActions">
{{ 'xpack.watcher.sections.watchDetail.noActionsFoundText' | i18n: { defaultMessage: 'No actions found.' } }}
</table-info>
</div>

<!-- Watch History -->
<div class="kuiViewContentItem kuiVerticalRhythm">
<h1 class="kuiTitle">
Watch History
</h1>
<h1
class="kuiTitle"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryTitle"
i18n-default-message="Watch History"
></h1>
</div>

<div class="kuiViewContentItem kuiVerticalRhythm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { REFRESH_INTERVALS } from 'plugins/watcher/../common/constants';

const app = uiModules.get('xpack/watcher');

app.directive('watchDetail', function ($injector) {
app.directive('watchDetail', function ($injector, i18n) {
const watchService = $injector.get('xpackWatcherWatchService');
const licenseService = $injector.get('xpackWatcherLicenseService');

Expand Down Expand Up @@ -152,17 +152,28 @@ app.directive('watchDetail', function ($injector) {

onWatchDelete = () => {
const confirmModalOptions = {
confirmButtonText: 'Delete Watch',
confirmButtonText: i18n('xpack.watcher.sections.watchDetail.deleteConfirmModal.deleteWatchButtonLabel', {
defaultMessage: 'Delete Watch' }
),
onConfirm: this.deleteWatch
};

return confirmModal('This will permanently delete the watch. Are you sure?', confirmModalOptions);
return confirmModal(
i18n('xpack.watcher.sections.watchDetail.deleteConfirmModal.description', {
defaultMessage: 'This will permanently delete the watch. Are you sure?' }
),
confirmModalOptions);
}

deleteWatch = () => {
return watchService.deleteWatch(this.watch.id)
.then(() => {
toastNotifications.addSuccess(`Deleted '${this.watch.displayName}'`);
toastNotifications.addSuccess(
i18n('xpack.watcher.sections.watchDetail.deleteWatchSuccessNotificationText', {
defaultMessage: 'Deleted {watchName}',
values: { watchName: this.watch.displayName } }
),
);
this.close();
})
.catch(err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

<!-- Watch history table -->
<table-info ng-show="watchHistory.isLoading">
Loading watch history&hellip;
{{ 'xpack.watcher.sections.watchDetail.watchHistory.watchHistoryLoadingText' | i18n: { defaultMessage: 'Loading watch history' } }}&hellip;
</table-info>
<table-info ng-show="!watchHistory.isLoading && !watchHistory.hasPageOfHistoryItems">
No watch history found.
{{ 'xpack.watcher.sections.watchDetail.watchHistory.watchHistoryNotFoundText' | i18n: { defaultMessage: 'No watch history found.' } }}
</table-info>
<watch-history-table
xpack-watch="watchHistory.watch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,39 @@
ng-change="watchHistoryRangeFilter.onRangeChange(watchHistoryRangeFilter.range)"
class="kuiSelect"
>
<option value="now-1h">Last 1 hour</option>
<option value="now-24h">Last 24 hours</option>
<option value="now-7d">Last 7 days</option>
<option value="now-30d">Last 30 days</option>
<option value="now-6M">Last 6 months</option>
<option value="now-1y">Last 1 year</option>
<option value="all">All</option>
<option
value="now-1h"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryRangeFilter.last1HourLabel"
i18n-default-message="Last 1 hour"
></option>
<option
value="now-24h"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryRangeFilter.last24HoursLabel"
i18n-default-message="Last 24 hours"
></option>
<option
value="now-7d"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryRangeFilter.last7DaysLabel"
i18n-default-message="Last 7 days"
></option>
<option
value="now-30d"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryRangeFilter.last30DaysLabel"
i18n-default-message="Last 30 days"
></option>
<option
value="now-6M"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryRangeFilter.last6MonthsLabel"
i18n-default-message="Last 6 months"
></option>
<option
value="now-1y"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryRangeFilter.last1YearLabel"
i18n-default-message="Last 1 year"
></option>
<option
value="all"
i18n-id="xpack.watcher.sections.watchDetail.watchHistoryRangeFilter.allLabel"
i18n-default-message="All"
></option>
</select>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sort-field="watchHistoryTable.sortField"
sort-reverse="watchHistoryTable.sortReverse"
>
Trigger Time
{{ 'xpack.watcher.sections.watchDetail.watchHistoryTable.triggerTimeColumnLabel' | i18n: { defaultMessage: 'Trigger Time' } }}
</sortable-column>
</th>
<th scope="col" class="kuiTableHeaderCell">
Expand All @@ -18,7 +18,7 @@
sort-field="watchHistoryTable.sortField"
sort-reverse="watchHistoryTable.sortReverse"
>
State
{{ 'xpack.watcher.sections.watchDetail.watchHistoryTable.stateColumnLabel' | i18n: { defaultMessage: 'State' } }}
</sortable-column>
</th>
<th scope="col" class="kuiTableHeaderCell">
Expand All @@ -28,7 +28,7 @@
sort-field="watchHistoryTable.sortField"
sort-reverse="watchHistoryTable.sortReverse"
>
Comment
{{ 'xpack.watcher.sections.watchDetail.watchHistoryTable.commentColumnLabel' | i18n: { defaultMessage: 'Comment' } }}
</sortable-column>
</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
>
<kbn-tab
tab-id="edit-watch"
title="Edit Watch"
title="{{ 'xpack.watcher.sections.watchEdit.json.editTabTitle' | i18n: { defaultMessage: 'Edit Watch' } }}"
>
Edit
{{ 'xpack.watcher.sections.watchEdit.json.editTabLabel' | i18n: { defaultMessage: 'Edit' } }}
</kbn-tab>
<kbn-tab
tab-id="watch-simulate"
title="Simulate Watch"
title="{{ 'xpack.watcher.sections.watchEdit.json.simulateTabTitle' | i18n: { defaultMessage: 'Simulate Watch' } }}"
>
Simulate
{{ 'xpack.watcher.sections.watchEdit.json.simulateTabLabel' | i18n: { defaultMessage: 'Simulate' } }}
</kbn-tab>
<kbn-tab
tab-id="simulate-results"
title="Simulate Results"
title="{{ 'xpack.watcher.sections.watchEdit.json.simulateResultsTabTitle' | i18n: { defaultMessage: 'Simulate Results' } }}"
ng-if="jsonWatchEdit.simulateResults"
>
Simulation Results
{{ 'xpack.watcher.sections.watchEdit.json.simulateResultsTabLabel' | i18n: { defaultMessage: 'Simulation Results' } }}
</kbn-tab>
</kbn-tabs>
</div>
Expand Down Expand Up @@ -79,8 +79,11 @@
ng-click="jsonWatchEdit.onWatchExecute()"
data-test-subj="btnSimulateWatch"
>
<span class="kuiButton__icon kuiIcon fa-play"></span>
Simulate Watch
<span
class="kuiButton__icon kuiIcon fa-play"
i18n-id="xpack.watcher.sections.watchEdit.json.simulateWatchButtonLabel"
i18n-default-message="Simulate Watch"
></span>
</button>
</div>
</div>
Expand All @@ -104,7 +107,10 @@
</div>

<div class="kuiVerticalRhythm">
<label>Simulation Output:</label>
<label
i18n-id="xpack.watcher.sections.watchEdit.json.simulationOutputLabel"
i18n-default-message="Simulation Output:"
></label>
<watch-history-item-detail
watch-history-item="jsonWatchEdit.simulateResults"
></watch-history-item-detail>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'plugins/watcher/services/license';

const app = uiModules.get('xpack/watcher');

app.directive('jsonWatchEdit', function ($injector) {
app.directive('jsonWatchEdit', function ($injector, i18n) {
const watchService = $injector.get('xpackWatcherWatchService');
const licenseService = $injector.get('xpackWatcherLicenseService');
const kbnUrl = $injector.get('kbnUrl');
Expand Down Expand Up @@ -112,11 +112,25 @@ app.directive('jsonWatchEdit', function ($injector) {

const confirmModalOptions = {
onConfirm: this.saveWatch,
confirmButtonText: 'Overwrite Watch'
confirmButtonText: i18n('xpack.watcher.sections.watchEdit.json.saveConfirmModal.overwriteWatchButtonLabel', {
defaultMessage: 'Overwrite Watch',
}),
};

const watchNameMessageFragment = existingWatch.name ? ` (name: "${existingWatch.name}")` : '';
const message = `Watch with ID "${this.watch.id}"${watchNameMessageFragment} already exists. Do you want to overwrite it?`;
const message = i18n('xpack.watcher.sections.watchEdit.json.saveConfirmModal.description', {
defaultMessage: 'Watch with ID "{watchId}" {watchNameMessageFragment} already exists. Do you want to overwrite it?',
values: {
watchId: this.watch.id,
watchNameMessageFragment: existingWatch.name
? i18n('xpack.watcher.sections.watchEdit.json.saveConfirmModal.descriptionFragmentText', {
defaultMessage: '(name: "{existingWatchName}")',
values: {
existingWatchName: existingWatch.name
}
})
: ''
}
});
return confirmModal(message, confirmModalOptions);
})
.catch(err => toastNotifications.addDanger(err));
Expand All @@ -142,7 +156,14 @@ app.directive('jsonWatchEdit', function ($injector) {
return watchService.saveWatch(this.watch)
.then(() => {
this.watch.isNew = false; // without this, the message displays 'New Watch'
toastNotifications.addSuccess(`Saved '${this.watch.displayName}'`);
toastNotifications.addSuccess(
i18n('xpack.watcher.sections.watchEdit.json.saveSuccessNotificationText', {
defaultMessage: 'Saved \'{watchDisplayName}\'',
values: {
watchDisplayName: this.watch.displayName
}
}),
);
this.onClose();
})
.catch(err => {
Expand All @@ -154,16 +175,30 @@ app.directive('jsonWatchEdit', function ($injector) {
onWatchDelete = () => {
const confirmModalOptions = {
onConfirm: this.deleteWatch,
confirmButtonText: 'Delete Watch'
confirmButtonText: i18n('xpack.watcher.sections.watchEdit.json.deleteConfirmModal.overwriteWatchButtonLabel', {
defaultMessage: 'Delete Watch',
}),
};

return confirmModal('This will permanently delete the watch. Are you sure?', confirmModalOptions);
return confirmModal(
i18n('xpack.watcher.sections.watchEdit.json.deleteConfirmModal.description', {
defaultMessage: 'This will permanently delete the watch. Are you sure?',
}),
confirmModalOptions
);
}

deleteWatch = () => {
return watchService.deleteWatch(this.watch.id)
.then(() => {
toastNotifications.addSuccess(`Deleted '${this.watch.displayName}'`);
toastNotifications.addSuccess(
i18n('xpack.watcher.sections.watchEdit.json.deleteSuccessNotificationText', {
defaultMessage: 'Deleted \'{watchDisplayName}\'',
values: {
watchDisplayName: this.watch.displayName
}
}),
);
this.onClose();
})
.catch(err => {
Expand Down
Loading

0 comments on commit 6247189

Please sign in to comment.