@@ -26,7 +26,10 @@ import {
26
26
import { ConnectionOption } from "azdata" ;
27
27
import { Logger } from "../models/logger" ;
28
28
import VscodeWrapper from "../controllers/vscodeWrapper" ;
29
- import { ConnectionDialog as Loc , refreshTokenLabel } from "../constants/locConstants" ;
29
+ import {
30
+ ConnectionDialog as Loc ,
31
+ refreshTokenLabel ,
32
+ } from "../constants/locConstants" ;
30
33
import {
31
34
FormItemSpec ,
32
35
FormItemActionButton ,
@@ -38,7 +41,10 @@ import {
38
41
AzureSubscription ,
39
42
VSCodeAzureSubscriptionProvider ,
40
43
} from "@microsoft/vscode-azext-azureauth" ;
41
- import { GenericResourceExpanded , ResourceManagementClient } from "@azure/arm-resources" ;
44
+ import {
45
+ GenericResourceExpanded ,
46
+ ResourceManagementClient ,
47
+ } from "@azure/arm-resources" ;
42
48
import { getErrorMessage , listAllIterator } from "../utils/utils" ;
43
49
import { l10n } from "vscode" ;
44
50
@@ -179,7 +185,10 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
179
185
) ;
180
186
this . state . connectionProfile = connection ;
181
187
182
- this . state . selectedInputMode = ( connection . connectionString && connection . server === undefined ) ? ConnectionInputMode . ConnectionString : ConnectionInputMode . Parameters ;
188
+ this . state . selectedInputMode =
189
+ connection . connectionString && connection . server === undefined
190
+ ? ConnectionInputMode . ConnectionString
191
+ : ConnectionInputMode . Parameters ;
183
192
this . state = this . state ;
184
193
}
185
194
}
@@ -442,8 +451,7 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
442
451
) {
443
452
return {
444
453
isValid : false ,
445
- validationMessage :
446
- Loc . azureAccountIsRequired ,
454
+ validationMessage : Loc . azureAccountIsRequired ,
447
455
} ;
448
456
}
449
457
return {
@@ -470,8 +478,7 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
470
478
) {
471
479
return {
472
480
isValid : false ,
473
- validationMessage :
474
- Loc . tenantIdIsRequired ,
481
+ validationMessage : Loc . tenantIdIsRequired ,
475
482
} ;
476
483
}
477
484
return {
@@ -495,8 +502,7 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
495
502
) {
496
503
return {
497
504
isValid : false ,
498
- validationMessage :
499
- Loc . connectionStringIsRequired ,
505
+ validationMessage : Loc . connectionStringIsRequired ,
500
506
} ;
501
507
}
502
508
return {
@@ -947,26 +953,40 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
947
953
// getSubscriptions() below checks this config setting if filtering is specified. If the user has this set, then we use it; if not, we get all subscriptions.
948
954
// we can't controll which config setting it uses, but the Azure Resources extension (ms-azuretools.vscode-azureresourcegroups) sets this config setting,
949
955
// so that's the easiest way for a user to control their subscription filters.
950
- const shouldUseFilter = vscode . workspace . getConfiguration ( ) . get < string [ ] | undefined > ( 'azureResourceGroups.selectedSubscriptions' ) !== undefined ;
956
+ const shouldUseFilter =
957
+ vscode . workspace
958
+ . getConfiguration ( )
959
+ . get <
960
+ string [ ] | undefined
961
+ > ( "azureResourceGroups.selectedSubscriptions" ) !==
962
+ undefined ;
951
963
952
964
const tenantSubMap = this . groupBy (
953
965
await auth . getSubscriptions ( shouldUseFilter ) ,
954
966
"tenantId" ,
955
967
) ; // TODO: replace with Object.groupBy once ES2024 is supported
956
968
957
969
if ( tenantSubMap . size === 0 ) {
958
- state . formError = l10n . t ( "No subscriptions set in VS Code's Azure account filter." ) ;
970
+ state . formError = l10n . t (
971
+ "No subscriptions set in VS Code's Azure account filter." ,
972
+ ) ;
959
973
} else {
960
974
for ( const t of tenantSubMap . keys ( ) ) {
961
975
for ( const s of tenantSubMap . get ( t ) ) {
962
976
try {
963
977
const servers = await this . getAzureServers ( s ) ;
964
978
state . azureDatabases . push ( ...servers ) ;
965
979
this . state = state ; // update state mid-reducer so the UI is more responsive
966
- }
967
- catch ( error ) {
968
- vscode . window . showErrorMessage ( Loc . errorLoadingAzureDatabases ( s . name , s . subscriptionId ) ) ;
969
- console . error ( state . formError + "\n" + getErrorMessage ( error ) ) ;
980
+ } catch ( error ) {
981
+ vscode . window . showErrorMessage (
982
+ Loc . errorLoadingAzureDatabases (
983
+ s . name ,
984
+ s . subscriptionId ,
985
+ ) ,
986
+ ) ;
987
+ console . error (
988
+ state . formError + "\n" + getErrorMessage ( error ) ,
989
+ ) ;
970
990
}
971
991
}
972
992
}
@@ -1013,23 +1033,34 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
1013
1033
server : server . name ,
1014
1034
databases : [ ] ,
1015
1035
location : server . location ,
1016
- resourceGroup : this . extractFromResourceId ( server . id , "resourceGroups" ) ,
1036
+ resourceGroup : this . extractFromResourceId (
1037
+ server . id ,
1038
+ "resourceGroups" ,
1039
+ ) ,
1017
1040
subscription : `${ sub . name } (${ sub . subscriptionId } )` ,
1018
1041
} ) ;
1019
1042
}
1020
1043
1021
1044
for ( const database of await databasesPromise ) {
1022
- const serverName = this . extractFromResourceId ( database . id , "servers" ) ;
1045
+ const serverName = this . extractFromResourceId (
1046
+ database . id ,
1047
+ "servers" ,
1048
+ ) ;
1023
1049
const server = result . find ( ( s ) => s . server === serverName ) ;
1024
1050
if ( server ) {
1025
- server . databases . push ( database . name . substring ( serverName . length + 1 ) ) ; // database.name is in the form 'serverName/databaseName', so we need to remove the server name and slash
1051
+ server . databases . push (
1052
+ database . name . substring ( serverName . length + 1 ) ,
1053
+ ) ; // database.name is in the form 'serverName/databaseName', so we need to remove the server name and slash
1026
1054
}
1027
1055
}
1028
1056
1029
1057
return result ;
1030
1058
}
1031
1059
1032
- private extractFromResourceId ( resourceId : string , property : string ) : string | undefined {
1060
+ private extractFromResourceId (
1061
+ resourceId : string ,
1062
+ property : string ,
1063
+ ) : string | undefined {
1033
1064
if ( ! property . endsWith ( "/" ) ) {
1034
1065
property += "/" ;
1035
1066
}
@@ -1042,6 +1073,9 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
1042
1073
startIndex += property . length ;
1043
1074
}
1044
1075
1045
- return resourceId . substring ( startIndex , resourceId . indexOf ( "/" , startIndex ) ) ;
1076
+ return resourceId . substring (
1077
+ startIndex ,
1078
+ resourceId . indexOf ( "/" , startIndex ) ,
1079
+ ) ;
1046
1080
}
1047
1081
}
0 commit comments