Skip to content

Commit

Permalink
Fix i18n and TS errors. Refactor license test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Apr 5, 2021
1 parent 5d1e3cf commit 937ed8a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
25 changes: 15 additions & 10 deletions src/plugins/es_ui_shared/server/license/license.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,25 @@ describe('license_pre_routing_factory', () => {
warn: jest.fn(),
};

const licensingMock = {
license$: {
subscribe: (callback) =>
callback({
type: currentLicenseType,
check: () => ({ state: licenseState }),
getFeature: () => ({}),
}),
},
refresh: jest.fn(),
createLicensePoller: jest.fn(),
featureUsage: {},
};

license.setup({ pluginName, logger });
license.start({
pluginId: 'id',
minimumLicenseType: 'basic',
licensing: {
license$: {
subscribe: (callback) =>
callback({
type: currentLicenseType,
check: () => ({ state: licenseState }),
getFeature: () => ({}),
}),
},
},
licensing: licensingMock,
});

const route = jest.fn();
Expand Down
22 changes: 9 additions & 13 deletions src/plugins/es_ui_shared/server/license/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
*/

import { i18n } from '@kbn/i18n';
import {
Logger,
KibanaRequest,
KibanaResponseFactory,
RequestHandler,
RequestHandlerContext,
} from 'src/core/server';
import { Logger, KibanaRequest, KibanaResponseFactory } from 'src/core/server';

/* eslint-disable @kbn/eslint/no-restricted-paths */
import type {
Expand Down Expand Up @@ -61,37 +55,39 @@ export class License {
getLicenseErrorMessage(licenseCheckState: LicenseCheckState): string {
switch (licenseCheckState) {
case 'invalid':
return i18n.translate('xpack.esUi.license.errorUnsupportedMessage', {
return i18n.translate('esUi.license.errorUnsupportedMessage', {
defaultMessage:
'Your {licenseType} license does not support {pluginName}. Please upgrade your license.',
values: { licenseType: this.licenseType!, pluginName: this.pluginName },
});

case 'expired':
return i18n.translate('xpack.esUi.license.errorExpiredMessage', {
return i18n.translate('esUi.license.errorExpiredMessage', {
defaultMessage:
'You cannot use {pluginName} because your {licenseType} license has expired.',
values: { licenseType: this.licenseType!, pluginName: this.pluginName },
});

case 'unavailable':
return i18n.translate('xpack.esUi.license.errorUnavailableMessage', {
return i18n.translate('esUi.license.errorUnavailableMessage', {
defaultMessage:
'You cannot use {pluginName} because license information is not available at this time.',
values: { pluginName: this.pluginName },
});
}

return i18n.translate('xpack.esUi.license.genericErrorMessage', {
return i18n.translate('esUi.license.genericErrorMessage', {
defaultMessage: 'You cannot use {pluginName} because the license check failed.',
values: { pluginName: this.pluginName },
});
}

guardApiRoute<P, Q, B>(handler: RequestHandler<P, Q, B, RequestHandlerContext>) {
guardApiRoute<RequestHandler, RequestHandlerContext, Params, Query, Body>(
handler: RequestHandler<Params, Query, Body, RequestHandlerContext>
) {
return (
ctx: RequestHandlerContext,
request: KibanaRequest<P, Q, B>,
request: KibanaRequest<Params, Query, Body>,
response: KibanaResponseFactory
) => {
// We'll only surface license errors if users attempt disallowed access to the API.
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -7251,7 +7251,6 @@
"xpack.crossClusterReplication.followerIndexList.table.statusColumnTitle": "ステータス",
"xpack.crossClusterReplication.homeBreadcrumbTitle": "クラスター横断レプリケーション",
"xpack.crossClusterReplication.indexMgmtBadge.followerLabel": "フォロワー",
"xpack.crossClusterReplication.licenseCheckErrorMessage": "ライセンス確認失敗",
"xpack.crossClusterReplication.pauseFollowerIndex.confirmModal.cancelButtonText": "キャンセル",
"xpack.crossClusterReplication.pauseFollowerIndex.confirmModal.confirmButtonText": "複製を中止",
"xpack.crossClusterReplication.pauseFollowerIndex.confirmModal.multiplePauseDescription": "これらのフォロワーインデックスの複製が一時停止されます:",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -7313,7 +7313,6 @@
"xpack.crossClusterReplication.followerIndexList.table.statusColumnTitle": "状态",
"xpack.crossClusterReplication.homeBreadcrumbTitle": "跨集群复制",
"xpack.crossClusterReplication.indexMgmtBadge.followerLabel": "Follower",
"xpack.crossClusterReplication.licenseCheckErrorMessage": "许可证检查失败",
"xpack.crossClusterReplication.pauseAutoFollowPatternsLabel": "暂停{total, plural, other {复制}}",
"xpack.crossClusterReplication.pauseFollowerIndex.confirmModal.cancelButtonText": "取消",
"xpack.crossClusterReplication.pauseFollowerIndex.confirmModal.confirmButtonText": "暂停复制",
Expand Down

0 comments on commit 937ed8a

Please sign in to comment.