Skip to content

Commit 6a75e59

Browse files
committed
Revert "Show toasts for notifications and notification banner on critical notifications(#5097)"
This reverts commit fc77aab.
1 parent fc77aab commit 6a75e59

File tree

17 files changed

+74
-449
lines changed

17 files changed

+74
-449
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/AmazonQToolWindowFactory.kt

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import com.intellij.openapi.project.Project
1010
import com.intellij.openapi.wm.ToolWindow
1111
import com.intellij.openapi.wm.ToolWindowFactory
1212
import com.intellij.openapi.wm.ex.ToolWindowEx
13-
import com.intellij.ui.components.panels.Wrapper
14-
import com.intellij.util.ui.components.BorderLayoutPanel
13+
import com.intellij.ui.content.Content
14+
import com.intellij.ui.content.ContentManager
1515
import software.aws.toolkits.core.utils.debug
1616
import software.aws.toolkits.core.utils.getLogger
1717
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
@@ -22,8 +22,6 @@ import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
2222
import software.aws.toolkits.jetbrains.core.credentials.sono.Q_SCOPES
2323
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenAuthState
2424
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProviderListener
25-
import software.aws.toolkits.jetbrains.core.notifications.NotificationPanel
26-
import software.aws.toolkits.jetbrains.core.notifications.ProcessNotificationsBase
2725
import software.aws.toolkits.jetbrains.core.webview.BrowserState
2826
import software.aws.toolkits.jetbrains.services.amazonq.QWebviewPanel
2927
import software.aws.toolkits.jetbrains.services.amazonq.RefreshQChatPanelButtonPressedListener
@@ -37,21 +35,7 @@ import java.awt.event.ComponentAdapter
3735
import java.awt.event.ComponentEvent
3836

3937
class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
40-
4138
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
42-
val mainPanel = BorderLayoutPanel()
43-
val qPanel = Wrapper()
44-
val notificationPanel = NotificationPanel()
45-
46-
mainPanel.addToTop(notificationPanel)
47-
mainPanel.add(qPanel)
48-
val notifListener = ProcessNotificationsBase.getInstance(project)
49-
notifListener.addListenerForNotification { bannerContent ->
50-
runInEdt {
51-
notificationPanel.updateNotificationPanel(bannerContent)
52-
}
53-
}
54-
5539
if (toolWindow is ToolWindowEx) {
5640
val actionManager = ActionManager.getInstance()
5741
toolWindow.setTitleActions(listOf(actionManager.getAction("aws.q.toolwindow.titleBar")))
@@ -62,7 +46,7 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
6246
ToolkitConnectionManagerListener.TOPIC,
6347
object : ToolkitConnectionManagerListener {
6448
override fun activeConnectionChanged(newConnection: ToolkitConnection?) {
65-
onConnectionChanged(project, newConnection, qPanel)
49+
onConnectionChanged(project, newConnection, toolWindow)
6650
}
6751
}
6852
)
@@ -72,7 +56,8 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
7256
object : RefreshQChatPanelButtonPressedListener {
7357
override fun onRefresh() {
7458
runInEdt {
75-
prepareChatContent(project, qPanel)
59+
contentManager.removeAllContents(true)
60+
prepareChatContent(project, contentManager)
7661
}
7762
}
7863
}
@@ -83,37 +68,43 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
8368
object : BearerTokenProviderListener {
8469
override fun onChange(providerId: String, newScopes: List<String>?) {
8570
if (ToolkitConnectionManager.getInstance(project).connectionStateForFeature(QConnection.getInstance()) == BearerTokenAuthState.AUTHORIZED) {
86-
val qComponent = AmazonQToolWindow.getInstance(project).component
71+
val content = contentManager.factory.createContent(AmazonQToolWindow.getInstance(project).component, null, false).also {
72+
it.isCloseable = true
73+
it.isPinnable = true
74+
}
8775

8876
runInEdt {
89-
qPanel.setContent(qComponent)
77+
contentManager.removeAllContents(true)
78+
contentManager.addContent(content)
9079
}
9180
}
9281
}
9382
}
9483
)
9584

96-
prepareChatContent(project, qPanel)
85+
val content = prepareChatContent(project, contentManager)
9786

98-
val content = contentManager.factory.createContent(mainPanel, null, false).also {
99-
it.isCloseable = true
100-
it.isPinnable = true
101-
}
10287
toolWindow.activate(null)
103-
contentManager.addContent(content)
88+
contentManager.setSelectedContent(content)
10489
}
10590

10691
private fun prepareChatContent(
10792
project: Project,
108-
qPanel: Wrapper,
109-
) {
93+
contentManager: ContentManager,
94+
): Content {
11095
val component = if (isQConnected(project) && !isQExpired(project)) {
11196
AmazonQToolWindow.getInstance(project).component
11297
} else {
11398
QWebviewPanel.getInstance(project).browser?.prepareBrowser(BrowserState(FeatureId.AmazonQ))
11499
QWebviewPanel.getInstance(project).component
115100
}
116-
qPanel.setContent(component)
101+
102+
val content = contentManager.factory.createContent(component, null, false).also {
103+
it.isCloseable = true
104+
it.isPinnable = true
105+
}
106+
contentManager.addContent(content)
107+
return content
117108
}
118109

119110
override fun init(toolWindow: ToolWindow) {
@@ -134,7 +125,8 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
134125

135126
override fun shouldBeAvailable(project: Project): Boolean = isQWebviewsAvailable()
136127

137-
private fun onConnectionChanged(project: Project, newConnection: ToolkitConnection?, qPanel: Wrapper) {
128+
private fun onConnectionChanged(project: Project, newConnection: ToolkitConnection?, toolWindow: ToolWindow) {
129+
val contentManager = toolWindow.contentManager
138130
val isNewConnectionForQ = newConnection?.let {
139131
(it as? AwsBearerTokenConnection)?.let { conn ->
140132
val scopeShouldHave = Q_SCOPES
@@ -159,8 +151,15 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
159151
LOG.debug { "returning login window; no Q connection found" }
160152
QWebviewPanel.getInstance(project).component
161153
}
154+
155+
val content = contentManager.factory.createContent(component, null, false).also {
156+
it.isCloseable = true
157+
it.isPinnable = true
158+
}
159+
162160
runInEdt {
163-
qPanel.setContent(component)
161+
contentManager.removeAllContents(true)
162+
contentManager.addContent(content)
164163
}
165164
}
166165

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/OuterAmazonQPanel.kt

Lines changed: 0 additions & 39 deletions
This file was deleted.

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/AwsToolkit.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ object AwsToolkit {
2828

2929
const val GITHUB_URL = "https://github.com/aws/aws-toolkit-jetbrains"
3030
const val AWS_DOCS_URL = "https://docs.aws.amazon.com/console/toolkit-for-jetbrains"
31-
const val GITHUB_CHANGELOG = "https://github.com/aws/aws-toolkit-jetbrains/blob/main/CHANGELOG.md"
3231
}
3332

3433
data class PluginInfo(val id: String, val name: String) {

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -3,109 +3,11 @@
33

44
package software.aws.toolkits.jetbrains.core.notifications
55

6-
import com.intellij.icons.AllIcons
7-
import com.intellij.ide.BrowserUtil
8-
import com.intellij.openapi.actionSystem.AnAction
9-
import com.intellij.openapi.actionSystem.AnActionEvent
10-
import com.intellij.openapi.project.Project
11-
import com.intellij.openapi.ui.Messages
12-
import com.intellij.ui.EditorNotificationPanel
13-
import software.aws.toolkits.jetbrains.AwsToolkit
14-
import software.aws.toolkits.resources.AwsCoreBundle
15-
166
fun checkSeverity(notificationSeverity: String): NotificationSeverity = when (notificationSeverity) {
177
"Critical" -> NotificationSeverity.CRITICAL
188
"Warning" -> NotificationSeverity.WARNING
199
"Info" -> NotificationSeverity.INFO
2010
else -> NotificationSeverity.INFO
2111
}
2212

23-
object NotificationManager {
24-
fun createActions(
25-
project: Project,
26-
followupActions: List<NotificationFollowupActions>?,
27-
message: String,
28-
title: String,
29-
30-
): List<NotificationActionList> = buildList {
31-
var url: String? = null
32-
followupActions?.forEach { action ->
33-
if (action.type == "ShowUrl") {
34-
url = action.content.locale.url
35-
}
36-
37-
if (action.type == "UpdateExtension") {
38-
add(
39-
NotificationActionList(AwsCoreBundle.message("notification.update")) {
40-
// TODO: Add update logic
41-
}
42-
)
43-
}
44-
45-
if (action.type == "OpenChangelog") {
46-
add(
47-
NotificationActionList(AwsCoreBundle.message("notification.changelog")) {
48-
BrowserUtil.browse(AwsToolkit.GITHUB_CHANGELOG)
49-
}
50-
)
51-
}
52-
}
53-
add(
54-
NotificationActionList(AwsCoreBundle.message("general.more_dialog")) {
55-
if (url == null) {
56-
Messages.showYesNoDialog(
57-
project,
58-
message,
59-
title,
60-
AwsCoreBundle.message("general.acknowledge"),
61-
AwsCoreBundle.message("general.cancel"),
62-
AllIcons.General.Error
63-
)
64-
} else {
65-
val link = url ?: AwsToolkit.GITHUB_URL
66-
val openLink = Messages.showYesNoDialog(
67-
project,
68-
message,
69-
title,
70-
AwsCoreBundle.message(AwsCoreBundle.message("notification.learn_more")),
71-
AwsCoreBundle.message("general.cancel"),
72-
AllIcons.General.Error
73-
)
74-
if (openLink == 0) {
75-
BrowserUtil.browse(link)
76-
}
77-
}
78-
}
79-
)
80-
}
81-
82-
fun buildNotificationActions(actions: List<NotificationActionList>): List<AnAction> = actions.map { (title, block) ->
83-
object : AnAction(title) {
84-
override fun actionPerformed(e: AnActionEvent) {
85-
block()
86-
}
87-
}
88-
}
89-
90-
fun buildBannerPanel(panel: EditorNotificationPanel, actions: List<NotificationActionList>): EditorNotificationPanel {
91-
actions.forEach { (actionTitle, block) ->
92-
panel.createActionLabel(actionTitle) {
93-
block()
94-
}
95-
}
96-
97-
return panel
98-
}
99-
}
100-
101-
data class NotificationActionList(
102-
val title: String,
103-
val blockToExecute: () -> Unit,
104-
)
105-
106-
data class BannerContent(
107-
val title: String,
108-
val message: String,
109-
val actions: List<NotificationActionList>,
110-
val id: String,
111-
)
13+
// TODO: Add actions that can be performed from the notifications here

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPanel.kt

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)