Remove unused public APIs in share plugin (#116992)

* Remove unused public APIs in share plugin

* update translations

* update jest snapshots
This commit is contained in:
Stacey Gammon 2021-11-03 15:44:20 -04:00 committed by GitHub
parent 3d867400d8
commit d38f4884ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 4 additions and 30 deletions

View file

@ -6,5 +6,5 @@
* Side Public License, v 1.
*/
export { LocatorDefinition, LocatorPublic, useLocatorUrl, formatSearchParams } from './url_service';
export { LocatorDefinition, LocatorPublic, useLocatorUrl } from './url_service';
export type { AnonymousAccessServiceContract, AnonymousAccessState } from './anonymous_access';

View file

@ -12,11 +12,11 @@ export { CSV_QUOTE_VALUES_SETTING, CSV_SEPARATOR_SETTING } from '../common/const
export { LocatorDefinition, LocatorPublic, KibanaLocation } from '../common/url_service';
export { UrlGeneratorStateMapping } from './url_generators/url_generator_definition';
export type { UrlGeneratorStateMapping } from './url_generators/url_generator_definition';
export { SharePluginSetup, SharePluginStart } from './plugin';
export type { SharePluginSetup, SharePluginStart } from './plugin';
export {
export type {
ShareContext,
ShareMenuProvider,
ShareMenuItem,

View file

@ -12,8 +12,4 @@ export interface UrlGeneratorContract<Id extends UrlGeneratorId> {
id: Id;
createUrl(state: UrlGeneratorStateMapping[Id]['State']): Promise<string>;
isDeprecated: boolean;
migrate(state: UrlGeneratorStateMapping[Id]['State']): Promise<{
state: UrlGeneratorStateMapping[Id]['MigratedState'];
id: UrlGeneratorStateMapping[Id]['MigratedId'];
}>;
}

View file

@ -72,17 +72,6 @@ export class UrlGeneratorInternal<Id extends UrlGeneratorId> {
return this.spec.createUrl!(state);
},
isDeprecated: !!this.spec.isDeprecated,
migrate: async (state: UrlGeneratorStateMapping[Id]['State']) => {
if (!this.spec.isDeprecated) {
throw new Error(
i18n.translate('share.urlGenerators.error.migrateCalledNotDeprecated', {
defaultMessage: 'You cannot call migrate on a non-deprecated generator.',
})
);
}
return this.spec.migrate!(state);
},
};
}
}

View file

@ -29,12 +29,8 @@ test('Registering and retrieving a generator', async () => {
"createUrl": [Function],
"id": "TEST_GENERATOR",
"isDeprecated": false,
"migrate": [Function],
}
`);
await expect(generator.migrate({})).rejects.toEqual(
new Error('You cannot call migrate on a non-deprecated generator.')
);
expect(await generator.createUrl({})).toBe('myurl');
const retrievedGenerator = start.getUrlGenerator('TEST_GENERATOR');
@ -43,12 +39,8 @@ test('Registering and retrieving a generator', async () => {
"createUrl": [Function],
"id": "TEST_GENERATOR",
"isDeprecated": false,
"migrate": [Function],
}
`);
await expect(generator.migrate({})).rejects.toEqual(
new Error('You cannot call migrate on a non-deprecated generator.')
);
expect(await generator.createUrl({})).toBe('myurl');
});
@ -124,6 +116,5 @@ test('Generator returns migrated url', async () => {
const generator = start.getUrlGenerator('v1');
expect(generator.isDeprecated).toBe(true);
expect(await generator.migrate({ bar: 'hi' })).toEqual({ id: 'v2', state: { foo: 'hi' } });
expect(await generator.createUrl({ bar: 'hi' })).toEqual('www.hi.com');
});

View file

@ -4391,7 +4391,6 @@
"share.contextMenu.permalinksLabel": "パーマリンク",
"share.contextMenuTitle": "この {objectType} を共有",
"share.urlGenerators.error.createUrlFnProvided": "このジェネレーターは非推奨とマークされています。createUrl fn を付けないでください。",
"share.urlGenerators.error.migrateCalledNotDeprecated": "非推奨以外のジェネレーターで migrate を呼び出すことはできません。",
"share.urlGenerators.error.migrationFnGivenNotDeprecated": "移行機能を提供する場合、このジェネレーターに非推奨マークを付ける必要があります",
"share.urlGenerators.error.noCreateUrlFnProvided": "このジェネレーターには非推奨のマークがありません。createUrl fn を付けてください。",
"share.urlGenerators.error.noMigrationFnProvided": "アクセスリンクジェネレーターに非推奨マークが付いている場合、移行機能を提供する必要があります。",

View file

@ -4434,7 +4434,6 @@
"share.contextMenu.permalinksLabel": "固定链接",
"share.contextMenuTitle": "共享此 {objectType}",
"share.urlGenerators.error.createUrlFnProvided": "此生成器标记为已过时。切勿提供 createUrl 函数。",
"share.urlGenerators.error.migrateCalledNotDeprecated": "无法在非过时的生成器上调用迁移。",
"share.urlGenerators.error.migrationFnGivenNotDeprecated": "如果提供了迁移函数,则必须将此生成器标记为已过时",
"share.urlGenerators.error.noCreateUrlFnProvided": "此生成器未标记为已过时。请提供 createUrl 函数。",
"share.urlGenerators.error.noMigrationFnProvided": "如果访问链接生成器标记为已过时,则必须提供迁移函数。",