11import type { RootAction , RootState , SchemaValidationThunkAction } from '.' ;
2- import { EJSON } from 'bson' ;
2+ import { EJSON , ObjectId } from 'bson' ;
33import { parseFilter } from 'mongodb-query-parser' ;
44import { stringify as javascriptStringify } from 'javascript-stringify' ;
5+ import { openToast } from '@mongodb-js/compass-components' ;
56import { clearSampleDocuments } from './sample-documents' ;
67import { zeroStateChanged } from './zero-state' ;
78import { isLoadedChanged } from './is-loaded' ;
@@ -475,6 +476,12 @@ export const saveValidation = (
475476 validation_action : validation . validationAction ,
476477 validation_level : validation . validationLevel ,
477478 } ;
479+ const toastId = `schema-validation-update-${ new ObjectId ( ) . toString ( ) } ` ;
480+
481+ openToast ( toastId , {
482+ title : 'Updating validation rules…' ,
483+ variant : 'progress' ,
484+ } ) ;
478485 track ( 'Schema Validation Updated' , trackEvent , connectionInfoRef . current ) ;
479486 try {
480487 await dataService . updateCollection (
@@ -486,8 +493,17 @@ export const saveValidation = (
486493 }
487494 ) ;
488495 dispatch ( fetchValidation ( namespace ) ) ;
496+ openToast ( toastId , {
497+ title : 'New validation rules applied' ,
498+ variant : 'success' ,
499+ } ) ;
489500 } catch ( error ) {
490501 dispatch ( validationSaveFailed ( error as Error ) ) ;
502+ openToast ( toastId , {
503+ title : 'Failed to update validation rules' ,
504+ description : ( error as Error ) ?. message ?? 'An unknown error occurred' ,
505+ variant : 'warning' ,
506+ } ) ;
491507 }
492508 } ;
493509} ;
0 commit comments