@@ -2,7 +2,6 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
22import { debounce } from 'lodash' ;
33import { connect } from 'react-redux' ;
44import { useTelemetry } from '@mongodb-js/compass-telemetry/provider' ;
5- import type { BannerVariant } from '@mongodb-js/compass-components' ;
65import {
76 css ,
87 cx ,
@@ -112,6 +111,7 @@ const ValidationCodeEditor = ({
112111 text = { text }
113112 onChangeText = { onChangeText }
114113 readOnly = { readOnly }
114+ formattable = { ! readOnly }
115115 completer = { completer }
116116 />
117117 ) ;
@@ -214,19 +214,6 @@ export const ValidationEditor: React.FunctionComponent<
214214 const { validationAction, validationLevel, error, syntaxError, isChanged } =
215215 validation ;
216216
217- const hasErrors = ! ! ( error || syntaxError ) ;
218-
219- let message = '' ;
220- let variant : BannerVariant = 'info' ;
221-
222- if ( syntaxError ) {
223- message = syntaxError . message ;
224- variant = 'danger' ;
225- } else if ( error ) {
226- message = error . message ;
227- variant = 'warning' ;
228- }
229-
230217 const onClickApplyValidation = useCallback ( async ( ) => {
231218 const confirmed = await showConfirmation ( {
232219 title : 'Are you sure you want to apply these validation rules?' ,
@@ -273,7 +260,10 @@ export const ValidationEditor: React.FunctionComponent<
273260 serverVersion = { serverVersion }
274261 />
275262 </ div >
276- { variant && message && < Banner variant = { variant } > { message } </ Banner > }
263+ { syntaxError && < Banner variant = "danger" > { syntaxError . message } </ Banner > }
264+ { ! syntaxError && error && (
265+ < Banner variant = "danger" > { error . message } </ Banner >
266+ ) }
277267 { isEditable && (
278268 < div className = { actionsStyles } >
279269 { isEditingEnabled ? (
@@ -308,7 +298,7 @@ export const ValidationEditor: React.FunctionComponent<
308298 onClick = { ( ) => {
309299 void onClickApplyValidation ( ) ;
310300 } }
311- disabled = { hasErrors }
301+ disabled = { ! ! syntaxError }
312302 >
313303 Apply
314304 </ Button >
@@ -322,7 +312,7 @@ export const ValidationEditor: React.FunctionComponent<
322312 data-testid = "enable-edit-validation-button"
323313 onClick = { onClickEnableEditRules }
324314 >
325- Edit Rules
315+ Edit rules
326316 </ Button >
327317 ) }
328318 </ div >
0 commit comments