diff --git a/src/core/public/application/__snapshots__/application_service.test.ts.snap b/src/core/public/application/__snapshots__/application_service.test.ts.snap
new file mode 100644
index 000000000000..376b320b64ea
--- /dev/null
+++ b/src/core/public/application/__snapshots__/application_service.test.ts.snap
@@ -0,0 +1,84 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`#start() getComponent returns renderable JSX tree 1`] = `
+
+`;
diff --git a/src/core/public/application/application_service.test.ts b/src/core/public/application/application_service.test.ts
index 4672a42c9eb0..54489fbd182b 100644
--- a/src/core/public/application/application_service.test.ts
+++ b/src/core/public/application/application_service.test.ts
@@ -525,17 +525,7 @@ describe('#start()', () => {
const { getComponent } = await service.start(startDeps);
expect(() => shallow(createElement(getComponent))).not.toThrow();
- expect(getComponent()).toMatchInlineSnapshot(`
-
- `);
+ expect(getComponent()).toMatchSnapshot();
});
it('renders null when in legacy mode', async () => {
diff --git a/src/core/public/application/application_service.tsx b/src/core/public/application/application_service.tsx
index c69b96274aa9..4d714c8f9dad 100644
--- a/src/core/public/application/application_service.tsx
+++ b/src/core/public/application/application_service.tsx
@@ -19,7 +19,7 @@
import React from 'react';
import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
-import { map, takeUntil } from 'rxjs/operators';
+import { map, shareReplay, takeUntil } from 'rxjs/operators';
import { createBrowserHistory, History } from 'history';
import { InjectedMetadataSetup } from '../injected_metadata';
@@ -256,6 +256,11 @@ export class ApplicationService {
)
.subscribe(apps => applications$.next(apps));
+ const applicationStatuses$ = applications$.pipe(
+ map(apps => new Map([...apps.entries()].map(([id, app]) => [id, app.status!]))),
+ shareReplay(1)
+ );
+
return {
applications$,
capabilities,
@@ -264,11 +269,6 @@ export class ApplicationService {
getUrlForApp: (appId, { path }: { path?: string } = {}) =>
getAppUrl(availableMounters, appId, path),
navigateToApp: async (appId, { path, state }: { path?: string; state?: any } = {}) => {
- const app = applications$.value.get(appId);
- if (app && app.status !== AppStatus.accessible) {
- // should probably redirect to the error page instead
- throw new Error(`Trying to navigate to an inaccessible application: ${appId}`);
- }
if (await this.shouldNavigate(overlays)) {
this.appLeaveHandlers.delete(this.currentAppId$.value!);
this.navigate!(getAppUrl(availableMounters, appId, path), state);
@@ -283,6 +283,7 @@ export class ApplicationService {
);
diff --git a/src/core/public/application/integration_tests/router.test.tsx b/src/core/public/application/integration_tests/router.test.tsx
index cc71cf8722df..4d83ab67810a 100644
--- a/src/core/public/application/integration_tests/router.test.tsx
+++ b/src/core/public/application/integration_tests/router.test.tsx
@@ -18,15 +18,18 @@
*/
import React from 'react';
+import { BehaviorSubject } from 'rxjs';
import { createMemoryHistory, History, createHashHistory } from 'history';
import { AppRouter, AppNotFound } from '../ui';
import { EitherApp, MockedMounterMap, MockedMounterTuple } from '../test_types';
import { createRenderer, createAppMounter, createLegacyAppMounter } from './utils';
+import { AppStatus } from '../types';
describe('AppContainer', () => {
let mounters: MockedMounterMap;
let history: History;
+ let appStatuses$: BehaviorSubject