31
31
import '../../ui/legacy/components/data_grid/data_grid.js' ;
32
32
33
33
import * as i18n from '../../core/i18n/i18n.js' ;
34
- import type * as Platform from '../../core/platform/platform.js' ;
34
+ import * as Platform from '../../core/platform/platform.js' ;
35
35
import * as UI from '../../ui/legacy/legacy.js' ;
36
36
import { Directives , html , render } from '../../ui/lit/lit.js' ;
37
37
38
38
import editFileSystemViewStyles from './editFileSystemView.css.js' ;
39
- import { IsolatedFileSystemManager } from './IsolatedFileSystemManager.js' ;
40
39
import type { PlatformFileSystem } from './PlatformFileSystem.js' ;
41
40
42
41
const { styleMap} = Directives ;
@@ -132,28 +131,37 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
132
131
} ;
133
132
134
133
export class EditFileSystemView extends UI . Widget . VBox {
135
- readonly #fileSystemPath: Platform . DevToolsPath . UrlString ;
134
+ #fileSystem?: PlatformFileSystem ;
136
135
#excludedFolderPaths: PathWithStatus [ ] = [ ] ;
137
136
readonly #view: View ;
138
137
139
- constructor ( fileSystemPath : Platform . DevToolsPath . UrlString , view : View = DEFAULT_VIEW ) {
138
+ constructor ( view : View = DEFAULT_VIEW ) {
140
139
super ( ) ;
141
- this . #fileSystemPath = fileSystemPath ;
142
140
this . #view = view ;
143
141
}
144
142
143
+ set fileSystem ( fileSystem : PlatformFileSystem ) {
144
+ this . #fileSystem = fileSystem ;
145
+ this . #resyncExcludedFolderPaths( ) ;
146
+ this . requestUpdate ( ) ;
147
+ }
148
+
145
149
override wasShown ( ) : void {
146
- this . #excludedFolderPaths = this . #getFileSystem( )
147
- . excludedFolders ( )
150
+ this . #resyncExcludedFolderPaths( ) ;
151
+ this . requestUpdate ( ) ;
152
+ }
153
+
154
+ #resyncExcludedFolderPaths( ) : void {
155
+ this . #excludedFolderPaths = this . #fileSystem?. excludedFolders ( )
148
156
. values ( )
149
157
. map ( path => ( { path, status : ExcludedFolderStatus . VALID } ) )
150
- . toArray ( ) ;
151
- this . requestUpdate ( ) ;
158
+ . toArray ( ) ??
159
+ [ ] ;
152
160
}
153
161
154
162
override performUpdate ( ) : void {
155
163
const input : EditFileSystemViewInput = {
156
- fileSystemPath : this . #fileSystemPath ,
164
+ fileSystemPath : this . #fileSystem ?. path ( ) ?? Platform . DevToolsPath . urlString `` ,
157
165
excludedFolderPaths : this . #excludedFolderPaths,
158
166
onCreate : e => this . #onCreate( e . detail . url ) ,
159
167
onEdit : e => this . #onEdit( e . detail . node . dataset . index ?? '-1' , e . detail . valueBeforeEditing , e . detail . newText ) ,
@@ -172,7 +180,7 @@ export class EditFileSystemView extends UI.Widget.VBox {
172
180
const pathWithStatus = this . #validateFolder( url ) ;
173
181
this . #excludedFolderPaths. push ( pathWithStatus ) ;
174
182
if ( pathWithStatus . status === ExcludedFolderStatus . VALID ) {
175
- this . #getFileSystem ( ) . addExcludedFolder ( pathWithStatus . path ) ;
183
+ this . #fileSystem ? .addExcludedFolder ( pathWithStatus . path ) ;
176
184
}
177
185
178
186
this . requestUpdate ( ) ;
@@ -189,11 +197,11 @@ export class EditFileSystemView extends UI.Widget.VBox {
189
197
this . #excludedFolderPaths[ index ] = pathWithStatus ;
190
198
191
199
if ( oldPathWithStatus . status === ExcludedFolderStatus . VALID ) {
192
- this . #getFileSystem ( ) . removeExcludedFolder ( valueBeforeEditing as Platform . DevToolsPath . EncodedPathString ) ;
200
+ this . #fileSystem ? .removeExcludedFolder ( valueBeforeEditing as Platform . DevToolsPath . EncodedPathString ) ;
193
201
}
194
202
195
203
if ( pathWithStatus . status === ExcludedFolderStatus . VALID ) {
196
- this . #getFileSystem ( ) . addExcludedFolder ( pathWithStatus . path ) ;
204
+ this . #fileSystem ? .addExcludedFolder ( pathWithStatus . path ) ;
197
205
}
198
206
199
207
this . requestUpdate ( ) ;
@@ -205,7 +213,7 @@ export class EditFileSystemView extends UI.Widget.VBox {
205
213
return ;
206
214
}
207
215
208
- this . #getFileSystem ( ) . removeExcludedFolder ( this . #excludedFolderPaths[ index ] . path ) ;
216
+ this . #fileSystem ? .removeExcludedFolder ( this . #excludedFolderPaths[ index ] . path ) ;
209
217
this . #excludedFolderPaths. splice ( index , 1 ) ;
210
218
211
219
this . requestUpdate ( ) ;
@@ -230,8 +238,4 @@ export class EditFileSystemView extends UI.Widget.VBox {
230
238
}
231
239
return prefix + ( prefix [ prefix . length - 1 ] === '/' ? '' : '/' ) ;
232
240
}
233
-
234
- #getFileSystem( ) : PlatformFileSystem {
235
- return IsolatedFileSystemManager . instance ( ) . fileSystem ( this . #fileSystemPath) as PlatformFileSystem ;
236
- }
237
241
}
0 commit comments