Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenAuthState
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProviderListener
import software.aws.toolkits.jetbrains.core.notifications.BannerContent
import software.aws.toolkits.jetbrains.core.notifications.NotificationDismissalState
import software.aws.toolkits.jetbrains.core.notifications.NotificationPanel
import software.aws.toolkits.jetbrains.core.notifications.ProcessNotificationsBase
import software.aws.toolkits.jetbrains.core.webview.BrowserState
Expand All @@ -32,6 +34,8 @@ import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileSe
import software.aws.toolkits.jetbrains.utils.isQConnected
import software.aws.toolkits.jetbrains.utils.isQExpired
import software.aws.toolkits.jetbrains.utils.isQWebviewsAvailable
import software.aws.toolkits.jetbrains.utils.isRunningOnRemoteBackend
import software.aws.toolkits.resources.AmazonQBundle
import software.aws.toolkits.resources.message
import software.aws.toolkits.telemetry.FeatureId
import java.awt.event.ComponentAdapter
Expand All @@ -42,7 +46,18 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
val mainPanel = BorderLayoutPanel()
val qPanel = Wrapper()
val notificationPanel = NotificationPanel()
val notificationPanel = NotificationPanel().apply {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not be shown if there is a 2nd emergency notif that we send right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes manifest takes priority

if (isRunningOnRemoteBackend() && !NotificationDismissalState.getInstance().isDismissed(REMOTE_RESIZE_NOTIFICATION_ID)) {
updateNotificationPanel(
BannerContent(
REMOTE_RESIZE_NOTIFICATION_ID,
AmazonQBundle.message("amazonq.resize.panel"),
// message is not used for banner
"",
)
)
}
}

mainPanel.addToTop(notificationPanel)
mainPanel.add(qPanel)
Expand Down Expand Up @@ -161,5 +176,6 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
private val LOG = getLogger<AmazonQToolWindowFactory>()
const val WINDOW_ID = AMAZON_Q_WINDOW_ID
private const val MINIMUM_TOOLWINDOW_WIDTH = 325
private const val REMOTE_RESIZE_NOTIFICATION_ID = "resize.amazon.q.toolwindow.if.remote"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ amazonq.getLogs.tooltip.text=Show Logs
amazonq.logs.error=Cannot retrieve logs. Please try Help-> Collect Logs and Diagnostic data
amazonq.logs.warning=Log files may contain sensitive information such as account IDs, resource names, and other data. Please be careful when sharing these logs.
amazonq.refresh.panel=Refresh Chat Session
amazonq.resize.panel=Please resize your IDE if the chat box isn't visible
amazonq.title=Amazon Q
amazonq.workspace.settings.open.prompt=Workspace index is now enabled. You can disable it from Amazon Q settings.
action.q.manage.subscription.text=Manage Q Developer Pro Subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ data class NotificationActionList(
)

data class BannerContent(
val id: String,
val title: String,
val message: String,
val actions: List<NotificationActionList>,
val id: String,
val actions: List<NotificationActionList> = emptyList(),
val severity: NotificationSeverity = NotificationSeverity.INFO,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

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

import com.intellij.icons.AllIcons
import com.intellij.openapi.application.runInEdt
import com.intellij.ui.EditorNotificationPanel
import com.intellij.ui.components.panels.Wrapper
import com.intellij.util.ui.components.BorderLayoutPanel
import software.aws.toolkits.resources.AwsCoreBundle

class NotificationPanel : BorderLayoutPanel() {
private val wrapper = Wrapper()
Expand All @@ -23,15 +21,21 @@ class NotificationPanel : BorderLayoutPanel() {
private fun removeNotificationPanel(notificationId: String) = runInEdt {
BannerNotificationService.getInstance().removeNotification(notificationId)
NotificationDismissalState.getInstance().dismissNotification(notificationId)
wrapper.removeAll()
wrapper.setContent(null)
}

fun updateNotificationPanel(bannerContent: BannerContent) {
val panel = EditorNotificationPanel()
val panel = EditorNotificationPanel(
when (bannerContent.severity) {
NotificationSeverity.CRITICAL -> EditorNotificationPanel.Status.Error
NotificationSeverity.WARNING -> EditorNotificationPanel.Status.Warning
NotificationSeverity.INFO -> EditorNotificationPanel.Status.Info
}
)
panel.text = bannerContent.title
panel.icon(AllIcons.General.Error)

val panelWithActions = NotificationManager.buildBannerPanel(panel, bannerContent.actions)
panelWithActions.createActionLabel(AwsCoreBundle.message("general.dismiss")) {
panelWithActions.setCloseAction {
removeNotificationPanel(bannerContent.id)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ProcessNotificationsBase(
if (shouldShow) {
LOG.info { "Showing notification with id: ${notificationData.id}" }
val notificationContent = notificationData.content.locale
val severity = notificationData.severity
val severity = checkSeverity(notificationData.severity)
val followupActions = NotificationManager.createActions(
project,
notificationData.actions,
Expand All @@ -99,11 +99,11 @@ class ProcessNotificationsBase(
notificationContent.title,
notificationContent.description,
NotificationManager.buildNotificationActions(followupActions),
checkSeverity(severity),
severity,
notificationData.id
)
if (severity == "Critical") {
val bannerContent = BannerContent(notificationContent.title, notificationContent.description, followupActions, notificationData.id)
if (severity == NotificationSeverity.CRITICAL) {
val bannerContent = BannerContent(notificationData.id, notificationContent.title, notificationContent.description, followupActions, severity)
BannerNotificationService.getInstance().addNotification(notificationData.id, bannerContent)
notifyListenerForNotification(bannerContent)
}
Expand Down
Loading