diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt new file mode 100644 index 00000000000..e1ec7bd2cd7 --- /dev/null +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt @@ -0,0 +1,25 @@ +// 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.notification.NotificationType +import com.intellij.openapi.actionSystem.AnAction +import software.aws.toolkits.jetbrains.utils.notifySticky + +object DisplayToastNotifications { + fun show(title: String, message: String, action: List, notificationType: ToastNotificationType) { + val notifyType = when (notificationType) { + ToastNotificationType.CRITICAL -> NotificationType.ERROR + ToastNotificationType.WARNING -> NotificationType.WARNING + ToastNotificationType.PRODUCT_UPDATE -> NotificationType.INFORMATION + } + notifySticky(notifyType, title, message, null, action) + } +} + +enum class ToastNotificationType { + CRITICAL, + WARNING, + PRODUCT_UPDATE, +} diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/utils/NotificationUtils.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/utils/NotificationUtils.kt index 0bd81b96227..924db699653 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/utils/NotificationUtils.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/utils/NotificationUtils.kt @@ -48,7 +48,7 @@ private fun notify(type: NotificationType, title: String, content: String = "", notify(notification, project) } -private fun notifySticky(type: NotificationType, title: String, content: String = "", project: Project? = null, notificationActions: Collection) { +fun notifySticky(type: NotificationType, title: String, content: String = "", project: Project? = null, notificationActions: Collection) { val notification = Notification(GROUP_DISPLAY_ID_STICKY, title, content, type) notificationActions.forEach { notification.addAction(if (it !is NotificationAction) createNotificationExpiringAction(it) else it)