44
55import * as i18n from '../../core/i18n/i18n.js' ;
66import type * as Platform from '../../core/platform/platform.js' ;
7+ import * as Cards from '../../ui/components/cards/cards.js' ;
78import * as UI from '../../ui/legacy/legacy.js' ;
89import * as VisualLogging from '../../ui/visual_logging/visual_logging.js' ;
910
@@ -27,11 +28,11 @@ const UIStrings = {
2728 /**
2829 *@description Text of the add button in Workspace Settings Tab of the Workspace settings in Settings
2930 */
30- addFolder : 'Add folder… ' ,
31+ addFolder : 'Add folder' ,
3132 /**
3233 *@description Label element text content in Workspace Settings Tab of the Workspace settings in Settings
3334 */
34- folderExcludePattern : 'Folder exclude pattern ' ,
35+ folderExcludePattern : 'Exclude from workspace ' ,
3536 /**
3637 *@description Label for an item to remove something
3738 */
@@ -42,7 +43,7 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
4243
4344export class WorkspaceSettingsTab extends UI . Widget . VBox {
4445 containerElement : HTMLElement ;
45- private readonly fileSystemsListContainer : HTMLElement ;
46+ #addButtonContainer : HTMLElement ;
4647 private readonly elementByPath : Map < Platform . DevToolsPath . UrlString , Element > ;
4748 private readonly mappingViewByPath : Map < Platform . DevToolsPath . UrlString , EditFileSystemView > ;
4849
@@ -51,12 +52,9 @@ export class WorkspaceSettingsTab extends UI.Widget.VBox {
5152
5253 this . element . setAttribute ( 'jslog' , `${ VisualLogging . pane ( 'workspace' ) } ` ) ;
5354
54- this . element . classList . add ( 'workspace-settings-tab' ) ;
55- const header = this . element . createChild ( 'header' ) ;
56- UI . UIUtils . createTextChild ( header . createChild ( 'h1' ) , i18nString ( UIStrings . workspace ) ) ;
57-
58- this . containerElement = this . element . createChild ( 'div' , 'settings-container-wrapper' )
59- . createChild ( 'div' , 'settings-tab settings-content settings-container' ) ;
55+ this . containerElement =
56+ this . contentElement . createChild ( 'div' , 'settings-card-container-wrapper' ) . createChild ( 'div' ) ;
57+ this . containerElement . classList . add ( 'settings-card-container' ) ;
6058
6159 IsolatedFileSystemManager . instance ( ) . addEventListener (
6260 Events . FileSystemAdded , event => this . fileSystemAdded ( event . data ) , this ) ;
@@ -65,47 +63,52 @@ export class WorkspaceSettingsTab extends UI.Widget.VBox {
6563
6664 const folderExcludePatternInput = this . createFolderExcludePatternInput ( ) ;
6765 folderExcludePatternInput . classList . add ( 'folder-exclude-pattern' ) ;
68- this . containerElement . appendChild ( folderExcludePatternInput ) ;
69-
70- const div = this . containerElement . createChild ( 'div' , 'settings-info-message' ) ;
71- UI . UIUtils . createTextChild ( div , i18nString ( UIStrings . mappingsAreInferredAutomatically ) ) ;
66+ const mappingsAreInferredInfo = document . createElement ( 'div' ) ;
67+ mappingsAreInferredInfo . classList . add ( 'mappings-info' ) ;
68+ UI . UIUtils . createTextChild ( mappingsAreInferredInfo , i18nString ( UIStrings . mappingsAreInferredAutomatically ) ) ;
7269
73- this . fileSystemsListContainer = this . containerElement . createChild ( 'div' , '' ) ;
74-
75- const addButton = UI . UIUtils . createTextButton (
76- i18nString ( UIStrings . addFolder ) , this . addFileSystemClicked . bind ( this ) ,
77- { jslogContext : 'sources.add-folder-to-workspace' } ) ;
78- this . containerElement . appendChild ( addButton ) ;
79- this . setDefaultFocusedElement ( addButton ) ;
70+ const card = new Cards . Card . Card ( ) ;
71+ this . containerElement . appendChild ( card ) ;
72+ card . data = {
73+ heading : i18nString ( UIStrings . workspace ) ,
74+ content : [ folderExcludePatternInput , mappingsAreInferredInfo ] ,
75+ } ;
8076
8177 this . elementByPath = new Map ( ) ;
82-
8378 this . mappingViewByPath = new Map ( ) ;
8479
8580 const fileSystems = IsolatedFileSystemManager . instance ( ) . fileSystems ( ) ;
8681 for ( let i = 0 ; i < fileSystems . length ; ++ i ) {
8782 this . addItem ( fileSystems [ i ] ) ;
8883 }
84+
85+ this . #addButtonContainer = this . containerElement . createChild ( 'div' , 'add-button-container' ) ;
86+ const addButton = UI . UIUtils . createTextButton (
87+ i18nString ( UIStrings . addFolder ) , this . addFileSystemClicked . bind ( this ) ,
88+ { jslogContext : 'sources.add-folder-to-workspace' } ) ;
89+ addButton . classList . add ( 'add-folder' ) ;
90+ this . #addButtonContainer. appendChild ( addButton ) ;
8991 }
9092
9193 override wasShown ( ) : void {
9294 super . wasShown ( ) ;
9395 this . registerCSSFiles ( [ workspaceSettingsTabStyles ] ) ;
9496 }
9597
96- private createFolderExcludePatternInput ( ) : Element {
97- const p = document . createElement ( 'p' ) ;
98- const labelElement = p . createChild ( 'label' ) ;
98+ private createFolderExcludePatternInput ( ) : HTMLElement {
99+ const excludePatternElement = document . createElement ( 'div' ) ;
100+ excludePatternElement . classList . add ( 'folder-exclude-pattern' ) ;
101+ const labelElement = excludePatternElement . createChild ( 'label' ) ;
99102 labelElement . textContent = i18nString ( UIStrings . folderExcludePattern ) ;
100103 const folderExcludeSetting = IsolatedFileSystemManager . instance ( ) . workspaceFolderExcludePatternSetting ( ) ;
101104 const inputElement = UI . UIUtils . createInput ( '' , 'text' , folderExcludeSetting . name ) ;
102105 UI . ARIAUtils . bindLabelToControl ( labelElement , inputElement ) ;
103- p . appendChild ( inputElement ) ;
106+ excludePatternElement . appendChild ( inputElement ) ;
104107 const setValue =
105108 UI . UIUtils . bindInput ( inputElement , folderExcludeSetting . set . bind ( folderExcludeSetting ) , regexValidator , false ) ;
106109 folderExcludeSetting . addChangeListener ( ( ) => setValue . call ( null , folderExcludeSetting . get ( ) ) ) ;
107110 setValue ( folderExcludeSetting . get ( ) ) ;
108- return p ;
111+ return excludePatternElement ;
109112
110113 function regexValidator ( value : string ) : { valid : boolean , errorMessage : ( string | undefined ) } {
111114 let regex ;
@@ -129,41 +132,34 @@ export class WorkspaceSettingsTab extends UI.Widget.VBox {
129132 fileSystem ) {
130133 return ;
131134 }
132- const element = this . renderFileSystem ( fileSystem ) ;
133- this . elementByPath . set ( fileSystem . path ( ) , element ) ;
134-
135- this . fileSystemsListContainer . appendChild ( element ) ;
136-
135+ const filename = this . getFilename ( fileSystem ) ;
136+ const removeButton = UI . UIUtils . createTextButton (
137+ i18nString ( UIStrings . remove ) , this . removeFileSystemClicked . bind ( this , fileSystem ) ,
138+ { jslogContext : 'settings.remove-file-system' } ) ;
139+
140+ const mappingViewContainer = document . createElement ( 'div' ) ;
141+ mappingViewContainer . classList . add ( 'mapping-view-container' ) ;
142+ const fileSystemExcludeCard = new Cards . Card . Card ( ) ;
143+ this . containerElement . insertBefore ( fileSystemExcludeCard , this . #addButtonContainer) ;
144+ fileSystemExcludeCard . data = {
145+ heading : filename ,
146+ headingIconName : 'folder' ,
147+ headingSuffix : removeButton ,
148+ content : [ mappingViewContainer ] ,
149+ } ;
137150 const mappingView = new EditFileSystemView ( fileSystem . path ( ) ) ;
138151 this . mappingViewByPath . set ( fileSystem . path ( ) , mappingView ) ;
139152 mappingView . element . classList . add ( 'file-system-mapping-view' ) ;
140- mappingView . show ( element ) ;
153+
154+ mappingView . show ( mappingViewContainer ) ;
155+
156+ this . elementByPath . set ( fileSystem . path ( ) , fileSystemExcludeCard ) ;
141157 }
142158
143- private renderFileSystem ( fileSystem : PlatformFileSystem ) : Element {
159+ private getFilename ( fileSystem : PlatformFileSystem ) : string {
144160 const fileSystemPath = fileSystem . path ( ) ;
145161 const lastIndexOfSlash = fileSystemPath . lastIndexOf ( '/' ) ;
146- const folderName = fileSystemPath . substr ( lastIndexOfSlash + 1 ) ;
147-
148- const element = document . createElement ( 'div' ) ;
149- element . classList . add ( 'file-system-container' ) ;
150- const header = element . createChild ( 'div' , 'file-system-header' ) ;
151-
152- const nameElement = header . createChild ( 'div' , 'file-system-name' ) ;
153- nameElement . textContent = folderName ;
154- UI . ARIAUtils . markAsHeading ( nameElement , 2 ) ;
155- const path = header . createChild ( 'div' , 'file-system-path' ) ;
156- path . textContent = fileSystemPath ;
157- UI . Tooltip . Tooltip . install ( path , fileSystemPath ) ;
158-
159- const toolbar = new UI . Toolbar . Toolbar ( '' ) ;
160- const button =
161- new UI . Toolbar . ToolbarButton ( i18nString ( UIStrings . remove ) , 'cross' , undefined , 'settings.remove-file-system' ) ;
162- button . addEventListener ( UI . Toolbar . ToolbarButton . Events . CLICK , this . removeFileSystemClicked . bind ( this , fileSystem ) ) ;
163- toolbar . appendToolbarItem ( button ) ;
164- header . appendChild ( toolbar . element ) ;
165-
166- return element ;
162+ return fileSystemPath . substr ( lastIndexOfSlash + 1 ) ;
167163 }
168164
169165 private removeFileSystemClicked ( fileSystem : PlatformFileSystem ) : void {
0 commit comments