@@ -256,18 +256,31 @@ export function addCommands(
256
256
label : trans . __ ( 'Save As...' ) ,
257
257
isEnabled : ( ) => true ,
258
258
execute : async ( ) => {
259
- const oldFilename = tracker . currentWidget ?. model . filePath ;
260
- const newFilename = ( await InputDialog . getText ( {
261
- title : 'Save as...' ,
262
- label : 'New filename' ,
263
- placeholder : oldFilename ,
264
- } ) ) . value ;
259
+ if ( ! tracker . currentWidget ) {
260
+ return ;
261
+ }
262
+
263
+ const model = tracker . currentWidget . model ;
264
+ const oldFilename = model . filePath ;
265
+ let newFilename = (
266
+ await InputDialog . getText ( {
267
+ title : 'Save as...' ,
268
+ label : 'New filename' ,
269
+ placeholder : oldFilename
270
+ } )
271
+ ) . value ;
265
272
266
273
if ( ! newFilename ) {
267
274
return ;
268
275
}
269
276
270
- const content = tracker . currentWidget ?. model . toJSON ( ) ;
277
+ if ( newFilename . toLowerCase ( ) . endsWith ( '.qgz' ) ) {
278
+ throw Error ( 'Not supported yet' ) ;
279
+ } else if ( ! newFilename . toLowerCase ( ) . endsWith ( '.jgis' ) ) {
280
+ newFilename += '.jGIS' ;
281
+ }
282
+
283
+ const content = model . toJSON ( ) ;
271
284
272
285
// FIXME: This doesn't re-open the project file in the current view where the save button was clicked.
273
286
app . serviceManager . contents . save ( newFilename , {
@@ -276,9 +289,11 @@ export function addCommands(
276
289
type : 'file' ,
277
290
mimetype : 'text/json'
278
291
} ) ;
292
+ // FIXME: The widget will only save to this new filename once, as opposed to continuously saving changes to the file like we expect.
293
+ model . filePath = newFilename ;
294
+
279
295
// FIXME: Saves to the currently open directory, while the above save is to the JupyterLab root directory.
280
296
// FIXME: Get "unsaved_project" from a constant
281
- // FIXME: unsaved_project is getting saved even though we're trying not to!
282
297
if ( oldFilename && ! oldFilename . endsWith ( 'unsaved_project' ) ) {
283
298
app . serviceManager . contents . save ( oldFilename , {
284
299
content : JSON . stringify ( content ) ,
0 commit comments