11// Libraries
2- import React , { FC , useEffect , useRef , useContext } from 'react'
2+ import React , { FC , useEffect , useRef , useContext , useMemo } from 'react'
33import { useSelector } from 'react-redux'
4+ import { useRouteMatch } from 'react-router-dom'
45import classnames from 'classnames'
56
67// Components
@@ -67,6 +68,9 @@ const FluxEditorMonaco: FC<Props> = ({
6768 const { setEditor} = useContext ( EditorContext )
6869 const isFluxQueryBuilder = useSelector ( fluxQueryBuilder )
6970 const sessionStore = useContext ( PersistanceContext )
71+ const { path} = useRouteMatch ( )
72+ const isNewQxBuilder =
73+ isFluxQueryBuilder && path === '/orgs/:orgID/data-explorer'
7074
7175 const wrapperClassName = classnames ( 'flux-editor--monaco' , {
7276 'flux-editor--monaco__autogrow' : autogrow ,
@@ -79,7 +83,7 @@ const FluxEditorMonaco: FC<Props> = ({
7983 useEffect ( ( ) => {
8084 if (
8185 connection . current &&
82- isFluxQueryBuilder &&
86+ isNewQxBuilder &&
8387 isFlagEnabled ( 'schemaComposition' )
8488 ) {
8589 connection . current . onSchemaSessionChange (
@@ -130,36 +134,41 @@ const FluxEditorMonaco: FC<Props> = ({
130134 onChangeScript ( text )
131135 }
132136
133- return (
134- < ErrorBoundary >
135- < div className = { wrapperClassName } data-testid = "flux-editor" >
136- < MonacoEditor
137- language = { FLUXLANGID }
138- theme = { THEME_NAME }
139- value = { script }
140- onChange = { onChange }
141- options = { {
142- fontSize : 13 ,
143- fontFamily : '"IBMPlexMono", monospace' ,
144- cursorWidth : 2 ,
145- lineNumbersMinChars : 4 ,
146- lineDecorationsWidth : 0 ,
147- minimap : {
148- renderCharacters : false ,
149- } ,
150- overviewRulerBorder : false ,
151- automaticLayout : true ,
152- readOnly : readOnly || false ,
153- wordWrap : wrapLines ?? 'off' ,
154- scrollBeyondLastLine : false ,
155- } }
156- editorDidMount = { editorDidMount }
157- />
158- < div id = { ICON_SYNC_ID } className = "sync-bar" >
159- < Icon glyph = { IconFont . Sync } className = "sync-icon" />
137+ return useMemo (
138+ ( ) => (
139+ < ErrorBoundary >
140+ < div className = { wrapperClassName } data-testid = "flux-editor" >
141+ < MonacoEditor
142+ language = { FLUXLANGID }
143+ theme = { THEME_NAME }
144+ value = { script }
145+ onChange = { onChange }
146+ options = { {
147+ fontSize : 13 ,
148+ fontFamily : '"IBMPlexMono", monospace' ,
149+ cursorWidth : 2 ,
150+ lineNumbersMinChars : 4 ,
151+ lineDecorationsWidth : 0 ,
152+ minimap : {
153+ renderCharacters : false ,
154+ } ,
155+ overviewRulerBorder : false ,
156+ automaticLayout : true ,
157+ readOnly : readOnly || false ,
158+ wordWrap : wrapLines ?? 'off' ,
159+ scrollBeyondLastLine : false ,
160+ } }
161+ editorDidMount = { editorDidMount }
162+ />
163+ { isNewQxBuilder && (
164+ < div id = { ICON_SYNC_ID } className = "sync-bar" >
165+ < Icon glyph = { IconFont . Sync } className = "sync-icon" />
166+ </ div >
167+ ) }
160168 </ div >
161- </ div >
162- </ ErrorBoundary >
169+ </ ErrorBoundary >
170+ ) ,
171+ [ onChangeScript , setEditor ]
163172 )
164173}
165174
0 commit comments