@@ -20,10 +20,7 @@ import {
2020 chatIcon ,
2121 readIcon
2222} from '@jupyter/chat' ;
23- import {
24- ICollaborativeDrive ,
25- SharedDocumentFactory
26- } from '@jupyter/collaborative-drive' ;
23+ import { ICollaborativeContentProvider } from '@jupyter/collaborative-drive' ;
2724import {
2825 ILayoutRestorer ,
2926 JupyterFrontEnd ,
@@ -114,7 +111,7 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
114111 IActiveCellManagerToken ,
115112 IAttachmentOpenerRegistry ,
116113 IChatCommandRegistry ,
117- ICollaborativeDrive ,
114+ ICollaborativeContentProvider ,
118115 IDefaultFileBrowser ,
119116 IInputToolbarRegistryFactory ,
120117 ILayoutRestorer ,
@@ -133,7 +130,7 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
133130 activeCellManager : IActiveCellManager | null ,
134131 attachmentOpenerRegistry : IAttachmentOpenerRegistry ,
135132 chatCommandRegistry : IChatCommandRegistry ,
136- drive : ICollaborativeDrive | null ,
133+ drive : ICollaborativeContentProvider | null ,
137134 filebrowser : IDefaultFileBrowser | null ,
138135 inputToolbarFactory : IInputToolbarRegistryFactory ,
139136 restorer : ILayoutRestorer | null ,
@@ -175,11 +172,11 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
175172 previousDirectory &&
176173 previousDirectory !== currentDirectory
177174 ) {
178- drive
175+ app . serviceManager . contents
179176 . get ( previousDirectory )
180177 . then ( contentModel => {
181178 if ( contentModel . content . length === 0 ) {
182- drive . delete ( previousDirectory ) . catch ( e => {
179+ app . serviceManager . contents . delete ( previousDirectory ) . catch ( e => {
183180 // no-op, the directory might not be empty
184181 } ) ;
185182 }
@@ -194,18 +191,18 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
194191 Promise . resolve ( null ) ;
195192
196193 if ( drive && currentDirectory && previousDirectory !== currentDirectory ) {
197- directoryCreation = drive
194+ directoryCreation = app . serviceManager . contents
198195 . get ( currentDirectory , { content : false } )
199196 . catch ( async ( ) => {
200- return drive
197+ return app . serviceManager . contents
201198 . newUntitled ( {
202199 type : 'directory'
203200 } )
204201 . then ( async contentModel => {
205- return drive
202+ return app . serviceManager . contents
206203 . rename ( contentModel . path , currentDirectory )
207204 . catch ( e => {
208- drive . delete ( contentModel . path ) ;
205+ app . serviceManager . contents . delete ( contentModel . path ) ;
209206 throw new Error ( e ) ;
210207 } ) ;
211208 } )
@@ -270,9 +267,7 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
270267 app . docRegistry . addFileType ( chatFileType ) ;
271268
272269 if ( drive ) {
273- const chatFactory : SharedDocumentFactory = ( ) => {
274- return YChat . create ( ) ;
275- } ;
270+ const chatFactory = ( ) => YChat . create ( ) ;
276271 drive . sharedModelFactory . registerDocumentFactory ( 'chat' , chatFactory ) ;
277272 }
278273
@@ -364,7 +359,7 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
364359 id : pluginIds . chatCommands ,
365360 description : 'The commands to create or open a chat.' ,
366361 autoStart : true ,
367- requires : [ ICollaborativeDrive , IChatFactory ] ,
362+ requires : [ ICollaborativeContentProvider , IChatFactory ] ,
368363 optional : [
369364 IActiveCellManagerToken ,
370365 IChatPanel ,
@@ -375,7 +370,7 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
375370 ] ,
376371 activate : (
377372 app : JupyterFrontEnd ,
378- drive : ICollaborativeDrive ,
373+ drive : ICollaborativeContentProvider ,
379374 factory : IChatFactory ,
380375 activeCellManager : IActiveCellManager | null ,
381376 chatPanel : ChatPanel | null ,
@@ -434,23 +429,29 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
434429
435430 let fileExist = true ;
436431 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+ } ) ;
440437 } else {
441438 fileExist = false ;
442439 }
443440
444441 // Create a new file if it does not exists
445442 if ( ! fileExist ) {
446443 // 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+ } ) ;
451449 // Rename it if a name has been provided.
452450 if ( filepath ) {
453- model = await drive . rename ( model . path , filepath ) ;
451+ model = await app . serviceManager . contents . rename (
452+ model . path ,
453+ filepath
454+ ) ;
454455 }
455456
456457 if ( ! model ) {
@@ -470,7 +471,8 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
470471 } ) ;
471472 } else {
472473 commands . execute ( 'docmanager:open' , {
473- path : `RTC:${ filepath } ` ,
474+ // TODO: support JCollab v3 by optionally prefixing 'RTC:'
475+ path : `${ filepath } ` ,
474476 factory : FACTORY
475477 } ) ;
476478 }
@@ -553,9 +555,11 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
553555 }
554556
555557 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+ } ) ;
559563
560564 if ( ! fileExist ) {
561565 showErrorMessage (
@@ -589,7 +593,7 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
589593 return ;
590594 }
591595
592- const model = await drive . get ( filepath ) ;
596+ const model = await app . serviceManager . contents . get ( filepath ) ;
593597
594598 // Create a share model from the chat file
595599 const sharedModel = drive . sharedModelFactory . createNew ( {
@@ -618,8 +622,9 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
618622 factory . tracker . add ( widget ) ;
619623 } else {
620624 // The chat is opened in the main area
625+ // TODO: support JCollab v3 by optionally prefixing 'RTC:'
621626 commands . execute ( 'docmanager:open' , {
622- path : `RTC: ${ filepath } ` ,
627+ path : `${ filepath } ` ,
623628 factory : FACTORY
624629 } ) ;
625630 }
@@ -668,7 +673,7 @@ const chatPanel: JupyterFrontEndPlugin<ChatPanel> = {
668673 description : 'The chat panel widget.' ,
669674 autoStart : true ,
670675 provides : IChatPanel ,
671- requires : [ IChatFactory , ICollaborativeDrive , IRenderMimeRegistry ] ,
676+ requires : [ IChatFactory , ICollaborativeContentProvider , IRenderMimeRegistry ] ,
672677 optional : [
673678 IAttachmentOpenerRegistry ,
674679 IChatCommandRegistry ,
@@ -681,7 +686,7 @@ const chatPanel: JupyterFrontEndPlugin<ChatPanel> = {
681686 activate : (
682687 app : JupyterFrontEnd ,
683688 factory : IChatFactory ,
684- drive : ICollaborativeDrive ,
689+ drive : ICollaborativeContentProvider ,
685690 rmRegistry : IRenderMimeRegistry ,
686691 attachmentOpenerRegistry : IAttachmentOpenerRegistry ,
687692 chatCommandRegistry : IChatCommandRegistry ,
@@ -700,7 +705,7 @@ const chatPanel: JupyterFrontEndPlugin<ChatPanel> = {
700705 */
701706 const chatPanel = new ChatPanel ( {
702707 commands,
703- drive ,
708+ contentsManager : app . serviceManager . contents ,
704709 rmRegistry,
705710 themeManager,
706711 defaultDirectory,
0 commit comments