Skip to content

Commit 6b607ac

Browse files
committed
chore(schema-validation): add progress toast
1 parent dbce22b commit 6b607ac

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/compass-schema-validation/src/modules/validation.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { RootAction, RootState, SchemaValidationThunkAction } from '.';
2-
import { EJSON } from 'bson';
2+
import { EJSON, ObjectId } from 'bson';
33
import { parseFilter } from 'mongodb-query-parser';
44
import { stringify as javascriptStringify } from 'javascript-stringify';
5+
import { openToast } from '@mongodb-js/compass-components';
56
import { clearSampleDocuments } from './sample-documents';
67
import { zeroStateChanged } from './zero-state';
78
import { 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

Comments
 (0)