Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into client-and-server…
Browse files Browse the repository at this point in the history
…-np-dir-move
  • Loading branch information
Kerry350 committed Feb 18, 2020
2 parents 934f001 + 8bc3fa4 commit e437cd3
Show file tree
Hide file tree
Showing 86 changed files with 1,633 additions and 1,264 deletions.
27 changes: 25 additions & 2 deletions .ci/end2end.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pipeline {
durabilityHint('PERFORMANCE_OPTIMIZED')
}
triggers {
issueCommentTrigger('(?i).*jenkins\\W+run\\W+(?:the\\W+)?e2e(?:\\W+please)?.*')
issueCommentTrigger('(?i)(retest|.*jenkins\\W+run\\W+(?:the\\W+)?e2e?.*)')
}
parameters {
booleanParam(name: 'FORCE', defaultValue: false, description: 'Whether to force the run.')
Expand Down Expand Up @@ -60,8 +60,14 @@ pipeline {
}
}
steps {
notifyStatus('Starting services', 'PENDING')
dir("${APM_ITS}"){
sh './scripts/compose.py start master --no-kibana --no-xpack-secure'
sh './scripts/compose.py start master --no-kibana'
}
}
post {
unsuccessful {
notifyStatus('Environmental issue', 'FAILURE')
}
}
}
Expand All @@ -77,10 +83,16 @@ pipeline {
JENKINS_NODE_COOKIE = 'dontKillMe'
}
steps {
notifyStatus('Preparing kibana', 'PENDING')
dir("${BASE_DIR}"){
sh script: "${CYPRESS_DIR}/ci/prepare-kibana.sh"
}
}
post {
unsuccessful {
notifyStatus('Kibana warm up failed', 'FAILURE')
}
}
}
stage('Smoke Tests'){
options { skipDefaultCheckout() }
Expand All @@ -91,6 +103,7 @@ pipeline {
}
}
steps{
notifyStatus('Running smoke tests', 'PENDING')
dir("${BASE_DIR}"){
sh '''
jobs -l
Expand All @@ -112,6 +125,12 @@ pipeline {
archiveArtifacts(allowEmptyArchive: false, artifacts: 'apm-its.log')
}
}
unsuccessful {
notifyStatus('Test failures', 'FAILURE')
}
success {
notifyStatus('Tests passed', 'SUCCESS')
}
}
}
}
Expand All @@ -123,3 +142,7 @@ pipeline {
}
}
}

def notifyStatus(String description, String status) {
withGithubNotify.notify('end2end-for-apm-ui', description, status, getBlueoceanDisplayURL())
}
2 changes: 0 additions & 2 deletions examples/ui_action_examples/public/hello_world_trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
*/

import { Trigger } from '../../../src/plugins/ui_actions/public';
import { HELLO_WORLD_ACTION_TYPE } from './hello_world_action';

export const HELLO_WORLD_TRIGGER_ID = 'HELLO_WORLD_TRIGGER_ID';

export const helloWorldTrigger: Trigger = {
id: HELLO_WORLD_TRIGGER_ID,
actionIds: [HELLO_WORLD_ACTION_TYPE],
};
7 changes: 4 additions & 3 deletions examples/ui_action_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { Plugin, CoreSetup, CoreStart } from '../../../src/core/public';
import { UiActionsSetup, UiActionsStart } from '../../../src/plugins/ui_actions/public';
import { createHelloWorldAction } from './hello_world_action';
import { createHelloWorldAction, HELLO_WORLD_ACTION_TYPE } from './hello_world_action';
import { helloWorldTrigger } from './hello_world_trigger';

interface UiActionExamplesSetupDependencies {
Expand All @@ -33,8 +33,9 @@ interface UiActionExamplesStartDependencies {
export class UiActionExamplesPlugin
implements
Plugin<void, void, UiActionExamplesSetupDependencies, UiActionExamplesStartDependencies> {
public setup(core: CoreSetup, deps: UiActionExamplesSetupDependencies) {
deps.uiActions.registerTrigger(helloWorldTrigger);
public setup(core: CoreSetup, { uiActions }: UiActionExamplesSetupDependencies) {
uiActions.registerTrigger(helloWorldTrigger);
uiActions.attachAction(helloWorldTrigger.id, HELLO_WORLD_ACTION_TYPE);
}

public start(coreStart: CoreStart, deps: UiActionExamplesStartDependencies) {
Expand Down
3 changes: 0 additions & 3 deletions examples/ui_actions_explorer/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@ export class UiActionsExplorerPlugin implements Plugin<void, void, {}, StartDeps
public setup(core: CoreSetup<{ uiActions: UiActionsStart }>, deps: SetupDeps) {
deps.uiActions.registerTrigger({
id: COUNTRY_TRIGGER,
actionIds: [],
});
deps.uiActions.registerTrigger({
id: PHONE_TRIGGER,
actionIds: [],
});
deps.uiActions.registerTrigger({
id: USER_TRIGGER,
actionIds: [],
});
deps.uiActions.registerAction(lookUpWeatherAction);
deps.uiActions.registerAction(viewInMapsAction);
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default function(kibana) {
order: -1003,
url: `${kbnBaseUrl}#/discover`,
euiIconType: 'discoverApp',
disableSubUrlTracking: true,
category: DEFAULT_APP_CATEGORIES.analyze,
},
{
Expand All @@ -87,6 +88,7 @@ export default function(kibana) {
order: -1002,
url: `${kbnBaseUrl}#/visualize`,
euiIconType: 'visualizeApp',
disableSubUrlTracking: true,
category: DEFAULT_APP_CATEGORIES.analyze,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,28 @@ export class DashboardStateManager {
// make sure url ('_a') matches initial state
this.kbnUrlStateStorage.set(this.STATE_STORAGE_KEY, initialState, { replace: true });

// setup state syncing utils. state container will be synched with url into `this.STATE_STORAGE_KEY` query param
// setup state syncing utils. state container will be synced with url into `this.STATE_STORAGE_KEY` query param
this.stateSyncRef = syncState<DashboardAppState>({
storageKey: this.STATE_STORAGE_KEY,
stateContainer: {
...this.stateContainer,
set: (state: DashboardAppState | null) => {
// sync state required state container to be able to handle null
// overriding set() so it could handle null coming from url
this.stateContainer.set({
...this.stateDefaults,
...state,
});
if (state) {
this.stateContainer.set({
...this.stateDefaults,
...state,
});
} else {
// Do nothing in case when state from url is empty,
// this fixes: https://github.com/elastic/kibana/issues/57789
// There are not much cases when state in url could become empty:
// 1. User manually removed `_a` from the url
// 2. Browser is navigating away from the page and most likely there is no `_a` in the url.
// In this case we don't want to do any state updates
// and just allow $scope.$on('destroy') fire later and clean up everything
}
},
},
stateStorage: this.kbnUrlStateStorage,
Expand Down
54 changes: 51 additions & 3 deletions src/legacy/core_plugins/kibana/public/discover/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/

import { BehaviorSubject } from 'rxjs';
import { i18n } from '@kbn/i18n';
import { AppMountParameters, CoreSetup, CoreStart, Plugin } from 'kibana/public';
import angular, { auto } from 'angular';
import { UiActionsSetup, UiActionsStart } from 'src/plugins/ui_actions/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import {
DataPublicPluginStart,
DataPublicPluginSetup,
getQueryStateContainer,
} from '../../../../../plugins/data/public';
import { registerFeature } from './np_ready/register_feature';
import './kibana_services';
import { IEmbeddableStart, IEmbeddableSetup } from '../../../../../plugins/embeddable/public';
Expand All @@ -30,7 +36,10 @@ import { NavigationPublicPluginStart as NavigationStart } from '../../../../../p
import { ChartsPluginStart } from '../../../../../plugins/charts/public';
import { buildServices } from './build_services';
import { SharePluginStart } from '../../../../../plugins/share/public';
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';
import {
KibanaLegacySetup,
AngularRenderedAppUpdater,
} from '../../../../../plugins/kibana_legacy/public';
import { DocViewsRegistry } from './np_ready/doc_views/doc_views_registry';
import { DocViewInput, DocViewInputFn } from './np_ready/doc_views/doc_views_types';
import { DocViewTable } from './np_ready/components/table/table';
Expand All @@ -40,6 +49,7 @@ import {
VisualizationsStart,
VisualizationsSetup,
} from '../../../visualizations/public/np_ready/public';
import { createKbnUrlTracker } from '../../../../../plugins/kibana_utils/public';

/**
* These are the interfaces with your public contracts. You should export these
Expand All @@ -56,6 +66,7 @@ export interface DiscoverSetupPlugins {
kibanaLegacy: KibanaLegacySetup;
home: HomePublicPluginSetup;
visualizations: VisualizationsSetup;
data: DataPublicPluginSetup;
}
export interface DiscoverStartPlugins {
uiActions: UiActionsStart;
Expand All @@ -81,6 +92,9 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
private docViewsRegistry: DocViewsRegistry | null = null;
private embeddableInjector: auto.IInjectorService | null = null;
private getEmbeddableInjector: (() => Promise<auto.IInjectorService>) | null = null;
private appStateUpdater = new BehaviorSubject<AngularRenderedAppUpdater>(() => ({}));
private stopUrlTracking: (() => void) | undefined = undefined;

/**
* why are those functions public? they are needed for some mocha tests
* can be removed once all is Jest
Expand All @@ -89,6 +103,27 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
public initializeServices?: () => Promise<{ core: CoreStart; plugins: DiscoverStartPlugins }>;

setup(core: CoreSetup, plugins: DiscoverSetupPlugins): DiscoverSetup {
const { querySyncStateContainer, stop: stopQuerySyncStateContainer } = getQueryStateContainer(
plugins.data.query
);
const { appMounted, appUnMounted, stop: stopUrlTracker } = createKbnUrlTracker({
baseUrl: core.http.basePath.prepend('/app/kibana'),
defaultSubUrl: '#/discover',
storageKey: 'lastUrl:discover',
navLinkUpdater$: this.appStateUpdater,
toastNotifications: core.notifications.toasts,
stateParams: [
{
kbnUrlKey: '_g',
stateUpdate$: querySyncStateContainer.state$,
},
],
});
this.stopUrlTracking = () => {
stopQuerySyncStateContainer();
stopUrlTracker();
};

this.getEmbeddableInjector = this.getInjector.bind(this);
this.docViewsRegistry = new DocViewsRegistry(this.getEmbeddableInjector);
this.docViewsRegistry.addDocView({
Expand All @@ -108,6 +143,8 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
plugins.kibanaLegacy.registerLegacyApp({
id: 'discover',
title: 'Discover',
updater$: this.appStateUpdater.asObservable(),
navLinkId: 'kibana:discover',
order: -1004,
euiIconType: 'discoverApp',
mount: async (params: AppMountParameters) => {
Expand All @@ -117,11 +154,16 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
if (!this.initializeInnerAngular) {
throw Error('Discover plugin method initializeInnerAngular is undefined');
}
appMounted();
await this.initializeServices();
await this.initializeInnerAngular();

const { renderApp } = await import('./np_ready/application');
return renderApp(innerAngularName, params.element);
const unmount = await renderApp(innerAngularName, params.element);
return () => {
unmount();
appUnMounted();
};
},
});
registerFeature(plugins.home);
Expand Down Expand Up @@ -160,6 +202,12 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
this.registerEmbeddable(core, plugins);
}

stop() {
if (this.stopUrlTracking) {
this.stopUrlTracking();
}
}

/**
* register embeddable with a slimmer embeddable version of inner angular
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { DataPublicPluginStart, IndexPatternsContract } from '../../../../../plu
import { VisualizationsStart } from '../../../visualizations/public';
import { SavedVisualizations } from './np_ready/types';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import { Chrome } from './legacy_imports';
import { KibanaLegacyStart } from '../../../../../plugins/kibana_legacy/public';

export interface VisualizeKibanaServices {
Expand All @@ -47,7 +46,6 @@ export interface VisualizeKibanaServices {
embeddable: IEmbeddableStart;
getBasePath: () => string;
indexPatterns: IndexPatternsContract;
legacyChrome: Chrome;
localStorage: Storage;
navigation: NavigationStart;
toastNotifications: ToastsStart;
Expand All @@ -61,6 +59,7 @@ export interface VisualizeKibanaServices {
visualizations: VisualizationsStart;
usageCollection?: UsageCollectionSetup;
I18nContext: I18nStart['Context'];
setActiveUrl: (newUrl: string) => void;
}

let services: VisualizeKibanaServices | null = null;
Expand Down
9 changes: 2 additions & 7 deletions src/legacy/core_plugins/kibana/public/visualize/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@
*/

import { PluginInitializerContext } from 'kibana/public';
import { legacyChrome, npSetup, npStart } from './legacy_imports';
import { npSetup, npStart } from 'ui/new_platform';
import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
import { plugin } from './index';

const instance = plugin({
env: npSetup.plugins.kibanaLegacy.env,
} as PluginInitializerContext);
instance.setup(npSetup.core, {
...npSetup.plugins,
__LEGACY: {
legacyChrome,
},
});
instance.setup(npSetup.core, npSetup.plugins);
instance.start(npStart.core, {
...npStart.plugins,
visualizations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
* directly where they are needed.
*/

import chrome from 'ui/chrome';

export const legacyChrome = chrome;
export { Chrome } from 'ui/chrome';

// @ts-ignore
export { AppState, AppStateProvider } from 'ui/state_management/app_state';
export { State } from 'ui/state_management/state';
Expand All @@ -39,8 +34,6 @@ export { StateManagementConfigProvider } from 'ui/state_management/config_provid
export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
export { PersistedState } from 'ui/persisted_state';

export { npSetup, npStart } from 'ui/new_platform';

export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
export { EventsProvider } from 'ui/events';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { VisualizeKibanaServices } from '../kibana_services';

let angularModuleInstance: IModule | null = null;

export const renderApp = async (
export const renderApp = (
element: HTMLElement,
appBasePath: string,
deps: VisualizeKibanaServices
Expand All @@ -58,7 +58,6 @@ export const renderApp = async (
{ core: deps.core, env: deps.pluginInitializerContext.env },
true
);
// custom routing stuff
initVisualizeApp(angularModuleInstance, deps);
}
const $injector = mountVisualizeApp(appBasePath, element);
Expand Down
Loading

0 comments on commit e437cd3

Please sign in to comment.