|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import { SharePluginStart, SharePluginSetup } from '../../../src/plugins/share/public'; |
| 21 | +import { Plugin, CoreSetup, AppMountParameters } from '../../../src/core/public'; |
| 22 | +import { |
| 23 | + HelloLinkGeneratorState, |
| 24 | + createHelloPageLinkGenerator, |
| 25 | + LegacyHelloLinkGeneratorState, |
| 26 | + HELLO_URL_GENERATOR_V1, |
| 27 | + HELLO_URL_GENERATOR, |
| 28 | + helloPageLinkGeneratorV1, |
| 29 | +} from './url_generator'; |
| 30 | + |
| 31 | +declare module '../../../src/plugins/share/public' { |
| 32 | + export interface UrlGeneratorStateMapping { |
| 33 | + [HELLO_URL_GENERATOR_V1]: LegacyHelloLinkGeneratorState; |
| 34 | + [HELLO_URL_GENERATOR]: HelloLinkGeneratorState; |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +interface StartDeps { |
| 39 | + share: SharePluginStart; |
| 40 | +} |
| 41 | + |
| 42 | +interface SetupDeps { |
| 43 | + share: SharePluginSetup; |
| 44 | +} |
| 45 | + |
| 46 | +const APP_ID = 'urlGeneratorsExamples'; |
| 47 | + |
| 48 | +export class AccessLinksExamplesPlugin implements Plugin<void, void, SetupDeps, StartDeps> { |
| 49 | + public setup(core: CoreSetup<StartDeps>, { share: { urlGenerators } }: SetupDeps) { |
| 50 | + urlGenerators.registerUrlGenerator( |
| 51 | + createHelloPageLinkGenerator(async () => ({ |
| 52 | + appBasePath: (await core.getStartServices())[0].application.getUrlForApp(APP_ID), |
| 53 | + })) |
| 54 | + ); |
| 55 | + |
| 56 | + urlGenerators.registerUrlGenerator(helloPageLinkGeneratorV1); |
| 57 | + |
| 58 | + core.application.register({ |
| 59 | + id: APP_ID, |
| 60 | + title: 'Access links examples', |
| 61 | + async mount(params: AppMountParameters) { |
| 62 | + const { renderApp } = await import('./app'); |
| 63 | + return renderApp( |
| 64 | + { |
| 65 | + appBasePath: params.appBasePath, |
| 66 | + }, |
| 67 | + params |
| 68 | + ); |
| 69 | + }, |
| 70 | + }); |
| 71 | + } |
| 72 | + |
| 73 | + public start() {} |
| 74 | + |
| 75 | + public stop() {} |
| 76 | +} |
0 commit comments