@@ -6,6 +6,7 @@ package software.aws.toolkits.jetbrains.core.credentials.pinning
6
6
import com.intellij.icons.AllIcons
7
7
import com.intellij.openapi.Disposable
8
8
import com.intellij.openapi.application.ApplicationManager
9
+ import com.intellij.openapi.application.ModalityState
9
10
import com.intellij.openapi.components.PersistentStateComponent
10
11
import com.intellij.openapi.components.State
11
12
import com.intellij.openapi.components.Storage
@@ -14,7 +15,7 @@ import com.intellij.openapi.extensions.ExtensionPointName
14
15
import com.intellij.openapi.project.Project
15
16
import com.intellij.openapi.ui.DialogWrapper
16
17
import com.intellij.openapi.ui.MessageDialogBuilder
17
- import org.jetbrains.annotations.TestOnly
18
+ import org.jetbrains.annotations.VisibleForTesting
18
19
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
19
20
import software.aws.toolkits.jetbrains.core.credentials.ToolkitAuthManager
20
21
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnection
@@ -98,7 +99,7 @@ class DefaultConnectionPinningManager :
98
99
}
99
100
100
101
var connectionToPin = if (oldConnection is AwsBearerTokenConnection ) oldConnection else newConnection
101
- if (computeOnEdt { showDialogIfNeeded(oldConnection, newConnection, featuresString) } ) {
102
+ if (showDialogIfNeeded(oldConnection, newConnection, featuresString)) {
102
103
features.forEach {
103
104
setPinnedConnection(it, connectionToPin)
104
105
}
@@ -126,33 +127,35 @@ class DefaultConnectionPinningManager :
126
127
127
128
override fun dispose () {}
128
129
129
- @TestOnly
130
+ @VisibleForTesting
130
131
internal fun showDialogIfNeeded (oldConnection : ToolkitConnection ? , newConnection : ToolkitConnection , featuresString : String , project : Project ? = null) =
131
132
if (! doNotPromptForPinning) {
132
133
val bearerTokenConnectionName = bearerTokenConnectionString(oldConnection, newConnection)
133
134
134
- MessageDialogBuilder .yesNo(
135
- message(" credentials.switch.confirmation.title" , featuresString, bearerTokenConnectionName),
136
- message(" credentials.switch.confirmation.comment" , featuresString, bearerTokenConnectionName, message(" iam.name" ),)
137
- )
138
- .yesText(message(" credentials.switch.confirmation.yes" ))
139
- .noText(message(" credentials.switch.confirmation.no" ))
140
- .doNotAsk(object : com.intellij.openapi.ui.DoNotAskOption .Adapter () {
141
- override fun rememberChoice (isSelected : Boolean , exitCode : Int ) {
142
- if (isSelected && exitCode == DialogWrapper .OK_EXIT_CODE ) {
143
- doNotPromptForPinning = true
135
+ computeOnEdt(ModalityState .defaultModalityState()) {
136
+ MessageDialogBuilder .yesNo(
137
+ message(" credentials.switch.confirmation.title" , featuresString, bearerTokenConnectionName),
138
+ message(" credentials.switch.confirmation.comment" , featuresString, bearerTokenConnectionName, message(" iam.name" ))
139
+ )
140
+ .yesText(message(" credentials.switch.confirmation.yes" ))
141
+ .noText(message(" credentials.switch.confirmation.no" ))
142
+ .doNotAsk(object : com.intellij.openapi.ui.DoNotAskOption .Adapter () {
143
+ override fun rememberChoice (isSelected : Boolean , exitCode : Int ) {
144
+ if (isSelected && exitCode == DialogWrapper .OK_EXIT_CODE ) {
145
+ doNotPromptForPinning = true
146
+ }
147
+ }
148
+ })
149
+ .icon(AllIcons .General .QuestionDialog )
150
+ .help(HelpIds .EXPLORER_CREDS_HELP .id)
151
+ .ask(project).apply {
152
+ if (this ) {
153
+ UiTelemetry .click(project, " connection_multiple_auths_yes" )
154
+ } else {
155
+ UiTelemetry .click(project, " connection_multiple_auths_no" )
144
156
}
145
157
}
146
- })
147
- .icon(AllIcons .General .QuestionDialog )
148
- .help(HelpIds .EXPLORER_CREDS_HELP .id)
149
- .ask(project).apply {
150
- if (this ) {
151
- UiTelemetry .click(project, " connection_multiple_auths_yes" )
152
- } else {
153
- UiTelemetry .click(project, " connection_multiple_auths_no" )
154
- }
155
- }
158
+ }
156
159
} else {
157
160
false
158
161
}
0 commit comments