Skip to content

Commit 25686ed

Browse files
committed
DO NOT MERGE!!! Testing duplicated code
1 parent 8066fa6 commit 25686ed

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/explorer/webview/OuterToolkitPanel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import com.intellij.util.ui.components.BorderLayoutPanel
99
import software.aws.toolkits.core.utils.error
1010
import software.aws.toolkits.core.utils.getLogger
1111
import software.aws.toolkits.jetbrains.core.explorer.AwsToolkitExplorerToolWindow
12-
import software.aws.toolkits.jetbrains.utils.isTookitConnected
12+
import software.aws.toolkits.jetbrains.utils.isTookitConnected2
1313
import javax.swing.JComponent
1414

1515
class OuterToolkitPanel(val project: Project) : BorderLayoutPanel() {
1616
private val wrapper = Wrapper()
1717
init {
1818
isOpaque = false
1919
addToCenter(wrapper)
20-
val component = if (!isTookitConnected(project) || shouldPromptToolkitReauth(project)) {
20+
val component = if (!isTookitConnected2(project) || shouldPromptToolkitReauth(project)) {
2121
ToolkitWebviewPanel.getInstance(project).component
2222
} else {
2323
AwsToolkitExplorerToolWindow.getInstance(project)

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/utils/ToolkitUtils.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,31 @@ fun isTookitConnected(project: Project): Boolean =
4141

4242
return@let false
4343
}
44+
45+
fun isTookitConnected2(project: Project): Boolean =
46+
ToolkitConnectionManager.getInstance(project).let {
47+
if (CredentialManager.getInstance().getCredentialIdentifiers().isNotEmpty()) {
48+
LOG.debug { "inspecting existing connection and found IAM credentials" }
49+
return@let true
50+
}
51+
52+
val conn = it.activeConnection()
53+
val hasIdCRoleAccess = if (conn is AwsBearerTokenConnection) {
54+
conn.scopes.contains(IDENTITY_CENTER_ROLE_ACCESS_SCOPE)
55+
} else {
56+
false
57+
}
58+
59+
if (hasIdCRoleAccess) {
60+
LOG.debug { "inspecting existing connection and found bearer connections with IdCRoleAccess scope" }
61+
return@let true
62+
}
63+
64+
val isCodecatalystConn = it.activeConnectionForFeature(CodeCatalystConnection.getInstance()) != null
65+
if (isCodecatalystConn) {
66+
LOG.debug { "inspecting existing connection and found active Codecatalyst connection" }
67+
return@let true
68+
}
69+
70+
return@let false
71+
}

0 commit comments

Comments
 (0)