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

[ES UI Shared] Remove old ace based EuiCodeEditor #169613

Merged
merged 9 commits into from
Oct 25, 2023
Next Next commit
Remove all traces of es_ui_shared code editor
sabarasaba committed Oct 24, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
danielleadams Danielle Adams
commit b5fcaaa5b8d4892f3187c85466aae0d0afe707da

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

312 changes: 0 additions & 312 deletions src/plugins/es_ui_shared/public/components/code_editor/code_editor.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions src/plugins/es_ui_shared/public/components/code_editor/index.tsx

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/plugins/es_ui_shared/public/index.ts
Original file line number Diff line number Diff line change
@@ -21,8 +21,6 @@ export { JsonEditor } from './components/json_editor';
export { PageLoading } from './components/page_loading';
export { SectionLoading } from './components/section_loading';

export type { EuiCodeEditorProps } from './components/code_editor';
export { EuiCodeEditor } from './components/code_editor';
export type { Frequency } from './components/cron_editor';
export { CronEditor } from './components/cron_editor';
export { ViewApiRequestFlyout } from './components/view_api_request_flyout';
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@
* 2.0.
*/

import { CodeEditor } from '@kbn/kibana-react-plugin/public';
import React, { FC } from 'react';

import { expandLiteralStrings, XJsonMode, EuiCodeEditorProps } from '../../../shared_imports';
import { CodeEditor, type CodeEditorProps } from '@kbn/kibana-react-plugin/public';
import { expandLiteralStrings, XJsonMode } from '../../../shared_imports';

export const EDITOR_MODE = { TEXT: 'text', JSON: 'json', XJSON: new XJsonMode() };

@@ -18,7 +18,7 @@ interface JobEditorProps {
width?: string;
mode?: typeof EDITOR_MODE[keyof typeof EDITOR_MODE];
readOnly?: boolean;
onChange?: EuiCodeEditorProps['onChange'];
onChange?: CodeEditorProps['onChange'];
}
export const JsonEditor: FC<JobEditorProps> = ({
value,
Original file line number Diff line number Diff line change
@@ -5,9 +5,6 @@
* 2.0.
*/

export { EuiCodeEditor } from '@kbn/es-ui-shared-plugin/public';
export type { EuiCodeEditorProps } from '@kbn/es-ui-shared-plugin/public';

import { XJson } from '@kbn/es-ui-shared-plugin/public';
const { collapseLiteralStrings, expandLiteralStrings } = XJson;

Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
import React from 'react';
import { act } from 'react-dom/test-utils';

import '../../../test/global_mocks';
import { API_BASE_PATH } from '../../../common/constants';
import { getComposableTemplate } from '../../../test/fixtures';
import { setupEnvironment } from '../helpers';
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
import React from 'react';
import { act } from 'react-dom/test-utils';

import '../../../test/global_mocks';
import { API_BASE_PATH } from '../../../common/constants';
import { setupEnvironment } from '../helpers';

Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
import React from 'react';
import { act } from 'react-dom/test-utils';

import '../../../test/global_mocks';
import * as fixtures from '../../../test/fixtures';
import { API_BASE_PATH } from '../../../common/constants';
import { setupEnvironment, kibanaVersion } from '../helpers';
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@
import React from 'react';
import { act } from 'react-dom/test-utils';

import '@kbn/es-ui-shared-plugin/public/components/code_editor/jest_mock';
import '../../../../../../test/global_mocks';
import { breadcrumbService, IndexManagementBreadcrumb } from '../../../../services/breadcrumbs';
import { setupEnvironment } from './helpers';
import { API_BASE_PATH } from './helpers/constants';
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
import React from 'react';
import { act } from 'react-dom/test-utils';

import '../../../../../../test/global_mocks';
import { breadcrumbService, IndexManagementBreadcrumb } from '../../../../services/breadcrumbs';
import { setupEnvironment } from './helpers';
import { API_BASE_PATH } from './helpers/constants';
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
import React, { ComponentType, MemoExoticComponent } from 'react';
import SemVer from 'semver/classes/semver';

import '@kbn/es-ui-shared-plugin/public/components/code_editor/jest_mock';
import { GlobalFlyout } from '@kbn/es-ui-shared-plugin/public';
import { docLinksServiceMock, uiSettingsServiceMock } from '@kbn/core/public/mocks';
import { MAJOR_VERSION } from '../../../../../../../common';
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { uiSettingsServiceMock } from '@kbn/core/public/mocks';
import '@kbn/es-ui-shared-plugin/public/components/code_editor/jest_mock';

jest.mock('lodash', () => {
const original = jest.requireActual('lodash');
Original file line number Diff line number Diff line change
@@ -224,7 +224,6 @@ export const LoadMappingsProvider = ({ onJson, esNodesPlugins, children }: Props
maxWidth={600}
>
{view === 'json' ? (
// The CSS override for the EuiCodeEditor requires a parent .application css class
<div className="application">
sabarasaba marked this conversation as resolved.
Show resolved Hide resolved
<EuiText color="subdued">
<FormattedMessage
1 change: 0 additions & 1 deletion x-pack/plugins/index_management/public/shared_imports.ts
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@ export {
PageLoading,
PageError,
SectionLoading,
EuiCodeEditor,
} from '@kbn/es-ui-shared-plugin/public';

export type {
29 changes: 0 additions & 29 deletions x-pack/plugins/index_management/test/global_mocks.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
* 2.0.
*/

import React from 'react';
import { act } from 'react-dom/test-utils';

import { setupEnvironment, pageHelpers } from './helpers';
@@ -14,23 +13,6 @@ import { PIPELINE_TO_CLONE, PipelinesCloneTestBed } from './helpers/pipelines_cl

const { setup } = pageHelpers.pipelinesClone;

jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');

return {
...original,
// Mocking EuiCodeEditor, which uses React Ace under the hood
EuiCodeEditor: (props: any) => (
<input
data-test-subj={props['data-test-subj']}
onChange={(syntheticEvent: any) => {
props.onChange(syntheticEvent.jsonString);
}}
/>
),
};
});

describe('<PipelinesClone />', () => {
let testBed: PipelinesCloneTestBed;

Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
import React from 'react';
import { act } from 'react-dom/test-utils';

import '@kbn/es-ui-shared-plugin/public/components/code_editor/jest_mock';
import { setupEnvironment, pageHelpers } from './helpers';
import { API_BASE_PATH } from '../../common/constants';
import { PipelinesCreateTestBed } from './helpers/pipelines_create.helpers';
@@ -34,23 +33,6 @@ jest.mock('@kbn/kibana-react-plugin/public', () => {
};
});

jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');

return {
...original,
// Mocking EuiCodeEditor, which uses React Ace under the hood
EuiCodeEditor: (props: any) => (
<input
data-test-subj={props['data-test-subj']}
onChange={(syntheticEvent: any) => {
props.onChange(syntheticEvent.jsonString);
}}
/>
),
};
});

describe('<PipelinesCreate />', () => {
let testBed: PipelinesCreateTestBed;

Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
* 2.0.
*/

import React from 'react';
import { act } from 'react-dom/test-utils';

import { setupEnvironment, pageHelpers } from './helpers';
@@ -14,23 +13,6 @@ import { PIPELINE_TO_EDIT, PipelinesEditTestBed } from './helpers/pipelines_edit

const { setup } = pageHelpers.pipelinesEdit;

jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');

return {
...original,
// Mocking EuiCodeEditor, which uses React Ace under the hood
EuiCodeEditor: (props: any) => (
<input
data-test-subj={props['data-test-subj']}
onChange={(syntheticEvent: any) => {
props.onChange(syntheticEvent.jsonString);
}}
/>
),
};
});

describe('<PipelinesEdit />', () => {
let testBed: PipelinesEditTestBed;

Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ import { HttpSetup } from '@kbn/core/public';
import { registerTestBed, TestBed } from '@kbn/test-jest-helpers';
import { stubWebWorker } from '@kbn/test-jest-helpers';

import '@kbn/es-ui-shared-plugin/public/components/code_editor/jest_mock';
import { uiMetricService, apiService } from '../../../services';
import { Props } from '..';
import { initHttpRequests } from './http_requests.helpers';
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
*/

import React from 'react';
import '@kbn/es-ui-shared-plugin/public/components/code_editor/jest_mock';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { ModalProvider, OnDoneLoadJsonHandler } from './modal_provider';

Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@

import React, { FC } from 'react';
import { monaco, XJsonLang } from '@kbn/monaco';
import { CodeEditor } from '@kbn/kibana-react-plugin/public';
import { type EuiCodeEditorProps, XJson } from '@kbn/es-ui-shared-plugin/public';
import { CodeEditor, type CodeEditorProps } from '@kbn/kibana-react-plugin/public';
import { XJson } from '@kbn/es-ui-shared-plugin/public';

const { expandLiteralStrings } = XJson;

@@ -20,7 +20,7 @@ interface MlJobEditorProps {
width?: string;
mode?: typeof ML_EDITOR_MODE[keyof typeof ML_EDITOR_MODE];
readOnly?: boolean;
onChange?: EuiCodeEditorProps['onChange'];
onChange?: CodeEditorProps['onChange'];
'data-test-subj'?: string;
schema?: object;
}
2 changes: 0 additions & 2 deletions x-pack/plugins/osquery/public/shared_imports.ts
Original file line number Diff line number Diff line change
@@ -45,6 +45,4 @@ export {
export { fieldValidators } from '@kbn/es-ui-shared-plugin/static/forms/helpers';
export type { ERROR_CODE } from '@kbn/es-ui-shared-plugin/static/forms/helpers/field_validators/types';

export { EuiCodeEditor } from '@kbn/es-ui-shared-plugin/public';
export type { EuiCodeEditorProps } from '@kbn/es-ui-shared-plugin/public';
export { useUiSetting$, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
Original file line number Diff line number Diff line change
@@ -321,9 +321,9 @@ describe('<DetailPanel />', () => {
const { find } = initTestBed({ panelType });
const tabContent = find('rollupJobDetailTabContent');

it('should render the "EuiCodeEditor" with the job "json" data', () => {
const euiCodeEditor = tabContent.find('[data-test-subj="jsonCodeBlock"]').at(0);
expect(JSON.parse(euiCodeEditor.text())).toEqual(defaultJob.json);
it('should render the "CodeEditor" with the job "json" data', () => {
const codeEditor = tabContent.find('[data-test-subj="jsonCodeBlock"]').at(0);
expect(JSON.parse(codeEditor.text())).toEqual(defaultJob.json);
});
});
});