-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display startup and emergency notifications (#5143)
* Add framework for processing notifications (#5112) * Add deserialization for notification messages retrieved from the notification file and criteria on whether it should be displayed (#5093) * Display toast notifications with actions * Condition matcher for displaying notifications * Modified deserialization cases and added tests * not required file change * feedback 1 * modified the base class * modified test instance lifecycle * Show toasts for notifications and notification banner on critical notifications(#5097) * Display toast notifications with actions * Condition matcher for displaying notifications * Show notification banner * feedback 1 * Modified deserialization cases and added tests * not required file change * feedback 1 * feedback 1 * modified the base class * merge conflicts resolved * rearranged call site * show notifications when panel is opened * fixed tests * detekt * feedback * convert panels into wrappers * fixed test * Adding update/restart action to notifications (#5136) * Poll for new notifications (#5119) * initial commit * run on startup * detekt * move vals * remote resource implementation * comments * detekt * Validate file before saving * cache path * observer implementation * deserialize notifs from file * detekt * remove unused interface * internal class * Fix observer * etag singleton state component * add telemetry * atomicBoolean * initialize once per IDE startup * code scan * Omit (Unit) * specify etag storage location * detekt * fix detekt issues * basic tests * no star imports * coroutine scope delay instead of thread.sleep * feedback fixes * test fix * Application Exists for tests * endpoint object * detekt * detekt fixes * boolean flag * boolean flag * update tests * move startup flag handling to processBase * fix delay * fix delay * Notification dismissal state tracking (#5129) * split notifications into separated lists. * add persistent notification dismissal state logic * boolean changes * group persistant states * comments * Service initialized automatically * isStartup global * Deserialized notification schedule type * tests * persistent state syntax * convert to light services * Remove state from companion object * detekt * endpoint as registryKey * detekt * fix startup issues * Expiry issues * Add logging info to IDE notification polling and processing (#5138) * add logs for polling and processing notifs * redundant * finish log * fix isFirstPoll not setting to false on first pass --------- Co-authored-by: aws-toolkit-automation <[email protected]> Co-authored-by: manodnyab <[email protected]> Co-authored-by: Bryce Ito <[email protected]>
- Loading branch information
1 parent
07ccd11
commit 1a5f1c9
Showing
34 changed files
with
2,385 additions
and
72 deletions.
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
...nity/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/OuterAmazonQPanel.kt
This file contains 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,39 @@ | ||
// 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.project.Project | ||
import com.intellij.ui.components.panels.Wrapper | ||
import com.intellij.util.ui.components.BorderLayoutPanel | ||
import software.aws.toolkits.core.utils.error | ||
import software.aws.toolkits.core.utils.getLogger | ||
import software.aws.toolkits.jetbrains.core.webview.BrowserState | ||
import software.aws.toolkits.jetbrains.services.amazonq.QWebviewPanel | ||
import software.aws.toolkits.jetbrains.utils.isQConnected | ||
import software.aws.toolkits.jetbrains.utils.isQExpired | ||
import software.aws.toolkits.telemetry.FeatureId | ||
import javax.swing.JComponent | ||
|
||
class OuterAmazonQPanel(val project: Project) : BorderLayoutPanel() { | ||
private val wrapper = Wrapper() | ||
init { | ||
isOpaque = false | ||
addToCenter(wrapper) | ||
val component = if (isQConnected(project) && !isQExpired(project)) { | ||
AmazonQToolWindow.getInstance(project).component | ||
} else { | ||
QWebviewPanel.getInstance(project).browser?.prepareBrowser(BrowserState(FeatureId.AmazonQ)) | ||
QWebviewPanel.getInstance(project).component | ||
} | ||
updateQPanel(component) | ||
} | ||
|
||
fun updateQPanel(content: JComponent) { | ||
try { | ||
wrapper.setContent(content) | ||
} catch (e: Exception) { | ||
getLogger<OuterAmazonQPanel>().error { "Error while creating window" } | ||
} | ||
} | ||
} |
This file contains 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 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 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
132 changes: 132 additions & 0 deletions
132
...munity/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt
This file contains 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,132 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.core.notifications | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.ide.BrowserUtil | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.application.runInEdt | ||
import com.intellij.openapi.progress.ProgressIndicator | ||
import com.intellij.openapi.progress.ProgressManager | ||
import com.intellij.openapi.progress.Task | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.ui.Messages | ||
import com.intellij.ui.EditorNotificationPanel | ||
import software.aws.toolkits.jetbrains.AwsPlugin | ||
import software.aws.toolkits.jetbrains.AwsToolkit | ||
import software.aws.toolkits.jetbrains.core.plugin.PluginUpdateManager | ||
import software.aws.toolkits.resources.AwsCoreBundle | ||
|
||
fun checkSeverity(notificationSeverity: String): NotificationSeverity = when (notificationSeverity) { | ||
"Critical" -> NotificationSeverity.CRITICAL | ||
"Warning" -> NotificationSeverity.WARNING | ||
"Info" -> NotificationSeverity.INFO | ||
else -> NotificationSeverity.INFO | ||
} | ||
|
||
object NotificationManager { | ||
fun createActions( | ||
project: Project, | ||
followupActions: List<NotificationFollowupActions>?, | ||
message: String, | ||
title: String, | ||
|
||
): List<NotificationActionList> = buildList { | ||
var url: String? = null | ||
followupActions?.forEach { action -> | ||
if (action.type == "ShowUrl") { | ||
url = action.content.locale.url | ||
} | ||
|
||
if (action.type == "UpdateExtension") { | ||
add( | ||
NotificationActionList(AwsCoreBundle.message("notification.update")) { | ||
updatePlugins() | ||
} | ||
) | ||
} | ||
|
||
if (action.type == "OpenChangelog") { | ||
add( | ||
NotificationActionList(AwsCoreBundle.message("notification.changelog")) { | ||
BrowserUtil.browse(AwsToolkit.GITHUB_CHANGELOG) | ||
} | ||
) | ||
} | ||
} | ||
add( | ||
NotificationActionList(AwsCoreBundle.message("general.more_dialog")) { | ||
if (url == null) { | ||
Messages.showYesNoDialog( | ||
project, | ||
message, | ||
title, | ||
AwsCoreBundle.message("general.acknowledge"), | ||
AwsCoreBundle.message("general.cancel"), | ||
AllIcons.General.Error | ||
) | ||
} else { | ||
val link = url ?: AwsToolkit.GITHUB_URL | ||
val openLink = Messages.showYesNoDialog( | ||
project, | ||
message, | ||
title, | ||
AwsCoreBundle.message(AwsCoreBundle.message("notification.learn_more")), | ||
AwsCoreBundle.message("general.cancel"), | ||
AllIcons.General.Error | ||
) | ||
if (openLink == 0) { | ||
BrowserUtil.browse(link) | ||
} | ||
} | ||
} | ||
) | ||
} | ||
|
||
fun buildNotificationActions(actions: List<NotificationActionList>): List<AnAction> = actions.map { (title, block) -> | ||
object : AnAction(title) { | ||
override fun actionPerformed(e: AnActionEvent) { | ||
block() | ||
} | ||
} | ||
} | ||
|
||
fun buildBannerPanel(panel: EditorNotificationPanel, actions: List<NotificationActionList>): EditorNotificationPanel { | ||
actions.forEach { (actionTitle, block) -> | ||
panel.createActionLabel(actionTitle) { | ||
block() | ||
} | ||
} | ||
|
||
return panel | ||
} | ||
private fun updatePlugins() { | ||
val pluginUpdateManager = PluginUpdateManager() | ||
runInEdt { | ||
ProgressManager.getInstance().run(object : Task.Backgroundable( | ||
null, | ||
AwsCoreBundle.message("aws.settings.auto_update.progress.message") | ||
) { | ||
override fun run(indicator: ProgressIndicator) { | ||
pluginUpdateManager.checkForUpdates(indicator, AwsPlugin.CORE) | ||
pluginUpdateManager.checkForUpdates(indicator, AwsPlugin.TOOLKIT) | ||
pluginUpdateManager.checkForUpdates(indicator, AwsPlugin.Q) | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
|
||
data class NotificationActionList( | ||
val title: String, | ||
val blockToExecute: () -> Unit, | ||
) | ||
|
||
data class BannerContent( | ||
val title: String, | ||
val message: String, | ||
val actions: List<NotificationActionList>, | ||
val id: String, | ||
) |
6 changes: 6 additions & 0 deletions
6
...unity/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt
This file contains 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,6 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.core.notifications | ||
|
||
object DisplayToastNotifications |
Oops, something went wrong.