Skip to content

Commit

Permalink
Removed ResizeChecker from __LEGACY.
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh committed Nov 15, 2019
1 parent 72b9511 commit c4808ae
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 29 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
4 changes: 0 additions & 4 deletions src/legacy/core_plugins/console/np_ready/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ import { npSetup, npStart } from 'ui/new_platform';
import { I18nContext } from 'ui/i18n';
/* eslint-enable @kbn/eslint/no-restricted-paths */

import { ResizeChecker } from '../../../../../plugins/kibana_utils/public';

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

Expand All @@ -49,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
11 changes: 11 additions & 0 deletions test/functional/apps/console/_console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ GET _search
export default function({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const log = getService('log');
const find = getService('find');
const browser = getService('browser');
const PageObjects = getPageObjects(['common', 'console']);

describe('console app', function describeIndexTests() {
Expand Down Expand Up @@ -81,5 +83,14 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
expect(await PageObjects.console.getRequestFontSize()).to.be('24px');
});
});

it('should resize the editor', async () => {
const editor = await find.byCssSelector('.conApp');
await browser.setWindowSize(1300, 1100);
const initialSize = await editor.getSize();
await browser.setWindowSize(1000, 1100);
const afterSize = await editor.getSize();
expect(initialSize.width).to.be.greaterThan(afterSize.width);
});
});
}

0 comments on commit c4808ae

Please sign in to comment.