-
Notifications
You must be signed in to change notification settings - Fork 274
Show notification banner #5097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Show notification banner #5097
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
c3cc2bf
Display toast notifications with actions
manodnyab 09729c7
Condition matcher for displaying notifications
manodnyab 885f3f0
Show notification banner
manodnyab f0aca38
feedback 1
manodnyab e909a0e
Modified deserialization cases and added tests
manodnyab 5a84e39
Merge branch 'feature/ideNotifs' into manodnyb/checkRulesForNotificat…
manodnyab 56c1888
not required file change
manodnyab a981227
Merge remote-tracking branch 'origin/manodnyb/checkRulesForNotificati…
manodnyab 682897f
feedback 1
manodnyab adb6ec7
resolved conflicts
manodnyab dbfcefc
feedback 1
manodnyab 823ea7f
Merge remote-tracking branch 'origin/feature/ideNotifs' into manodnyb…
manodnyab 218c8ed
modified the base class
manodnyab b684a01
merge conflicts resolved
manodnyab 368fd25
merge conflicts resolved
manodnyab 57fb2ef
rearranged call site
manodnyab a5126d1
show notifications when panel is opened
manodnyab 22f9438
resolved merge conflicts
manodnyab 87ec1d9
fixed tests
manodnyab 24a2f65
Merge branch 'feature/ideNotifs' into manodnyb/addNotificationBanner
manodnyab 78f8c6b
detekt
manodnyab bfc1077
Merge remote-tracking branch 'origin/manodnyb/addNotificationBanner' …
manodnyab 1a83a40
feedback
manodnyab 9e8b0af
Merge branch 'feature/ideNotifs' into manodnyb/addNotificationBanner
manodnyab 1b12854
convert panels into wrappers
manodnyab e7d8594
Merge remote-tracking branch 'origin/manodnyb/addNotificationBanner' …
manodnyab bbf6779
fixed test
manodnyab a8fa482
Merge branch 'feature/ideNotifs' into manodnyb/addNotificationBanner
manodnyab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...nity/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/NotificationPanel.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package software.aws.toolkits.jetbrains.services.amazonq.toolwindow | ||
|
|
||
| import com.intellij.icons.AllIcons | ||
| import com.intellij.openapi.application.runInEdt | ||
| import com.intellij.openapi.components.Service | ||
| import com.intellij.openapi.components.service | ||
| import com.intellij.openapi.project.Project | ||
| import com.intellij.ui.EditorNotificationPanel | ||
| import com.intellij.ui.components.panels.Wrapper | ||
| import com.intellij.util.ui.components.BorderLayoutPanel | ||
| import software.aws.toolkits.jetbrains.core.notifications.BannerContent | ||
| import software.aws.toolkits.jetbrains.core.notifications.NotificationManager | ||
| import software.aws.toolkits.jetbrains.core.notifications.ProcessNotificationsBase | ||
| import software.aws.toolkits.resources.AwsCoreBundle | ||
|
|
||
| @Service(Service.Level.PROJECT) | ||
| class NotificationPanel : BorderLayoutPanel() { | ||
| private val wrapper = Wrapper() | ||
| init { | ||
| isOpaque = false | ||
| addToCenter(wrapper) | ||
| ProcessNotificationsBase.showBannerNotification.forEach { | ||
| updateNotificationPanel(it.value) | ||
| } | ||
| } | ||
|
|
||
| private fun removeNotificationPanel(notificationId: String) = runInEdt { | ||
| ProcessNotificationsBase.showBannerNotification.remove(notificationId) // TODO: add id to dismissed notification list | ||
| wrapper.removeAll() | ||
| } | ||
|
|
||
| fun updateNotificationPanel(bannerContent: BannerContent) { | ||
| val panel = EditorNotificationPanel() | ||
| panel.text = bannerContent.title | ||
| panel.icon(AllIcons.General.Error) | ||
| val panelWithActions = NotificationManager.buildBannerPanel(panel, bannerContent.actions) | ||
| panelWithActions.createActionLabel(AwsCoreBundle.message("general.dismiss")) { | ||
| removeNotificationPanel(bannerContent.id) | ||
| } | ||
|
|
||
| wrapper.setContent(panelWithActions) | ||
| } | ||
|
|
||
| companion object { | ||
| fun getInstance(project: Project): NotificationPanel = project.service() | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
...nity/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/OuterAmazonQPanel.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package software.aws.toolkits.jetbrains.services.amazonq.toolwindow | ||
|
|
||
| import com.intellij.openapi.components.Service | ||
| import com.intellij.openapi.components.service | ||
| import com.intellij.openapi.project.Project | ||
| import com.intellij.ui.components.panels.Wrapper | ||
| import com.intellij.util.ui.components.BorderLayoutPanel | ||
| import software.aws.toolkits.core.utils.getLogger | ||
| import javax.swing.JComponent | ||
|
|
||
| @Service(Service.Level.PROJECT) | ||
| class OuterAmazonQPanel : BorderLayoutPanel() { | ||
| private val wrapper = Wrapper() | ||
| init { | ||
| isOpaque = false | ||
| addToCenter(wrapper) | ||
| } | ||
|
|
||
| fun updateQPanel(content: JComponent) { | ||
Check noticeCode scanning / QDJVMC Class member can have 'private' visibility Note
Function 'updateQPanel' could be private
|
||
| try { | ||
| wrapper.setContent(content) | ||
| } catch (e: Exception) { | ||
| getLogger<OuterAmazonQPanel>().error("Error while creating window") | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| fun getInstance(project: Project): OuterAmazonQPanel = project.service() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.