Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused public APIs in share plugin #116992

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/share/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
6 changes: 3 additions & 3 deletions src/plugins/share/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}>;
}
11 changes: 0 additions & 11 deletions src/plugins/share/public/url_generators/url_generator_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
});

Expand Down Expand Up @@ -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');
});
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 @@ -4395,7 +4395,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": "アクセスリンクジェネレーターに非推奨マークが付いている場合、移行機能を提供する必要があります。",
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 @@ -4438,7 +4438,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": "如果访问链接生成器标记为已过时,则必须提供迁移函数。",
Expand Down