Skip to content

Commit

Permalink
Merge branch 'master' into disable_categorization_stats_check
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Feb 7, 2020
2 parents 2580dc0 + a7be72c commit fe9f18a
Show file tree
Hide file tree
Showing 76 changed files with 645 additions and 530 deletions.
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"src/plugins/management"
],
"advancedSettings": "src/plugins/advanced_settings",
"kibana_legacy": "src/plugins/kibana_legacy",
"kibana_react": "src/legacy/core_plugins/kibana_react",
"kibana-react": "src/plugins/kibana_react",
"kibana_utils": "src/plugins/kibana_utils",
Expand Down
1 change: 1 addition & 0 deletions src/core/server/elasticsearch/retry_call_cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('migrationsRetryCallCluster', () => {
'RequestTimeout',
'AuthenticationException',
'AuthorizationException',
'Gone',
];

const mockLogger = loggingServiceMock.create();
Expand Down
4 changes: 3 additions & 1 deletion src/core/server/elasticsearch/retry_call_cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export function migrationsRetryCallCluster(
error instanceof esErrors.ServiceUnavailable ||
error instanceof esErrors.RequestTimeout ||
error instanceof esErrors.AuthenticationException ||
error instanceof esErrors.AuthorizationException
error instanceof esErrors.AuthorizationException ||
// @ts-ignore
error instanceof esErrors.Gone
);
},
timer(delay),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ import chrome from 'ui/chrome';
export const legacyChrome = chrome;
export { SavedObjectSaveOpts } from 'ui/saved_objects/types';
export { npSetup, npStart } from 'ui/new_platform';
export { IPrivate } from 'ui/private';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal';
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { KbnUrl } from 'ui/url/kbn_url';
// @ts-ignore
export { PrivateProvider } from 'ui/private/private';
// @ts-ignore
export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_top_nav';
// @ts-ignore
export { PromiseServiceCreator } from 'ui/promises/promises';
// @ts-ignore
export { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url/index';
// @ts-ignore
export { confirmModalFactory } from 'ui/modals/confirm_modal';
export { configureAppAngularModule } from 'ui/legacy_compat';
export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { IInjector } from 'ui/chrome';
export { SavedObjectLoader } from 'ui/saved_objects';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/embeddable';
export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router';
export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
export {
configureAppAngularModule,
ensureDefaultIndexPattern,
IPrivate,
migrateLegacyQuery,
PrivateProvider,
PromiseServiceCreator,
} from '../../../../../plugins/kibana_legacy/public';
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,15 @@
// They can stay even after NP cutover
import angular from 'angular';
import 'ui/angular-bootstrap';
import { IPrivate } from 'ui/private';
import { EuiIcon } from '@elastic/eui';
// @ts-ignore
import { StateProvider } from 'ui/state_management/state';
// @ts-ignore
import { EventsProvider } from 'ui/events';
import { PersistedState } from 'ui/persisted_state';
// @ts-ignore
import { PromiseServiceCreator } from 'ui/promises/promises';
import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
// @ts-ignore
import { PrivateProvider } from 'ui/private/private';
import { CoreStart, LegacyCoreStart, IUiSettingsClient } from 'kibana/public';
// @ts-ignore
import { watchMultiDecorator } from 'ui/directives/watch_multi/watch_multi';
// @ts-ignore
import { registerListenEventListener } from 'ui/directives/listen/listen';
// @ts-ignore
import { KbnAccessibleClickProvider } from 'ui/accessibility/kbn_accessible_click';
// @ts-ignore
import { AppStateProvider } from 'ui/state_management/app_state';
// @ts-ignore
import { GlobalStateProvider } from 'ui/state_management/global_state';
Expand All @@ -51,7 +40,6 @@ import { StateManagementConfigProvider } from 'ui/state_management/config_provid
import { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url';
// @ts-ignore
import { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_top_nav';
import { configureAppAngularModule } from 'ui/legacy_compat';
import { IndexPatterns, DataPublicPluginStart } from '../../../../../plugins/data/public';
import { Storage } from '../../../../../plugins/kibana_utils/public';
import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public';
Expand Down Expand Up @@ -82,6 +70,15 @@ import { FixedScrollProvider } from './np_ready/angular/directives/fixed_scroll'
// @ts-ignore
import { DebounceProviderTimeout } from './np_ready/angular/directives/debounce/debounce';
import { createRenderCompleteDirective } from './np_ready/angular/directives/render_complete';
import {
configureAppAngularModule,
IPrivate,
KbnAccessibleClickProvider,
PrivateProvider,
PromiseServiceCreator,
registerListenEventListener,
watchMultiDecorator,
} from '../../../../../plugins/kibana_legacy/public';

/**
* returns the main inner angular module, it contains all the parts of Angular Discover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,22 @@ export function setServices(newServices: any) {
export { angular };
export { wrapInI18nContext } from 'ui/i18n';
export { buildVislibDimensions } from '../../../visualizations/public';
// @ts-ignore
export { callAfterBindingsWorkaround } from 'ui/compat';
export { getRequestInspectorStats, getResponseInspectorStats } from '../../../data/public';
// @ts-ignore
export { intervalOptions } from 'ui/agg_types';
// @ts-ignore
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
export { timezoneProvider } from 'ui/vis/lib/timezone';
// @ts-ignore
export { tabifyAggResponse } from 'ui/agg_response/tabify';
export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { unhashUrl } from '../../../../../plugins/kibana_utils/public';
// @ts-ignore
export { formatMsg, formatStack } from 'ui/notify/lib/index';
export {
migrateLegacyQuery,
ensureDefaultIndexPattern,
formatMsg,
formatStack,
} from '../../../../../plugins/kibana_legacy/public';

// EXPORT types
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,6 @@
*
*/

export class InitAfterBindingsWorkaround {
static $inject = ['$injector', '$attrs', '$element', '$scope', '$transclude'];
constructor($injector, $attrs, $element, $scope, $transclude) {
if (!this.initAfterBindings) {
throw new Error(
'When using inheritance you must move the logic in the constructor to the `initAfterBindings` method'
);
}

this.$onInit = () => {
$injector.invoke(this.initAfterBindings, this, {
$attrs,
$element,
$scope,
$transclude,
});
};
}
}

export function callAfterBindingsWorkaround(constructor) {
return function InitAfterBindingsWrapper($injector, $attrs, $element, $scope, $transclude) {
this.$onInit = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _ from 'lodash';
import { callAfterBindingsWorkaround, getAngularModule } from '../../kibana_services';
import { getAngularModule } from '../../kibana_services';
import contextAppTemplate from './context_app.html';
import './context/components/action_bar';
import { getFirstSortableField } from './context/api/utils/sorting';
Expand All @@ -33,6 +33,7 @@ import {
LOADING_STATUS,
QueryActionsProvider,
} from './context/query';
import { callAfterBindingsWorkaround } from './context/helpers/call_after_bindings_workaround';

const module = getAngularModule();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import { EuiCallOut, EuiCodeBlock } from '@elastic/eui';
import { formatMsg, formatStack } from '../../../kibana_services';

interface Props {
error: Error | string | null;
error: Error | string;
}

export function DocViewerError({ error }: Props) {
const errMsg = formatMsg(error);
const errStack = error ? formatStack(error) : '';
const errStack = typeof error === 'object' ? formatStack(error) : '';

return (
<EuiCallOut title={errMsg} color="danger" iconType="cross" data-test-subj="docViewerError">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface Props {
}

interface State {
error: null | Error | string;
error: Error | string;
hasError: boolean;
}
/**
Expand All @@ -42,7 +42,7 @@ interface State {
export class DocViewerTab extends React.Component<Props, State> {
state = {
hasError: false,
error: null,
error: '',
};

static getDerivedStateFromError(error: unknown) {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/home/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import { FeatureCatalogueRegistryProvider } from 'ui/registry/feature_catalogue';
import { npSetup, npStart } from 'ui/new_platform';
import chrome from 'ui/chrome';
import { IPrivate } from 'ui/private';
import { HomePlugin, LegacyAngularInjectedDependencies } from './plugin';
import { TelemetryOptInProvider } from '../../../telemetry/public/services';
import { IPrivate } from '../../../../../plugins/kibana_legacy/public';

/**
* Get dependencies relying on the global angular context.
Expand Down
18 changes: 8 additions & 10 deletions src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,29 @@ export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
export { PersistedState } from 'ui/persisted_state';

export { npSetup, npStart } from 'ui/new_platform';
export { IPrivate } from 'ui/private';
// @ts-ignore
export { PrivateProvider } from 'ui/private/private';

export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
// @ts-ignore
export { EventsProvider } from 'ui/events';
// @ts-ignore
export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_top_nav';
// @ts-ignore
export { PromiseServiceCreator } from 'ui/promises/promises';
// @ts-ignore
export { confirmModalFactory } from 'ui/modals/confirm_modal';
export { configureAppAngularModule, ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router';

// @ts-ignore
export { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url';
export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
export { KibanaParsedUrl } from 'ui/url/kibana_parsed_url';

export { wrapInI18nContext } from 'ui/i18n';

export { DashboardConstants } from '../dashboard/np_ready/dashboard_constants';
export { VisSavedObject } from '../../../visualizations/public/embeddable/visualize_embeddable';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/embeddable';
export { VisType } from '../../../visualizations/public';
export {
configureAppAngularModule,
ensureDefaultIndexPattern,
IPrivate,
migrateLegacyQuery,
PrivateProvider,
PromiseServiceCreator,
} from '../../../../../plugins/kibana_legacy/public';
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function initListingDirective(app) {
);
}

export function VisualizeListingController($injector, createNewVis) {
export function VisualizeListingController($injector, $scope, createNewVis) {
const {
addBasePath,
chrome,
Expand All @@ -59,7 +59,7 @@ export function VisualizeListingController($injector, createNewVis) {
this.savedObjects = savedObjects;

this.createNewVis = () => {
visualizations.showNewVisModal();
this.closeNewVisModal = visualizations.showNewVisModal();
};

this.editItem = ({ editUrl }) => {
Expand All @@ -73,7 +73,7 @@ export function VisualizeListingController($injector, createNewVis) {

if (createNewVis) {
// In case the user navigated to the page via the /visualize/new URL we start the dialog immediately
visualizations.showNewVisModal({
this.closeNewVisModal = visualizations.showNewVisModal({
onClose: () => {
// In case the user came via a URL to this page, change the URL to the regular landing page URL after closing the modal
kbnUrl.changePath(VisualizeConstants.LANDING_PAGE_PATH);
Expand Down Expand Up @@ -124,4 +124,10 @@ export function VisualizeListingController($injector, createNewVis) {
this.listingLimit = uiSettings.get('savedObjects:listingLimit');

addHelpMenuToAppChrome(chrome, docLinks);

$scope.$on('$destroy', () => {
if (this.closeNewVisModal) {
this.closeNewVisModal();
}
});
}
16 changes: 6 additions & 10 deletions src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,18 @@
export { npSetup, npStart } from 'ui/new_platform';
export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities';
export { IAggConfig, AggGroupNames, Schemas } from 'ui/agg_types';

// @ts-ignore
export { PrivateProvider } from 'ui/private/private';
// @ts-ignore
export { PaginateDirectiveProvider } from 'ui/directives/paginate';
// @ts-ignore
export { PaginateControlsDirectiveProvider } from 'ui/directives/paginate';
// @ts-ignore
export { watchMultiDecorator } from 'ui/directives/watch_multi/watch_multi';

// @ts-ignore
export { KbnAccessibleClickProvider } from 'ui/accessibility/kbn_accessible_click';
// @ts-ignore
export { StateManagementConfigProvider } from 'ui/state_management/config_provider';
export { configureAppAngularModule } from 'ui/legacy_compat';

export { tabifyGetColumns } from 'ui/agg_response/tabify/_get_columns';
// @ts-ignore
export { tabifyAggResponse } from 'ui/agg_response/tabify';
export {
configureAppAngularModule,
KbnAccessibleClickProvider,
PrivateProvider,
watchMultiDecorator,
} from '../../../../plugins/kibana_legacy/public';
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,26 @@ describe('NewVisModal', () => {
expect(window.location.assign).toBeCalledWith('testbasepath/aliasUrl?addToDashboard');
expect(onClose).toHaveBeenCalled();
});

it('closes and redirects properly if visualization with aliasUrl and without addToDashboard in editorParams', () => {
const onClose = jest.fn();
window.location.assign = jest.fn();
const wrapper = mountWithIntl(
<NewVisModal
isOpen={true}
onClose={onClose}
visTypesRegistry={visTypes}
editorParams={['foo=true', 'bar=42']}
addBasePath={addBasePath}
uiSettings={uiSettings}
savedObjects={{} as SavedObjectsStart}
/>
);
const visButton = wrapper.find('button[data-test-subj="visType-visWithAliasUrl"]');
visButton.simulate('click');
expect(window.location.assign).toBeCalledWith('testbasepath/aliasUrl');
expect(onClose).toHaveBeenCalled();
});
});

describe('filter for visualization types', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ class NewVisModal extends React.Component<TypeSelectionProps, TypeSelectionState
params = this.props.addBasePath(visType.aliasUrl);
if (this.props.editorParams && this.props.editorParams.includes('addToDashboard')) {
params = `${params}?addToDashboard`;
this.props.onClose();
}
this.props.onClose();
window.location.assign(params);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ export interface ShowNewVisModalParams {

export function showNewVisModal({ editorParams = [], onClose }: ShowNewVisModalParams = {}) {
const container = document.createElement('div');
let isClosed = false;
const handleClose = () => {
if (isClosed) return;
ReactDOM.unmountComponentAtNode(container);
document.body.removeChild(container);
if (onClose) {
onClose();
}
isClosed = true;
};

document.body.appendChild(container);
Expand All @@ -55,4 +58,6 @@ export function showNewVisModal({ editorParams = [], onClose }: ShowNewVisModalP
</I18nProvider>
);
ReactDOM.render(element, container);

return () => handleClose();
}
Loading

0 comments on commit fe9f18a

Please sign in to comment.