@@ -89,13 +89,30 @@ export async function activateAddDrivesPlugin(
89
89
bananaDrive . provider = '' ;
90
90
manager . services . contents . addDrive ( bananaDrive ) ;
91
91
const driveList : Drive [ ] = [ cocoDrive , bananaDrive ] ;
92
+
92
93
function camelCaseToDashedCase ( name : string ) {
93
94
if ( name !== name . toLowerCase ( ) ) {
94
95
name = name . replace ( / [ A - Z ] / g, m => '-' + m . toLowerCase ( ) ) ;
95
96
}
96
97
return name ;
97
98
}
98
99
100
+ function restoreDriveName ( id : string ) {
101
+ const list1 = id . split ( '-file-' ) ;
102
+ let driveName = list1 [ 0 ] ;
103
+ console . log ( 'driveName:' , driveName ) ;
104
+ for ( let i = 0 ; i < driveName . length ; i ++ ) {
105
+ if ( driveName [ i ] === '-' ) {
106
+ const index = i ;
107
+ const char = driveName . charAt ( index + 1 ) . toUpperCase ( ) ;
108
+ console . log ( 'char:' , char ) ;
109
+ driveName = driveName . replace ( driveName . charAt ( index + 1 ) , char ) ;
110
+ driveName = driveName . replace ( driveName . charAt ( index ) , '' ) ;
111
+ }
112
+ }
113
+ return driveName ;
114
+ }
115
+
99
116
app . commands . addCommand ( CommandIDs . addDriveBrowser , {
100
117
execute : args => {
101
118
function createSidePanel ( driveName : string ) {
@@ -104,6 +121,7 @@ export async function activateAddDrivesPlugin(
104
121
panel . title . iconClass = 'jp-SideBar-tabIcon' ;
105
122
panel . title . caption = 'Browse Drives' ;
106
123
panel . id = camelCaseToDashedCase ( driveName ) + '-file-browser' ;
124
+
107
125
app . shell . add ( panel , 'left' , { rank : 102 } ) ;
108
126
if ( restorer ) {
109
127
restorer . add ( panel , driveName + '-browser' ) ;
@@ -159,6 +177,14 @@ export async function activateAddDrivesPlugin(
159
177
execute : args => {
160
178
if ( test !== undefined ) {
161
179
const node = app . contextMenuHitTest ( test ) ;
180
+ if ( node ?. dataset . id ) {
181
+ const driveName = restoreDriveName ( node ?. dataset . id ) ;
182
+ driveList . forEach ( drive => {
183
+ if ( drive . name === driveName ) {
184
+ drive . dispose ( ) ;
185
+ }
186
+ } ) ;
187
+ }
162
188
const panelToDispose = Array . from ( app . shell . widgets ( 'left' ) ) . find (
163
189
widget => widget . id === node ?. dataset . id
164
190
) ;
0 commit comments