@@ -6,6 +6,7 @@ import { openToast } from '@mongodb-js/compass-components';
66import { isEqual , pick } from 'lodash' ;
77import { disableEditRules } from './edit-mode' ;
88import { isAction } from '../util' ;
9+ import { IS_ZERO_STATE_CHANGED , IsZeroStateChangedAction } from './zero-state' ;
910
1011export type ValidationServerAction = 'error' | 'warn' ;
1112export type ValidationLevel = 'off' | 'moderate' | 'strict' ;
@@ -91,17 +92,17 @@ export const VALIDATION_TEMPLATE = `/**
9192 * More information on schema validation rules can be found at:
9293 * https://www.mongodb.com/docs/manual/core/schema-validation/
9394 */
94- {
95+ {
9596 $jsonSchema: {
96- title: "Library.books",
97- bsonType: "object",
97+ title: "Library.books",
98+ bsonType: "object",
9899 required: ["fieldname1", "fieldname2"],
99100 properties: {
100- fieldname1: {
101+ fieldname1: {
101102 bsonType: "string",
102103 description: "Fieldname1 must be a string",
103104 },
104- fieldname2: {
105+ fieldname2: {
105106 bsonType: "int",
106107 description: "Fieldname2 must be an integer",
107108 },
@@ -210,7 +211,7 @@ export default function reducer(
210211 ) {
211212 return {
212213 ...state ,
213- isChanged : true ,
214+ isChanged : false ,
214215 error : null ,
215216 syntaxError : null ,
216217 ...DEFAULT_VALIDATION ,
@@ -285,6 +286,13 @@ export default function reducer(
285286 } ;
286287 }
287288
289+ if ( isAction < IsZeroStateChangedAction > ( action , IS_ZERO_STATE_CHANGED ) ) {
290+ return {
291+ ...state ,
292+ isChanged : true ,
293+ } ;
294+ }
295+
288296 if (
289297 isAction < ValidationLevelChangedAction > (
290298 action ,
0 commit comments