@@ -20,10 +20,7 @@ import {
20
20
chatIcon ,
21
21
readIcon
22
22
} from '@jupyter/chat' ;
23
- import {
24
- ICollaborativeDrive ,
25
- SharedDocumentFactory
26
- } from '@jupyter/collaborative-drive' ;
23
+ import { ICollaborativeContentProvider } from '@jupyter/collaborative-drive' ;
27
24
import {
28
25
ILayoutRestorer ,
29
26
JupyterFrontEnd ,
@@ -114,7 +111,7 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
114
111
IActiveCellManagerToken ,
115
112
IAttachmentOpenerRegistry ,
116
113
IChatCommandRegistry ,
117
- ICollaborativeDrive ,
114
+ ICollaborativeContentProvider ,
118
115
IDefaultFileBrowser ,
119
116
IInputToolbarRegistryFactory ,
120
117
ILayoutRestorer ,
@@ -133,7 +130,7 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
133
130
activeCellManager : IActiveCellManager | null ,
134
131
attachmentOpenerRegistry : IAttachmentOpenerRegistry ,
135
132
chatCommandRegistry : IChatCommandRegistry ,
136
- drive : ICollaborativeDrive | null ,
133
+ drive : ICollaborativeContentProvider | null ,
137
134
filebrowser : IDefaultFileBrowser | null ,
138
135
inputToolbarFactory : IInputToolbarRegistryFactory ,
139
136
restorer : ILayoutRestorer | null ,
@@ -175,11 +172,11 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
175
172
previousDirectory &&
176
173
previousDirectory !== currentDirectory
177
174
) {
178
- drive
175
+ app . serviceManager . contents
179
176
. get ( previousDirectory )
180
177
. then ( contentModel => {
181
178
if ( contentModel . content . length === 0 ) {
182
- drive . delete ( previousDirectory ) . catch ( e => {
179
+ app . serviceManager . contents . delete ( previousDirectory ) . catch ( e => {
183
180
// no-op, the directory might not be empty
184
181
} ) ;
185
182
}
@@ -194,18 +191,18 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
194
191
Promise . resolve ( null ) ;
195
192
196
193
if ( drive && currentDirectory && previousDirectory !== currentDirectory ) {
197
- directoryCreation = drive
194
+ directoryCreation = app . serviceManager . contents
198
195
. get ( currentDirectory , { content : false } )
199
196
. catch ( async ( ) => {
200
- return drive
197
+ return app . serviceManager . contents
201
198
. newUntitled ( {
202
199
type : 'directory'
203
200
} )
204
201
. then ( async contentModel => {
205
- return drive
202
+ return app . serviceManager . contents
206
203
. rename ( contentModel . path , currentDirectory )
207
204
. catch ( e => {
208
- drive . delete ( contentModel . path ) ;
205
+ app . serviceManager . contents . delete ( contentModel . path ) ;
209
206
throw new Error ( e ) ;
210
207
} ) ;
211
208
} )
@@ -270,9 +267,7 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
270
267
app . docRegistry . addFileType ( chatFileType ) ;
271
268
272
269
if ( drive ) {
273
- const chatFactory : SharedDocumentFactory = ( ) => {
274
- return YChat . create ( ) ;
275
- } ;
270
+ const chatFactory = ( ) => YChat . create ( ) ;
276
271
drive . sharedModelFactory . registerDocumentFactory ( 'chat' , chatFactory ) ;
277
272
}
278
273
@@ -364,7 +359,7 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
364
359
id : pluginIds . chatCommands ,
365
360
description : 'The commands to create or open a chat.' ,
366
361
autoStart : true ,
367
- requires : [ ICollaborativeDrive , IChatFactory ] ,
362
+ requires : [ ICollaborativeContentProvider , IChatFactory ] ,
368
363
optional : [
369
364
IActiveCellManagerToken ,
370
365
IChatPanel ,
@@ -375,7 +370,7 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
375
370
] ,
376
371
activate : (
377
372
app : JupyterFrontEnd ,
378
- drive : ICollaborativeDrive ,
373
+ drive : ICollaborativeContentProvider ,
379
374
factory : IChatFactory ,
380
375
activeCellManager : IActiveCellManager | null ,
381
376
chatPanel : ChatPanel | null ,
@@ -434,23 +429,29 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
434
429
435
430
let fileExist = true ;
436
431
if ( filepath ) {
437
- await drive . get ( filepath , { content : false } ) . catch ( ( ) => {
438
- fileExist = false ;
439
- } ) ;
432
+ await app . serviceManager . contents
433
+ . get ( filepath , { content : false } )
434
+ . catch ( ( ) => {
435
+ fileExist = false ;
436
+ } ) ;
440
437
} else {
441
438
fileExist = false ;
442
439
}
443
440
444
441
// Create a new file if it does not exists
445
442
if ( ! fileExist ) {
446
443
// Create a new untitled chat.
447
- let model : Contents . IModel | null = await drive . newUntitled ( {
448
- type : 'file' ,
449
- ext : chatFileType . extensions [ 0 ]
450
- } ) ;
444
+ let model : Contents . IModel | null =
445
+ await app . serviceManager . contents . newUntitled ( {
446
+ type : 'file' ,
447
+ ext : chatFileType . extensions [ 0 ]
448
+ } ) ;
451
449
// Rename it if a name has been provided.
452
450
if ( filepath ) {
453
- model = await drive . rename ( model . path , filepath ) ;
451
+ model = await app . serviceManager . contents . rename (
452
+ model . path ,
453
+ filepath
454
+ ) ;
454
455
}
455
456
456
457
if ( ! model ) {
@@ -470,7 +471,8 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
470
471
} ) ;
471
472
} else {
472
473
commands . execute ( 'docmanager:open' , {
473
- path : `RTC:${ filepath } ` ,
474
+ // TODO: support JCollab v3 by optionally prefixing 'RTC:'
475
+ path : `${ filepath } ` ,
474
476
factory : FACTORY
475
477
} ) ;
476
478
}
@@ -553,9 +555,11 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
553
555
}
554
556
555
557
let fileExist = true ;
556
- await drive . get ( filepath , { content : false } ) . catch ( ( ) => {
557
- fileExist = false ;
558
- } ) ;
558
+ await app . serviceManager . contents
559
+ . get ( filepath , { content : false } )
560
+ . catch ( ( ) => {
561
+ fileExist = false ;
562
+ } ) ;
559
563
560
564
if ( ! fileExist ) {
561
565
showErrorMessage (
@@ -589,7 +593,7 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
589
593
return ;
590
594
}
591
595
592
- const model = await drive . get ( filepath ) ;
596
+ const model = await app . serviceManager . contents . get ( filepath ) ;
593
597
594
598
// Create a share model from the chat file
595
599
const sharedModel = drive . sharedModelFactory . createNew ( {
@@ -618,8 +622,9 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
618
622
factory . tracker . add ( widget ) ;
619
623
} else {
620
624
// The chat is opened in the main area
625
+ // TODO: support JCollab v3 by optionally prefixing 'RTC:'
621
626
commands . execute ( 'docmanager:open' , {
622
- path : `RTC: ${ filepath } ` ,
627
+ path : `${ filepath } ` ,
623
628
factory : FACTORY
624
629
} ) ;
625
630
}
@@ -668,7 +673,7 @@ const chatPanel: JupyterFrontEndPlugin<ChatPanel> = {
668
673
description : 'The chat panel widget.' ,
669
674
autoStart : true ,
670
675
provides : IChatPanel ,
671
- requires : [ IChatFactory , ICollaborativeDrive , IRenderMimeRegistry ] ,
676
+ requires : [ IChatFactory , ICollaborativeContentProvider , IRenderMimeRegistry ] ,
672
677
optional : [
673
678
IAttachmentOpenerRegistry ,
674
679
IChatCommandRegistry ,
@@ -681,7 +686,7 @@ const chatPanel: JupyterFrontEndPlugin<ChatPanel> = {
681
686
activate : (
682
687
app : JupyterFrontEnd ,
683
688
factory : IChatFactory ,
684
- drive : ICollaborativeDrive ,
689
+ drive : ICollaborativeContentProvider ,
685
690
rmRegistry : IRenderMimeRegistry ,
686
691
attachmentOpenerRegistry : IAttachmentOpenerRegistry ,
687
692
chatCommandRegistry : IChatCommandRegistry ,
@@ -700,7 +705,7 @@ const chatPanel: JupyterFrontEndPlugin<ChatPanel> = {
700
705
*/
701
706
const chatPanel = new ChatPanel ( {
702
707
commands,
703
- drive ,
708
+ contentsManager : app . serviceManager . contents ,
704
709
rmRegistry,
705
710
themeManager,
706
711
defaultDirectory,
0 commit comments