Skip to content

Commit

Permalink
ui/resize_checker 👉 src/plugins/kibana_utils (elastic#44750)
Browse files Browse the repository at this point in the history
* Moved ResizeChecker to kibana_utils.

* Removed ResizeChecker from __LEGACY.
  • Loading branch information
sainthkh authored and Liza K committed Nov 17, 2019
1 parent b9cb99a commit 2596c9d
Show file tree
Hide file tree
Showing 19 changed files with 223 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ describe('Legacy (Ace) Console Editor Component Smoke Test', () => {
updateCurrentState: () => {},
},
},
// eslint-disable-next-line
ResizeChecker: function() {
return { on: () => {} };
},
docLinkVersion: 'NA',
};
editor = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const DEFAULT_INPUT_VALUE = `GET _search
function _Editor({ previousStateLocation = 'stored' }: EditorProps) {
const {
services: { history, notifications },
ResizeChecker,
docLinkVersion,
} = useAppContext();

Expand Down Expand Up @@ -130,7 +129,6 @@ function _Editor({ previousStateLocation = 'stored' }: EditorProps) {
mappings.retrieveAutoCompleteInfo();

const unsubscribeResizer = subscribeResizeChecker(
ResizeChecker,
editorRef.current!,
editorInstanceRef.current
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function _EditorOuput() {
const editorInstanceRef = useRef<null | any>(null);
const {
services: { settings },
ResizeChecker,
} = useAppContext();

const dispatch = useEditorActionContext();
Expand All @@ -42,11 +41,7 @@ function _EditorOuput() {
const editor$ = $(editorRef.current!);
editorInstanceRef.current = initializeOutput(editor$, settings);
editorInstanceRef.current.update('');
const unsubscribe = subscribeResizeChecker(
ResizeChecker,
editorRef.current!,
editorInstanceRef.current
);
const unsubscribe = subscribeResizeChecker(editorRef.current!, editorInstanceRef.current);

dispatch({ type: 'setOutputEditor', value: editorInstanceRef.current });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const CHILD_ELEMENT_PREFIX = 'historyReq';
export function ConsoleHistory({ close }: Props) {
const {
services: { history },
ResizeChecker,
} = useAppContext();

const dispatch = useEditorActionContext();
Expand Down Expand Up @@ -200,7 +199,6 @@ export function ConsoleHistory({ close }: Props) {
<HistoryViewer
settings={readOnlySettings}
req={viewingReq}
ResizeChecker={ResizeChecker}
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ import { applyCurrentSettings } from '../console_editor/apply_editor_settings';
interface Props {
settings: DevToolsSettings;
req: any | null;
ResizeChecker: any;
}

export function HistoryViewer({ settings, ResizeChecker, req }: Props) {
export function HistoryViewer({ settings, req }: Props) {
const divRef = useRef<HTMLDivElement | null>(null);
const viewerRef = useRef<any | null>(null);

Expand All @@ -43,7 +42,7 @@ export function HistoryViewer({ settings, ResizeChecker, req }: Props) {
viewerRef.current = viewer;
viewer.renderer.setShowPrintMargin(false);
viewer.$blockScrolling = Infinity;
const unsubscribe = subscribeResizeChecker(ResizeChecker, divRef.current!, viewer);
const unsubscribe = subscribeResizeChecker(divRef.current!, viewer);
return () => unsubscribe();
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ResizeChecker } from '../../../../../../../../../plugins/kibana_utils/public';

export function subscribeResizeChecker(ResizeChecker: any, $el: any, ...editors: any[]) {
const checker = new ResizeChecker($el);
export function subscribeResizeChecker(el: HTMLElement, ...editors: any[]) {
const checker = new ResizeChecker(el);
checker.on('resize', () =>
editors.forEach(e => {
e.resize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface ContextValue {
notifications: NotificationsSetup;
};
docLinkVersion: string;
ResizeChecker: any;
}

interface ContextProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ export function legacyBackDoorToSettings() {
export function boot(deps: {
docLinkVersion: string;
I18nContext: any;
ResizeChecker: any;
notifications: NotificationsSetup;
}) {
const { I18nContext, ResizeChecker, notifications, docLinkVersion } = deps;
const { I18nContext, notifications, docLinkVersion } = deps;

const storage = createStorage({
engine: window.localStorage,
Expand All @@ -51,7 +50,6 @@ export function boot(deps: {
value={{
docLinkVersion,
services: { storage, history, settings, notifications },
ResizeChecker,
}}
>
<EditorContextProvider settings={settings.toJSON()}>
Expand Down
3 changes: 0 additions & 3 deletions src/legacy/core_plugins/console/np_ready/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ import 'brace/mode/text';
/* eslint-disable @kbn/eslint/no-restricted-paths */
import { npSetup, npStart } from 'ui/new_platform';
import { I18nContext } from 'ui/i18n';
import { ResizeChecker } from 'ui/resize_checker';
/* eslint-enable @kbn/eslint/no-restricted-paths */

export interface XPluginSet {
devTools: DevToolsSetup;
feature_catalogue: FeatureCatalogueSetup;
__LEGACY: {
I18nContext: any;
ResizeChecker: any;
};
}

Expand All @@ -48,7 +46,6 @@ pluginInstance.setup(npSetup.core, {
...npSetup.plugins,
__LEGACY: {
I18nContext,
ResizeChecker,
},
});
pluginInstance.start(npStart.core);
3 changes: 1 addition & 2 deletions src/legacy/core_plugins/console/np_ready/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ConsoleUIPlugin implements Plugin<any, any> {

async setup({ notifications }: CoreSetup, pluginSet: XPluginSet) {
const {
__LEGACY: { I18nContext, ResizeChecker },
__LEGACY: { I18nContext },
devTools,
feature_catalogue,
} = pluginSet;
Expand Down Expand Up @@ -62,7 +62,6 @@ export class ConsoleUIPlugin implements Plugin<any, any> {
boot({
docLinkVersion: ctx.core.docLinks.DOC_LINK_VERSION,
I18nContext,
ResizeChecker,
notifications,
}),
element
Expand Down
208 changes: 0 additions & 208 deletions src/legacy/ui/public/resize_checker/__tests__/resize_checker.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as Rx from 'rxjs';
import { debounceTime, filter, share, switchMap } from 'rxjs/operators';

import { PersistedState } from '../../persisted_state';
import { ResizeChecker } from '../../resize_checker';
import { ResizeChecker } from '../../../../../plugins/kibana_utils/public';
import { Vis, VisualizationController } from '../../vis';
import { getUpdateStatus } from '../../vis/update_status';

Expand Down
1 change: 1 addition & 0 deletions src/plugins/kibana_utils/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from './core';
export * from './errors';
export * from './store';
export * from './parse';
export * from './resize_checker';
export * from './render_complete';
export * from './store';
export * from './errors';
Expand Down
Loading

0 comments on commit 2596c9d

Please sign in to comment.