Skip to content

Commit

Permalink
Merge branch 'master' into cypress-cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Feb 10, 2020
2 parents eff893f + 09f1cad commit 6d7a878
Show file tree
Hide file tree
Showing 100 changed files with 1,242 additions and 1,455 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ bower_components
/src/plugins/data/common/es_query/kuery/ast/_generated_/**
/src/legacy/core_plugins/vis_type_timelion/public/_generated_/**
src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data
/src/legacy/ui/public/angular-bootstrap
/src/legacy/ui/public/flot-charts
/test/fixtures/scenarios
/src/legacy/core_plugins/console/public/webpackShims
Expand Down
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ module.exports = {
'test/plugin_functional/plugins/**/public/np_ready/**/*',
'test/plugin_functional/plugins/**/server/np_ready/**/*',
'src/legacy/core_plugins/**/public/np_ready/**/*',
'src/legacy/core_plugins/vis_type_*/public/**/*',
'!src/legacy/core_plugins/vis_type_*/public/legacy*',
'src/legacy/core_plugins/**/server/np_ready/**/*',
'x-pack/legacy/plugins/**/public/np_ready/**/*',
'x-pack/legacy/plugins/**/server/np_ready/**/*',
Expand Down
3 changes: 2 additions & 1 deletion src/core/public/overlays/modal/modal_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/* eslint-disable max-classes-per-file */

import { i18n as t } from '@kbn/i18n';
import { EuiModal, EuiConfirmModal, EuiOverlayMask } from '@elastic/eui';
import { EuiModal, EuiConfirmModal, EuiOverlayMask, EuiConfirmModalProps } from '@elastic/eui';
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Subject } from 'rxjs';
Expand Down Expand Up @@ -68,6 +68,7 @@ export interface OverlayModalConfirmOptions {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
defaultFocusedButton?: EuiConfirmModalProps['defaultFocusedButton'];
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { Breadcrumb } from '@elastic/eui';
import { EuiButtonEmptyProps } from '@elastic/eui';
import { EuiConfirmModalProps } from '@elastic/eui';
import { EuiGlobalToastListToast } from '@elastic/eui';
import { ExclusiveUnion } from '@elastic/eui';
import { IconType } from '@elastic/eui';
Expand Down
4 changes: 0 additions & 4 deletions src/dev/precommit_hook/casing_check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const IGNORE_DIRECTORY_GLOBS = [
'src/babel-*',
'packages/*',
'packages/kbn-ui-framework/generator-kui',
'src/legacy/ui/public/angular-bootstrap',
'src/legacy/ui/public/flot-charts',
'src/legacy/ui/public/utils/lodash-mixins',
'test/functional/fixtures/es_archiver/visualize_source-filters',
Expand Down Expand Up @@ -124,9 +123,6 @@ export const TEMPORARILY_IGNORED_PATHS = [
'src/legacy/core_plugins/timelion/server/series_functions/__tests__/fixtures/tlConfig.js',
'src/fixtures/config_upgrade_from_4.0.0_to_4.0.1-snapshot.json',
'src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_seriesMultiple.js',
'src/legacy/ui/public/angular-bootstrap/bindHtml/bindHtml.js',
'src/legacy/ui/public/angular-bootstrap/tooltip/tooltip-html-unsafe-popup.html',
'src/legacy/ui/public/angular-bootstrap/tooltip/tooltip-popup.html',
'src/legacy/ui/public/assets/favicons/android-chrome-192x192.png',
'src/legacy/ui/public/assets/favicons/android-chrome-256x256.png',
'src/legacy/ui/public/assets/favicons/android-chrome-512x512.png',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ export const legacyChrome = chrome;
export { SavedObjectSaveOpts } from 'ui/saved_objects/types';
export { npSetup, npStart } from 'ui/new_platform';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal';
export { KbnUrl } from 'ui/url/kbn_url';
// @ts-ignore
export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_top_nav';
// @ts-ignore
export { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url/index';
// @ts-ignore
export { confirmModalFactory } from 'ui/modals/confirm_modal';
export { IInjector } from 'ui/chrome';
export { SavedObjectLoader } from 'ui/saved_objects';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/embeddable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { EuiConfirmModal, EuiIcon } from '@elastic/eui';
import { EuiIcon } from '@elastic/eui';
import angular, { IModule } from 'angular';
import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
import {
Expand All @@ -30,7 +30,6 @@ import {
import { Storage } from '../../../../../../plugins/kibana_utils/public';
import {
configureAppAngularModule,
confirmModalFactory,
createTopNavDirective,
createTopNavHelper,
IPrivate,
Expand Down Expand Up @@ -111,7 +110,6 @@ function createLocalAngularModule(core: AppMountContext['core'], navigation: Nav
createLocalConfigModule(core);
createLocalKbnUrlModule();
createLocalTopNavModule(navigation);
createLocalConfirmModalModule();
createLocalIconModule();

const dashboardAngularModule = angular.module(moduleName, [
Expand All @@ -122,7 +120,6 @@ function createLocalAngularModule(core: AppMountContext['core'], navigation: Nav
'app/dashboard/TopNav',
'app/dashboard/KbnUrl',
'app/dashboard/Promise',
'app/dashboard/ConfirmModal',
'app/dashboard/icon',
]);
return dashboardAngularModule;
Expand All @@ -134,13 +131,6 @@ function createLocalIconModule() {
.directive('icon', reactDirective => reactDirective(EuiIcon));
}

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

function createLocalKbnUrlModule() {
angular
.module('app/dashboard/KbnUrl', ['app/dashboard/Private', 'ngRoute'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { IInjector } from '../legacy_imports';

import { ViewMode } from '../../../../embeddable_api/public/np_ready/public';
import { SavedObjectDashboard } from '../saved_dashboard/saved_dashboard';
import { DashboardAppState, SavedDashboardPanel, ConfirmModalFn } from './types';
import { DashboardAppState, SavedDashboardPanel } from './types';
import {
IIndexPattern,
TimeRange,
Expand Down Expand Up @@ -87,8 +87,6 @@ export interface DashboardAppScope extends ng.IScope {

export function initDashboardAppDirective(app: any, deps: RenderDeps) {
app.directive('dashboardApp', function($injector: IInjector) {
const confirmModal = $injector.get<ConfirmModalFn>('confirmModal');

return {
restrict: 'E',
controllerAs: 'dashboardApp',
Expand All @@ -105,7 +103,6 @@ export function initDashboardAppDirective(app: any, deps: RenderDeps) {
$route,
$scope,
$routeParams,
confirmModal,
indexPatterns: deps.npDataStart.indexPatterns,
kbnUrlStateStorage,
history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import _, { uniq } from 'lodash';
import { i18n } from '@kbn/i18n';
import { EUI_MODAL_CANCEL_BUTTON } from '@elastic/eui';
import React from 'react';
import angular from 'angular';

Expand All @@ -27,12 +28,7 @@ import { map } from 'rxjs/operators';
import { History } from 'history';
import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen';

import {
ConfirmationButtonTypes,
migrateLegacyQuery,
SavedObjectSaveOpts,
subscribeWithScope,
} from '../legacy_imports';
import { migrateLegacyQuery, SavedObjectSaveOpts, subscribeWithScope } from '../legacy_imports';
import {
COMPARE_ALL_OPTIONS,
compareFilters,
Expand Down Expand Up @@ -63,7 +59,7 @@ import {
openAddPanelFlyout,
ViewMode,
} from '../../../../embeddable_api/public/np_ready/public';
import { ConfirmModalFn, NavAction, SavedDashboardPanel } from './types';
import { NavAction, SavedDashboardPanel } from './types';

import { showOptionsPopover } from './top_nav/show_options_popover';
import { DashboardSaveModal } from './top_nav/save_modal';
Expand All @@ -90,7 +86,6 @@ export interface DashboardAppControllerDependencies extends RenderDeps {
$routeParams: any;
indexPatterns: IndexPatternsContract;
dashboardConfig: KibanaLegacyStart['dashboardConfig'];
confirmModal: ConfirmModalFn;
history: History;
kbnUrlStateStorage: IKbnUrlStateStorage;
}
Expand All @@ -108,7 +103,6 @@ export class DashboardAppController {
dashboardConfig,
localStorage,
indexPatterns,
confirmModal,
savedQueryService,
embeddables,
share,
Expand Down Expand Up @@ -635,27 +629,31 @@ export class DashboardAppController {
}
}

confirmModal(
i18n.translate('kbn.dashboard.changeViewModeConfirmModal.discardChangesDescription', {
defaultMessage: `Once you discard your changes, there's no getting them back.`,
}),
{
onConfirm: revertChangesAndExitEditMode,
onCancel: _.noop,
confirmButtonText: i18n.translate(
'kbn.dashboard.changeViewModeConfirmModal.confirmButtonLabel',
{ defaultMessage: 'Discard changes' }
),
cancelButtonText: i18n.translate(
'kbn.dashboard.changeViewModeConfirmModal.cancelButtonLabel',
{ defaultMessage: 'Continue editing' }
),
defaultFocusedButton: ConfirmationButtonTypes.CANCEL,
title: i18n.translate('kbn.dashboard.changeViewModeConfirmModal.discardChangesTitle', {
defaultMessage: 'Discard changes to dashboard?',
overlays
.openConfirm(
i18n.translate('kbn.dashboard.changeViewModeConfirmModal.discardChangesDescription', {
defaultMessage: `Once you discard your changes, there's no getting them back.`,
}),
}
);
{
confirmButtonText: i18n.translate(
'kbn.dashboard.changeViewModeConfirmModal.confirmButtonLabel',
{ defaultMessage: 'Discard changes' }
),
cancelButtonText: i18n.translate(
'kbn.dashboard.changeViewModeConfirmModal.cancelButtonLabel',
{ defaultMessage: 'Continue editing' }
),
defaultFocusedButton: EUI_MODAL_CANCEL_BUTTON,
title: i18n.translate('kbn.dashboard.changeViewModeConfirmModal.discardChangesTitle', {
defaultMessage: 'Discard changes to dashboard?',
}),
}
)
.then(isConfirmed => {
if (isConfirmed) {
revertChangesAndExitEditMode();
}
});
};

/**
Expand Down
12 changes: 0 additions & 12 deletions src/legacy/core_plugins/kibana/public/dashboard/np_ready/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,3 @@ export interface StagedFilter {
operator: string;
index: string;
}

export type ConfirmModalFn = (
message: string,
confirmOptions: {
onConfirm: () => void;
onCancel: () => void;
confirmButtonText: string;
cancelButtonText: string;
defaultFocusedButton: string;
title: string;
}
) => void;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// these are necessary to bootstrap the local angular.
// They can stay even after NP cutover
import angular from 'angular';
import 'ui/angular-bootstrap';
import { EuiIcon } from '@elastic/eui';
// @ts-ignore
import { StateProvider } from 'ui/state_management/state';
Expand Down Expand Up @@ -64,6 +63,7 @@ import { createFieldChooserDirective } from './np_ready/components/field_chooser
import { createDiscoverFieldDirective } from './np_ready/components/field_chooser/discover_field';
import { CollapsibleSidebarProvider } from './np_ready/angular/directives/collapsible_sidebar/collapsible_sidebar';
import { DiscoverStartPlugins } from './plugin';
import { initAngularBootstrap } from '../../../../../plugins/kibana_legacy/public';
import { createCssTruncateDirective } from './np_ready/angular/directives/css_truncate';
// @ts-ignore
import { FixedScrollProvider } from './np_ready/angular/directives/fixed_scroll';
Expand All @@ -85,6 +85,7 @@ import {
* needs to render, so in the end the current 'kibana' angular module is no longer necessary
*/
export function getInnerAngularModule(name: string, core: CoreStart, deps: DiscoverStartPlugins) {
initAngularBootstrap();
const module = initializeInnerAngularModule(name, core, deps.navigation, deps.data);
configureAppAngularModule(module, core as LegacyCoreStart, true);
return module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class CreateIndexPatternWizard extends Component {
indexPatternCreationType: PropTypes.object.isRequired,
config: PropTypes.object.isRequired,
changeUrl: PropTypes.func.isRequired,
openConfirm: PropTypes.func.isRequired,
}).isRequired,
};

Expand Down Expand Up @@ -142,12 +143,16 @@ export class CreateIndexPatternWizard extends Component {
values: { title: this.title },
defaultMessage: "An index pattern with the title '{title}' already exists.",
});
try {
await services.confirmModalPromise(confirmMessage, {
confirmButtonText: 'Go to existing pattern',
});

const isConfirmed = await services.openConfirm(confirmMessage, {
confirmButtonText: i18n.translate('kbn.management.indexPattern.goToPatternButtonLabel', {
defaultMessage: 'Go to existing pattern',
}),
});

if (isConfirmed) {
return services.changeUrl(`/management/kibana/index_patterns/${indexPatternId}`);
} catch (err) {
} else {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ uiRoutes.when('/management/kibana/index_pattern', {
$http: npStart.core.http,
savedObjectsClient: npStart.core.savedObjects.client,
indexPatternCreationType,
confirmModalPromise: $injector.get('confirmModalPromise'),
changeUrl: url => {
$scope.$evalAsync(() => kbnUrl.changePath(url));
},
openConfirm: npStart.core.overlays.openConfirm,
};

const initialQuery = $routeParams.id ? decodeURIComponent($routeParams.id) : undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ uiModules
$route,
Promise,
config,
Private,
confirmModal
Private
) {
const {
startSyncingState,
Expand Down Expand Up @@ -290,15 +289,19 @@ uiModules
confirmButtonText: i18n.translate('kbn.management.editIndexPattern.refreshButton', {
defaultMessage: 'Refresh',
}),
onConfirm: async () => {
await $scope.indexPattern.init(true);
$scope.fields = $scope.indexPattern.getNonScriptedFields();
},
title: i18n.translate('kbn.management.editIndexPattern.refreshHeader', {
defaultMessage: 'Refresh field list?',
}),
};
confirmModal(confirmMessage, confirmModalOptions);

npStart.core.overlays
.openConfirm(confirmMessage, confirmModalOptions)
.then(async isConfirmed => {
if (isConfirmed) {
await $scope.indexPattern.init(true);
$scope.fields = $scope.indexPattern.getNonScriptedFields();
}
});
};

$scope.removePattern = function() {
Expand All @@ -322,12 +325,16 @@ uiModules
confirmButtonText: i18n.translate('kbn.management.editIndexPattern.deleteButton', {
defaultMessage: 'Delete',
}),
onConfirm: doRemove,
title: i18n.translate('kbn.management.editIndexPattern.deleteHeader', {
defaultMessage: 'Delete index pattern?',
}),
};
confirmModal('', confirmModalOptions);

npStart.core.overlays.openConfirm('', confirmModalOptions).then(isConfirmed => {
if (isConfirmed) {
doRemove();
}
});
};

$scope.setDefaultPattern = function() {
Expand Down
Loading

0 comments on commit 6d7a878

Please sign in to comment.