-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Change Role Mappings editor to use CodeEditor #107459
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,17 @@ | |
import 'brace/mode/json'; | ||
import 'brace/theme/github'; | ||
|
||
import { EuiButton, EuiCodeEditor, EuiFormRow, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; | ||
import { EuiButton, EuiFormRow, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; | ||
import React, { Fragment, useState } from 'react'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { XJsonLang } from '@kbn/monaco'; | ||
|
||
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; | ||
import { | ||
CodeEditorField, | ||
useKibana, | ||
} from '../../../../../../../../src/plugins/kibana_react/public'; | ||
import type { Rule } from '../../model'; | ||
import { generateRulesFromRaw, RuleBuilderError } from '../../model'; | ||
|
||
|
@@ -76,25 +80,26 @@ export const JSONRuleEditor = (props: Props) => { | |
data-test-subj="roleMappingsJSONEditor" | ||
> | ||
<Fragment> | ||
<EuiCodeEditor | ||
<CodeEditorField | ||
aria-label={''} | ||
mode={'json'} | ||
theme="github" | ||
languageId={XJsonLang.ID} | ||
value={rawRules} | ||
onChange={onRulesChange} | ||
width="100%" | ||
height="auto" | ||
minLines={6} | ||
maxLines={30} | ||
isReadOnly={false} | ||
setOptions={{ | ||
showLineNumbers: true, | ||
fullWidth={true} | ||
height="300px" | ||
Comment on lines
-87
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This component doesn't support |
||
options={{ | ||
accessibilitySupport: 'off', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disabling None of these should be used when editing code. It just causes frustration when typing. Seeing as this is also an optional UI for editing role mappings, I think it's safe to disable |
||
lineNumbers: 'on', | ||
fontSize: 12, | ||
tabSize: 2, | ||
automaticLayout: true, | ||
minimap: { enabled: false }, | ||
overviewRulerBorder: false, | ||
scrollbar: { alwaysConsumeMouseWheel: false }, | ||
scrollBeyondLastLine: false, | ||
wordWrap: 'on', | ||
wrappingIndent: 'indent', | ||
}} | ||
editorProps={{ | ||
$blockScrolling: Infinity, | ||
}} | ||
showGutter={true} | ||
/> | ||
<EuiSpacer size="s" /> | ||
<EuiButton iconType="broom" onClick={reformatRules} size="s"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jest uses jsdom to render components, but Monaco requires a canvas. Instead of installing a separate package just to use for this test, I opted for a shallow render which still allows us to exercise these unit test cases.
Note that to use a shallow mock this has to be the top level component, so as a result I had to mock
useKibana()
.