Skip to content

Commit fd096ee

Browse files
committed
Allow chromeless applications to render via non-/app routes (elastic#51527)
* Allow chromeless applications to render via non-/app routes * Address review nits * Fix chrome:application integration tests * Move extraneous application integration tests to unit tests
1 parent d7e6c84 commit fd096ee

22 files changed

+933
-638
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [App](./kibana-plugin-public.app.md) &gt; [appRoute](./kibana-plugin-public.app.approute.md)
4+
5+
## App.appRoute property
6+
7+
Override the application's routing path from `/app/${id}`<!-- -->. Must be unique across registered applications. Should not include the base path from HTTP.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
appRoute?: string;
13+
```

docs/development/core/public/kibana-plugin-public.app.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface App extends AppBase
1616
1717
| Property | Type | Description |
1818
| --- | --- | --- |
19+
| [appRoute](./kibana-plugin-public.app.approute.md) | <code>string</code> | Override the application's routing path from <code>/app/${id}</code>. Must be unique across registered applications. Should not include the base path from HTTP. |
1920
| [chromeless](./kibana-plugin-public.app.chromeless.md) | <code>boolean</code> | Hide the UI chrome when the application is mounted. Defaults to <code>false</code>. Takes precedence over chrome service visibility settings. |
2021
| [mount](./kibana-plugin-public.app.mount.md) | <code>AppMount &#124; AppMountDeprecated</code> | A mount function called when the user navigates to this app's route. May have signature of [AppMount](./kibana-plugin-public.appmount.md) or [AppMountDeprecated](./kibana-plugin-public.appmountdeprecated.md)<!-- -->. |
2122

docs/development/core/public/kibana-plugin-public.appmountparameters.appbasepath.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## AppMountParameters.appBasePath property
66

7-
The base path for configuring the application's router.
7+
The route path for configuring navigation to the application. This string should not include the base path from HTTP.
88

99
<b>Signature:</b>
1010

@@ -22,6 +22,7 @@ export class MyPlugin implements Plugin {
2222
setup({ application }) {
2323
application.register({
2424
id: 'my-app',
25+
appRoute: '/my-app',
2526
async mount(params) {
2627
const { renderApp } = await import('./application');
2728
return renderApp(params);

docs/development/core/public/kibana-plugin-public.appmountparameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ export interface AppMountParameters
1515

1616
| Property | Type | Description |
1717
| --- | --- | --- |
18-
| [appBasePath](./kibana-plugin-public.appmountparameters.appbasepath.md) | <code>string</code> | The base path for configuring the application's router. |
18+
| [appBasePath](./kibana-plugin-public.appmountparameters.appbasepath.md) | <code>string</code> | The route path for configuring navigation to the application. This string should not include the base path from HTTP. |
1919
| [element](./kibana-plugin-public.appmountparameters.element.md) | <code>HTMLElement</code> | The container element to render the application into. |
2020

src/core/public/application/application_service.mock.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
import { Subject } from 'rxjs';
2121

2222
import { capabilitiesServiceMock } from './capabilities/capabilities_service.mock';
23-
import { ApplicationService } from './application_service';
2423
import {
2524
ApplicationSetup,
2625
InternalApplicationStart,
2726
ApplicationStart,
2827
InternalApplicationSetup,
2928
} from './types';
30-
31-
type ApplicationServiceContract = PublicMethodsOf<ApplicationService>;
29+
import { ApplicationServiceContract } from './test_types';
3230

3331
const createSetupContractMock = (): jest.Mocked<ApplicationSetup> => ({
3432
register: jest.fn(),
@@ -41,23 +39,27 @@ const createInternalSetupContractMock = (): jest.Mocked<InternalApplicationSetup
4139
registerMountContext: jest.fn(),
4240
});
4341

44-
const createStartContractMock = (legacyMode = false): jest.Mocked<ApplicationStart> => ({
42+
const createStartContractMock = (): jest.Mocked<ApplicationStart> => ({
4543
capabilities: capabilitiesServiceMock.createStartContract().capabilities,
4644
navigateToApp: jest.fn(),
4745
getUrlForApp: jest.fn(),
4846
registerMountContext: jest.fn(),
4947
});
5048

51-
const createInternalStartContractMock = (): jest.Mocked<InternalApplicationStart> => ({
52-
availableApps: new Map(),
53-
availableLegacyApps: new Map(),
54-
capabilities: capabilitiesServiceMock.createStartContract().capabilities,
55-
navigateToApp: jest.fn(),
56-
getUrlForApp: jest.fn(),
57-
registerMountContext: jest.fn(),
58-
currentAppId$: new Subject<string | undefined>(),
59-
getComponent: jest.fn(),
60-
});
49+
const createInternalStartContractMock = (): jest.Mocked<InternalApplicationStart> => {
50+
const currentAppId$ = new Subject<string | undefined>();
51+
52+
return {
53+
availableApps: new Map(),
54+
availableLegacyApps: new Map(),
55+
capabilities: capabilitiesServiceMock.createStartContract().capabilities,
56+
currentAppId$: currentAppId$.asObservable(),
57+
getComponent: jest.fn(),
58+
getUrlForApp: jest.fn(),
59+
navigateToApp: jest.fn().mockImplementation(appId => currentAppId$.next(appId)),
60+
registerMountContext: jest.fn(),
61+
};
62+
};
6163

6264
const createMock = (): jest.Mocked<ApplicationServiceContract> => ({
6365
setup: jest.fn().mockReturnValue(createInternalSetupContractMock()),
@@ -69,7 +71,6 @@ export const applicationServiceMock = {
6971
create: createMock,
7072
createSetupContract: createSetupContractMock,
7173
createStartContract: createStartContractMock,
72-
7374
createInternalSetupContract: createInternalSetupContractMock,
7475
createInternalStartContract: createInternalStartContractMock,
7576
};

0 commit comments

Comments
 (0)