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 7c34572
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 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
16 changes: 9 additions & 7 deletions src/plugins/es_ui_shared/server/license/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,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<Context extends RequestHandlerContext, Params, Query, Body>(
handler: RequestHandler<Params, Query, Body, Context>
) {
return (
ctx: RequestHandlerContext,
request: KibanaRequest<P, Q, B>,
ctx: Context,
request: KibanaRequest<Params, Query, Body>,
response: KibanaResponseFactory
) => {
// We'll only surface license errors if users attempt disallowed access to the API.
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/cross_cluster_replication/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {

import { Index } from '../../index_management/server';
import { PLUGIN } from '../common/constants';
import type { SetupDependencies, CcrRequestHandlerContext } from './types';
import { SetupDependencies, StartDependencies, CcrRequestHandlerContext } from './types';
import { registerApiRoutes } from './routes';
import { elasticsearchJsPlugin } from './client/elasticsearch_ccr';
import { CrossClusterReplicationConfig } from './config';
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
1 change: 1 addition & 0 deletions x-pack/plugins/watcher/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { i18n } from '@kbn/i18n';

import {
CoreSetup,
CoreStart,
ILegacyCustomClusterClient,
Logger,
Plugin,
Expand Down

0 comments on commit 7c34572

Please sign in to comment.