File tree Expand file tree Collapse file tree 1 file changed +19
-11
lines changed
packages/compass-schema-validation/src/components Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 KeylineCard ,
1717 ButtonVariant ,
1818 SpinLoader ,
19+ Tooltip ,
1920} from '@mongodb-js/compass-components' ;
2021import {
2122 CodemirrorMultilineEditor ,
@@ -241,7 +242,7 @@ export const ValidationEditor: React.FunctionComponent<
241242 } , [ showConfirmation ] ) ;
242243
243244 const isEmpty = useMemo < boolean > ( ( ) => {
244- if ( validation . validator . length === 0 ) return true ;
245+ if ( ! validation . validator || validation . validator . length === 0 ) return true ;
245246 try {
246247 return Object . keys ( JSON . parse ( validation . validator ) ) . length === 0 ;
247248 } catch {
@@ -257,17 +258,24 @@ export const ValidationEditor: React.FunctionComponent<
257258 < div className = { validationOptionsStyles } >
258259 { enableExportSchema && (
259260 < div className = { generateButtonContainerStyles } >
260- < Button
261- data-testid = "generate-rules-button"
262- disabled = { ! isEmpty }
263- isLoading = { isRulesGenerationInProgress }
264- loadingIndicator = { < SpinLoader /> }
265- onClick = { generateValidationRules }
266- variant = { ButtonVariant . Primary }
267- size = "small"
261+ < Tooltip
262+ enabled = { ! isEmpty }
263+ trigger = {
264+ < Button
265+ data-testid = "generate-rules-button"
266+ disabled = { ! isEmpty }
267+ isLoading = { isRulesGenerationInProgress }
268+ loadingIndicator = { < SpinLoader /> }
269+ onClick = { generateValidationRules }
270+ variant = { ButtonVariant . Primary }
271+ size = "small"
272+ >
273+ Generate rules
274+ </ Button >
275+ }
268276 >
269- Generate rules
270- </ Button >
277+ Clear existing rules before generating new ones
278+ </ Tooltip >
271279 </ div >
272280 ) }
273281 < ActionSelector
You can’t perform that action at this time.
0 commit comments