@@ -17,7 +17,7 @@ import { parseMongoDocuments, parseMongoQuery } from '@/lib/mongoQueryLang'
1717import { serializeMongoValue } from '@/lib/mongoQuerySerialize'
1818import type { DocumentEnvelope , UuidEncoding } from '@shared/types'
1919
20- export type EditorMode = 'view' | 'edit' | 'duplicate' | 'insert' | 'insert-many'
20+ export type EditorMode = 'view' | 'edit' | 'duplicate' | 'insert'
2121
2222type Props = {
2323 mode : EditorMode | null
@@ -36,22 +36,18 @@ const TITLES: Record<EditorMode, string> = {
3636 view : 'View document' ,
3737 edit : 'Edit document' ,
3838 duplicate : 'Duplicate document' ,
39- insert : 'Insert document' ,
40- 'insert-many' : 'Insert documents'
39+ insert : 'Insert documents'
4140}
4241
4342const DESCRIPTIONS : Record < EditorMode , string > = {
4443 view : 'Read-only — BSON types render as ObjectId / ISODate / UUID / NumberLong / NumberDecimal.' ,
4544 edit : 'Edit using mongo shell syntax — ObjectId("…"), ISODate("…"), NumberLong("…"), UUID/JUUID, regex literals.' ,
4645 duplicate : 'A copy with the original _id removed. Save inserts a new document with a fresh _id.' ,
4746 insert :
48- 'New document — mongo shell syntax. Leave _id out and the server will assign a fresh ObjectId.' ,
49- 'insert-many' :
5047 'Multiple documents, one after another newline, comma-separated or JSON array. Leave _id out for a fresh ObjectId.'
5148}
5249
5350const INSERT_TEMPLATE = '{\n \n}'
54- const INSERT_MANY_TEMPLATE = '{\n \n}\n{\n \n}'
5551
5652/**
5753 * Read the canonical EJSON document carried by an envelope, then re-render
@@ -99,7 +95,7 @@ export function DocumentEditorDialog({
9995 timezone,
10096 onClose
10197} : Props ) {
102- const open = mode !== null && ( mode === 'insert' || mode === 'insert-many' || envelope !== null )
98+ const open = mode !== null && ( mode === 'insert' || envelope !== null )
10399 const [ value , setValue ] = useState ( '' )
104100 const [ serverError , setServerError ] = useState < string | null > ( null )
105101 const queryClient = useQueryClient ( )
@@ -111,10 +107,6 @@ export function DocumentEditorDialog({
111107 setValue ( INSERT_TEMPLATE )
112108 return
113109 }
114- if ( mode === 'insert-many' ) {
115- setValue ( INSERT_MANY_TEMPLATE )
116- return
117- }
118110 if ( ! envelope ) return
119111 const rendered = shellRenderOf ( envelope , uuidEncoding , timezone )
120112 setValue ( mode === 'duplicate' ? stripIdShell ( rendered , uuidEncoding , timezone ) : rendered )
@@ -124,7 +116,7 @@ export function DocumentEditorDialog({
124116 { ok : true ; ejson : string ; documents : string [ ] } | { ok : false ; error : string }
125117 > ( ( ) => {
126118 if ( mode === 'view' || mode === null ) return { ok : true , ejson : '' , documents : [ ] }
127- if ( mode === 'insert-many ' ) {
119+ if ( mode === 'insert' ) {
128120 const parsed = parseMongoDocuments ( value )
129121 if ( ! parsed . ok ) return { ok : false , error : parsed . error }
130122 if ( parsed . documents . length === 0 ) return { ok : false , error : 'Enter at least one document' }
@@ -155,10 +147,10 @@ export function DocumentEditorDialog({
155147 replacement : compiled . ejson
156148 } )
157149 }
158- if ( mode === 'insert-many ' ) {
150+ if ( mode === 'insert' ) {
159151 return api . query . insertMany ( { connectionId, db, coll, documents : compiled . documents } )
160152 }
161- if ( mode === 'duplicate' || mode === 'insert' ) {
153+ if ( mode === 'duplicate' ) {
162154 return api . query . insertOne ( { connectionId, db, coll, document : compiled . ejson } )
163155 }
164156 throw new Error ( 'Cannot save in view mode' )
@@ -171,9 +163,7 @@ export function DocumentEditorDialog({
171163 ? 'Document updated'
172164 : mode === 'duplicate'
173165 ? 'Document duplicated'
174- : mode === 'insert-many'
175- ? `Inserted ${ manyCount } document${ manyCount === 1 ? '' : 's' } `
176- : 'Document inserted'
166+ : `Inserted ${ manyCount } document${ manyCount === 1 ? '' : 's' } `
177167 toast . success ( successMessage )
178168 onClose ( )
179169 } ,
@@ -190,7 +180,7 @@ export function DocumentEditorDialog({
190180 if ( ! mode ) return null
191181
192182 // Insert needs neither envelope nor _id; the others can't render without one.
193- if ( mode !== 'insert' && mode !== 'insert-many' && ! envelope ) return null
183+ if ( mode !== 'insert' && ! envelope ) return null
194184
195185 const parseError = compiled . ok ? null : compiled . error
196186 const isReadOnly = mode === 'view'
@@ -199,11 +189,9 @@ export function DocumentEditorDialog({
199189 ? 'Save changes'
200190 : mode === 'duplicate'
201191 ? 'Insert duplicate'
202- : mode === 'insert-many'
203- ? manyCount > 0
204- ? `Insert ${ manyCount } document${ manyCount === 1 ? '' : 's' } `
205- : 'Insert documents'
206- : 'Insert document'
192+ : manyCount > 0
193+ ? `Insert ${ manyCount } document${ manyCount === 1 ? '' : 's' } `
194+ : 'Insert documents'
207195
208196 return (
209197 < Dialog open = { open } onOpenChange = { handleOpenChange } >
@@ -235,7 +223,7 @@ export function DocumentEditorDialog({
235223 }
236224 >
237225 < Editor
238- key = { mode === 'insert' || mode === 'insert-many' ? mode : `${ envelope ?. id } ::${ mode } ` }
226+ key = { mode === 'insert' ? 'insert' : `${ envelope ?. id } ::${ mode } ` }
239227 height = "100%"
240228 width = "100%"
241229 value = { value }
0 commit comments