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

Kibana app migration: Shim dashboard #48913

Merged
merged 88 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
62f3164
centralize dependencies
flash1293 Oct 18, 2019
0bf00ae
move more stuff into kibana_services
flash1293 Oct 18, 2019
e72e51a
fix tests and dependency
flash1293 Oct 18, 2019
b42f417
bootstrap home via local application service
flash1293 Oct 19, 2019
0d2521e
fix routing for home app
flash1293 Oct 19, 2019
12fb70b
Merge remote-tracking branch 'upstream/master' into centralize-home
flash1293 Oct 21, 2019
af3ad7f
switch to dependency getter instead of direct exports
flash1293 Oct 21, 2019
a455322
Merge branch 'centralize-home' into local-application-service
flash1293 Oct 21, 2019
a1295d3
clean up
flash1293 Oct 21, 2019
082748a
add redirect functionality to local application service
flash1293 Oct 21, 2019
2bf3bf6
return early from route change handlers on dummy wrapper route
flash1293 Oct 21, 2019
398299c
fix jest tests
flash1293 Oct 21, 2019
44bcd46
Start shimming dashboard
flash1293 Oct 21, 2019
822cdac
Merge remote-tracking branch 'upstream/master' into centralize-home
flash1293 Oct 22, 2019
4ea2e63
fix broken tests
flash1293 Oct 22, 2019
22c5588
Merge branch 'centralize-home' into local-application-service
flash1293 Oct 22, 2019
1bd6b3b
local application service
flash1293 Oct 22, 2019
ae8dd12
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 22, 2019
afafe10
wip
flash1293 Oct 22, 2019
a7f2826
wip
flash1293 Oct 22, 2019
dbcf159
Merge branch 'local-application-service' into shim-dashboard
flash1293 Oct 22, 2019
c417060
fix mounting home several times
flash1293 Oct 22, 2019
0f2b23b
Merge branch 'local-application-service' into shim-dashboard
flash1293 Oct 22, 2019
03fd207
wip
flash1293 Oct 22, 2019
eea7c62
move handlers from addSetupWork into legacy_compat
flash1293 Oct 24, 2019
4f0c5b2
pass dependencies into angular configurator
flash1293 Oct 24, 2019
f1ff388
centralize dependencies and clean up shim
flash1293 Oct 24, 2019
48ecdf7
Merge branch 'master' into flash1293/local-application-service
elasticmachine Oct 24, 2019
d1700d2
remove requireDefaultIndex and provide helper function
flash1293 Oct 25, 2019
0dd5d3a
rename function and improve documentation
flash1293 Oct 25, 2019
74fb184
Merge remote-tracking branch 'upstream/master' into flash1293/local-a…
flash1293 Oct 28, 2019
79a1a14
Merge branch 'flash1293/local-application-service' of github.com:flas…
flash1293 Oct 28, 2019
50b1d97
Merge branch 'flash1293/local-application-service' into shim-dashboard
flash1293 Oct 28, 2019
105af0a
redirect unknown urls to default app
flash1293 Oct 28, 2019
f9b47f1
only wire up local angular once
flash1293 Oct 29, 2019
bd31c10
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 30, 2019
0777b47
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 30, 2019
1246675
fix top nav and dashboard only mode
flash1293 Oct 30, 2019
a34dd9f
decouple frome home shim PR
flash1293 Oct 31, 2019
d1defcc
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Oct 31, 2019
e8c59f7
fix typing problems
flash1293 Oct 31, 2019
e238a5d
fix other bugs
flash1293 Oct 31, 2019
3ef6254
got rid of two other angular dependencies
flash1293 Oct 31, 2019
ce902cd
fix i18n issue
flash1293 Oct 31, 2019
8022d4d
fix various issues
flash1293 Oct 31, 2019
936f09a
added some debug notes
flash1293 Oct 31, 2019
784a20e
fix vis filters
flash1293 Oct 31, 2019
ba78539
improve
flash1293 Nov 1, 2019
ac462b5
fix hooks handling for local routes in legacy_compat
flash1293 Nov 3, 2019
72b52ae
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 3, 2019
3c619d2
fix embedded visualize handler tests
flash1293 Nov 3, 2019
02caf27
fix test failures
flash1293 Nov 3, 2019
144699b
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 3, 2019
78855e1
remove buggy test
flash1293 Nov 3, 2019
14d8fd4
different take on global state handling
flash1293 Nov 4, 2019
fa13e4b
fix detection of url state
flash1293 Nov 4, 2019
2a5c0fb
fix broken test
flash1293 Nov 4, 2019
45e875d
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 7, 2019
5f9120b
never update state in dummy route mode
flash1293 Nov 7, 2019
296c174
clean up implementation
flash1293 Nov 7, 2019
8fb0fbd
fix type error
flash1293 Nov 7, 2019
f5ebcf7
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 8, 2019
fad42dd
remove session storage global state handling for now
flash1293 Nov 8, 2019
f005b4e
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 12, 2019
dcb9a88
remove unused dependencies
flash1293 Nov 12, 2019
a21ba30
started centralizing and cleaning up imports
flash1293 Nov 12, 2019
7ec261d
centralize external imports
flash1293 Nov 12, 2019
928f34f
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 13, 2019
a0abd00
fix import bugs
flash1293 Nov 13, 2019
42db084
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 13, 2019
8bdca65
fix merge bugs and rename main dynamic entrypoint
flash1293 Nov 13, 2019
042f2e8
fix jest tests
flash1293 Nov 13, 2019
363a907
fix saved object finder bug
flash1293 Nov 13, 2019
9296c4c
revert using stateless component for this PR
flash1293 Nov 13, 2019
8d41818
fix types
flash1293 Nov 13, 2019
44c15d7
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
a4dd4ff
revert unrelated changes and improve implementation
flash1293 Nov 14, 2019
d51dcd5
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
08d709b
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
ac541f2
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 14, 2019
c1ccc16
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 18, 2019
c4c5bc2
review fixes
flash1293 Nov 18, 2019
4b873e7
fix functional tests
flash1293 Nov 18, 2019
1b20af9
fix dashboard icon
flash1293 Nov 18, 2019
2ea9238
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 19, 2019
c445d72
remove bad import and do not deep-import types from data plugin
flash1293 Nov 19, 2019
6c4e756
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 19, 2019
6f4bbdb
Merge remote-tracking branch 'upstream/master' into shim-dashboard
flash1293 Nov 19, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { AppStateClass } from 'ui/state_management/app_state';
import { AppStateClass } from '../legacy_imports';

/**
* A poor excuse for a mock just to get some basic tests to run in jest without requiring the injector.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.dshAppContainer {
flex: 1;
display: flex;
flex-direction: column;
height: 100%;
}

.dshStartScreen {
Expand Down
220 changes: 220 additions & 0 deletions src/legacy/core_plugins/kibana/public/dashboard/application.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { EuiConfirmModal } from '@elastic/eui';
import angular, { IModule } from 'angular';
import { IPrivate } from 'ui/private';
import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
import {
AppMountContext,
ChromeStart,
LegacyCoreStart,
SavedObjectsClientContract,
UiSettingsClientContract,
} from 'kibana/public';
import { Storage } from '../../../../../plugins/kibana_utils/public';
import {
GlobalStateProvider,
StateManagementConfigProvider,
AppStateProvider,
PrivateProvider,
EventsProvider,
PersistedState,
createTopNavDirective,
createTopNavHelper,
PromiseServiceCreator,
KbnUrlProvider,
RedirectWhenMissingProvider,
confirmModalFactory,
configureAppAngularModule,
} from './legacy_imports';

// @ts-ignore
import { initDashboardApp } from './legacy_app';
import { DataStart } from '../../../data/public';
import { SavedQueryService } from '../../../data/public/search/search_bar/lib/saved_query_service';
flash1293 marked this conversation as resolved.
Show resolved Hide resolved
import { EmbeddablePublicPlugin } from '../../../../../plugins/embeddable/public';
import { NavigationStart } from '../../../navigation/public';
import { DataPublicPluginStart as NpDataStart } from '../../../../../plugins/data/public';

export interface RenderDeps {
core: LegacyCoreStart;
indexPatterns: DataStart['indexPatterns']['indexPatterns'];
dataStart: DataStart;
npDataStart: NpDataStart;
navigation: NavigationStart;
shareContextMenuExtensions: any;
savedObjectsClient: SavedObjectsClientContract;
savedObjectRegistry: any;
dashboardConfig: any;
savedDashboards: any;
dashboardCapabilities: any;
uiSettings: UiSettingsClientContract;
chrome: ChromeStart;
addBasePath: (path: string) => string;
savedQueryService: SavedQueryService;
embeddables: ReturnType<EmbeddablePublicPlugin['start']>;
localStorage: Storage;
}

let angularModuleInstance: IModule | null = null;

export const renderApp = (element: HTMLElement, appBasePath: string, deps: RenderDeps) => {
if (!angularModuleInstance) {
angularModuleInstance = createLocalAngularModule(deps.core, deps.navigation);
// global routing stuff
configureAppAngularModule(angularModuleInstance, deps.core as LegacyCoreStart, true);
// custom routing stuff
initDashboardApp(angularModuleInstance, deps);
}
const $injector = mountDashboardApp(appBasePath, element);
return () => {
$injector.get('$rootScope').$destroy();
};
};

const mainTemplate = (basePath: string) => `<div style="height: 100%">
<base href="${basePath}" />
<div ng-view style="height: 100%;"></div>
</div>
`;

const moduleName = 'app/dashboard';

const thirdPartyAngularDependencies = ['ngSanitize', 'ngRoute', 'react'];

function mountDashboardApp(appBasePath: string, element: HTMLElement) {
const mountpoint = document.createElement('div');
mountpoint.setAttribute('style', 'height: 100%');
// eslint-disable-next-line
mountpoint.innerHTML = mainTemplate(appBasePath);
// bootstrap angular into detached element and attach it later to
// make angular-within-angular possible
const $injector = angular.bootstrap(mountpoint, [moduleName]);
// initialize global state handler
element.appendChild(mountpoint);
return $injector;
}

function createLocalAngularModule(core: AppMountContext['core'], navigation: NavigationStart) {
createLocalI18nModule();
createLocalPrivateModule();
createLocalPromiseModule();
createLocalConfigModule(core);
createLocalKbnUrlModule();
createLocalStateModule();
createLocalPersistedStateModule();
createLocalTopNavModule(navigation);
createLocalConfirmModalModule();

const dashboardAngularModule = angular.module(moduleName, [
...thirdPartyAngularDependencies,
'app/dashboard/Config',
'app/dashboard/I18n',
'app/dashboard/Private',
'app/dashboard/PersistedState',
'app/dashboard/TopNav',
'app/dashboard/State',
'app/dashboard/ConfirmModal',
]);
return dashboardAngularModule;
}

function createLocalConfirmModalModule() {
angular
.module('app/dashboard/ConfirmModal', ['react'])
.factory('confirmModal', confirmModalFactory)
.directive('confirmModal', reactDirective => reactDirective(EuiConfirmModal));
}

function createLocalStateModule() {
angular
.module('app/dashboard/State', [
'app/dashboard/Private',
'app/dashboard/Config',
'app/dashboard/KbnUrl',
'app/dashboard/Promise',
'app/dashboard/PersistedState',
])
.factory('AppState', function(Private: any) {
return Private(AppStateProvider);
})
.service('getAppState', function(Private: any) {
return Private(AppStateProvider).getAppState;
})
.service('globalState', function(Private: any) {
return Private(GlobalStateProvider);
});
}

function createLocalPersistedStateModule() {
angular
.module('app/dashboard/PersistedState', ['app/dashboard/Private', 'app/dashboard/Promise'])
.factory('PersistedState', (Private: IPrivate) => {
const Events = Private(EventsProvider);
return class AngularPersistedState extends PersistedState {
constructor(value: any, path: any) {
super(value, path, Events);
}
};
});
}

function createLocalKbnUrlModule() {
angular
.module('app/dashboard/KbnUrl', ['app/dashboard/Private', 'ngRoute'])
.service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider))
.service('redirectWhenMissing', (Private: IPrivate) => Private(RedirectWhenMissingProvider));
}

function createLocalConfigModule(core: AppMountContext['core']) {
angular
.module('app/dashboard/Config', ['app/dashboard/Private'])
.provider('stateManagementConfig', StateManagementConfigProvider)
.provider('config', () => {
return {
$get: () => ({
get: core.uiSettings.get.bind(core.uiSettings),
}),
};
});
}

function createLocalPromiseModule() {
angular.module('app/dashboard/Promise', []).service('Promise', PromiseServiceCreator);
}

function createLocalPrivateModule() {
angular.module('app/dashboard/Private', []).provider('Private', PrivateProvider);
}

function createLocalTopNavModule(navigation: NavigationStart) {
angular
.module('app/dashboard/TopNav', ['react'])
.directive('kbnTopNav', createTopNavDirective)
.directive('kbnTopNavHelper', createTopNavHelper(navigation.ui));
}

function createLocalI18nModule() {
angular
.module('app/dashboard/I18n', [])
.provider('i18n', I18nProvider)
.filter('i18n', i18nFilter)
.directive('i18nId', i18nDirective);
}
20 changes: 14 additions & 6 deletions src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
>
<!-- Local nav. -->
<kbn-top-nav
ng-show="chrome.getVisible()"
ng-show="isVisible"
app-name="'dashboard'"
config="topNavMenu"

show-search-bar="chrome.getVisible()"
show-search-bar="isVisible"
show-filter-bar="showFilterBar()"
show-save-query="showSaveQuery"

Expand All @@ -34,13 +34,21 @@
The top nav is hidden in embed mode but the filter bar must still be present so
we show the filter bar on its own here if the chrome is not visible.
-->
<filter-bar
ng-if="showFilterBar() && !chrome.getVisible()"
<kbn-top-nav
ng-if="showFilterBar() && !isVisible"
class-name="'globalFilterGroup__filterBar'"

app-name="'dashboard'"
show-search-bar="true"
show-filter-bar="true"
show-save-query="false"
show-date-picker="false"

filters="model.filters"
on-filters-updated="onFiltersUpdated"
index-patterns="indexPatterns"
></filter-bar>
on-filters-updated="onFiltersUpdated"
>
</kbn-top-nav>

<div ng-show="getShouldShowEditHelp() || getShouldShowViewHelp()" class="dshStartScreen">
<div class="euiPanel euiPanel--paddingLarge euiPageContent euiPageContent--horizontalCenter">
Expand Down
Loading