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: Move static code dependencies into kibana_legacy plugin, part 1 #56408

Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5f77f47
Move PromiseServiceCreator to kibana_legacy, keep placeholder
kertal Jan 30, 2020
b7289cc
Fix types
kertal Jan 31, 2020
c7269b6
Merge master / Fix conflicts
kertal Jan 31, 2020
e41c85c
Migrate migrateLegacyQuery
kertal Jan 31, 2020
ef45e93
Migrate watch_multi decorator
kertal Jan 31, 2020
f12dad8
Migrate watch_multi decorator II
kertal Jan 31, 2020
8ebae78
Merge remote-tracking branch 'upstream/master' into kertal-pr-2020-01…
kertal Jan 31, 2020
fd2f0ae
Migrate call_after_bindings_workaround
kertal Jan 31, 2020
896127e
Migrate configureAppAngularModule, ensureDefaultIndexPattern and deps
kertal Feb 2, 2020
ac67728
Restore ui/notify banners
kertal Feb 2, 2020
75e76dd
Add banners, fix import path
kertal Feb 2, 2020
820bbcf
Fix i18n
kertal Feb 3, 2020
499f3a8
Migrate kbn_accessible_clicks
kertal Feb 3, 2020
a52503b
Fix app_redirect jest test
kertal Feb 4, 2020
926a01c
Migrate PrivateProvider
kertal Feb 4, 2020
7c772d8
Migrate registerListenEventListener
kertal Feb 4, 2020
2b491da
Merge upstream/master and fix conflicts
kertal Feb 4, 2020
04e5b73
Merge upstream/master, fix conflicts
kertal Feb 4, 2020
f48f8d4
Minor adaptions
kertal Feb 4, 2020
4fccc96
Fix i18n
kertal Feb 5, 2020
7e20c19
Optimize imports
kertal Feb 5, 2020
0be548a
Minor fixes
kertal Feb 5, 2020
d6604a1
Migrate IPrivate
kertal Feb 6, 2020
ff6e2a6
undo ToastNotification changes / add deprecated text
kertal Feb 6, 2020
484af2b
Merge upstream/master, fix conflicts
kertal Feb 6, 2020
b8c6b27
Remove duplicate import of migrateLegacyQuery
kertal Feb 6, 2020
c3d4f20
Fix i18n
kertal Feb 6, 2020
b6c6fa3
Merge upstream/master, fix conflicts
kertal Feb 6, 2020
a3f97b4
Merge upstream/master, fix conflicts
kertal Feb 7, 2020
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ 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 { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal';
export { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_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,13 +51,10 @@ 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 { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
Expand All @@ -66,10 +63,13 @@ export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
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 { getServices, callAfterBindingsWorkaround, getAngularModule } from '../../kibana_services';
import { getServices, 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 { timefilter } = getServices();

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,34 +40,32 @@ 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 { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';

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';
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';
2 changes: 1 addition & 1 deletion src/legacy/ui/public/UI_SYSTEMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ In this directory you'll find various UI systems you can use to craft effective
## ui/notify

* [banners](notify/banners/BANNERS.md)
* [toastNotifications](notify/toasts/TOAST_NOTIFICATIONS.md)
* [toastNotifications](../../../plugins/kibana_legacy/public/notify/toasts/TOAST_NOTIFICATIONS.md)
53 changes: 1 addition & 52 deletions src/legacy/ui/public/accessibility/kbn_accessible_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,58 +37,7 @@
* Apply this directive to any of these elements to automatically do the above.
*/

import { accessibleClickKeys, keyCodes } from '@elastic/eui';
import { uiModules } from '../modules';

export function KbnAccessibleClickProvider() {
return {
restrict: 'A',
controller: $element => {
$element.on('keydown', e => {
// Prevent a scroll from occurring if the user has hit space.
if (e.keyCode === keyCodes.SPACE) {
e.preventDefault();
}
});
},
link: (scope, element, attrs) => {
// The whole point of this directive is to hack in functionality that native buttons provide
// by default.
const elementType = element.prop('tagName');

if (elementType === 'BUTTON') {
throw new Error(`kbnAccessibleClick doesn't need to be used on a button.`);
}

if (elementType === 'A' && attrs.href !== undefined) {
throw new Error(
`kbnAccessibleClick doesn't need to be used on a link if it has a href attribute.`
);
}

// We're emulating a click action, so we should already have a regular click handler defined.
if (!attrs.ngClick) {
throw new Error('kbnAccessibleClick requires ng-click to be defined on its element.');
}

// If the developer hasn't already specified attributes required for accessibility, add them.
if (attrs.tabindex === undefined) {
element.attr('tabindex', '0');
}

if (attrs.role === undefined) {
element.attr('role', 'button');
}

element.on('keyup', e => {
// Support keyboard accessibility by emulating mouse click on ENTER or SPACE keypress.
if (accessibleClickKeys[e.keyCode]) {
// Delegate to the click handler on the element (assumed to be ng-click).
element.click();
}
});
},
};
}
import { KbnAccessibleClickProvider } from '../../../../plugins/kibana_legacy/public';

uiModules.get('kibana').directive('kbnAccessibleClick', KbnAccessibleClickProvider);
19 changes: 1 addition & 18 deletions src/legacy/ui/public/directives/listen/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,6 @@
*/

import { uiModules } from '../../modules';

export function registerListenEventListener($rootScope) {
/**
* Helper that registers an event listener, and removes that listener when
* the $scope is destroyed.
*
* @param {SimpleEmitter} emitter - the event emitter to listen to
* @param {string} eventName - the event name
* @param {Function} handler - the event handler
* @return {undefined}
*/
$rootScope.constructor.prototype.$listen = function(emitter, eventName, handler) {
emitter.on(eventName, handler);
this.$on('$destroy', function() {
emitter.off(eventName, handler);
});
};
}
import { registerListenEventListener } from '../../../../../plugins/kibana_legacy/public';

uiModules.get('kibana').run(registerListenEventListener);
4 changes: 3 additions & 1 deletion src/legacy/ui/public/directives/watch_multi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
* under the License.
*/

import './watch_multi';
import { uiModules } from '../../modules';
import { watchMultiDecorator } from '../../../../../plugins/kibana_legacy/public';
uiModules.get('kibana').config(watchMultiDecorator);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import expect from '@kbn/expect';
import { IE_REGEX } from '../url_overflow_service.js';
import { IE_REGEX } from '../../../../../plugins/kibana_legacy/public';

describe('IE_REGEX', () => {
it('should detect IE 9', () => {
Expand Down
Loading