Skip to content

fix(amazonq): Add modal notification if Amazon Q Chat is not available #5516

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -6,23 +6,53 @@
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationNamesInfo
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.ui.dsl.builder.panel
import icons.AwsIcons
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AMAZON_Q_WINDOW_ID
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindow
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.runScanKey
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.UiTelemetry
import javax.swing.JComponent

class QOpenPanelAction : AnAction(message("action.q.openchat.text"), null, AwsIcons.Logos.AWS_Q) {
override fun actionPerformed(e: AnActionEvent) {
if (isRunningOnRemoteBackend()) return
val project = e.getRequiredData(CommonDataKeys.PROJECT)
if (!isQWebviewsAvailable()) {
QWebviewNotAvailable(project).show()
return

Check warning on line 33 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt#L32-L33

Added lines #L32 - L33 were not covered by tests
}
UiTelemetry.click(project, "q_openChat")
ToolWindowManager.getInstance(project).getToolWindow(AMAZON_Q_WINDOW_ID)?.activate(null, true)
if (e.getData(runScanKey) == true) {
AmazonQToolWindow.openScanTab(project)
}
}
}

class QWebviewNotAvailable(project: Project) : DialogWrapper(project) {
override fun createCenterPanel(): JComponent = panel {
row {
icon(Messages.getWarningIcon())
label(AmazonQBundle.message("amazonqChat.incompatible.text", ApplicationNamesInfo.getInstance().fullProductName)).bold()
}
row {
Copy link
Contributor

Choose a reason for hiding this comment

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

label(AmazonQBundle.message("amazonQChat.incomptible.text.fix"))
}.visible(ApplicationInfo.getInstance().build.productCode == "AI")
}

Check warning on line 52 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt#L43-L52

Added lines #L43 - L52 were not covered by tests

init {
title = AmazonQBundle.message("amazonQChat.incompatible.title")

Check warning on line 55 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Amazon Q Chat not Supported on this Platform' is not properly capitalized. It should have title capitalization

Check warning

Code scanning / QDJVMC

Incorrect string capitalization Warning

String 'Amazon Q Chat not Supported on this Platform' is not properly capitalized. It should have title capitalization
init()
}

Check warning on line 57 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt#L54-L57

Added lines #L54 - L57 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
action.q.hello.description=Hello description
amazonqChat.incompatible.text=JCEF, a dependency of Amazon Q chat is not supported in {0}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
amazonqChat.incompatible.text=JCEF, a dependency of Amazon Q chat is not supported in {0}
amazonqChat.incompatible.text=JCEF, a dependency of Amazon Q Chat is not supported in {0}

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe too long? break into 2 lines?

"Webview support is not available"
"{amazonqChat.incompatible.text}"

amazonQChat.incomptible.text.fix=<html>To fix this,<ul><li>Click on Help-> Find Actions: Choose Boot runtime for the IDE</li><li>Select the latest JetBrains Runtime JBR with JCEF that matches the default runtime</li></ul></html>
Copy link
Contributor

Choose a reason for hiding this comment

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

amazonQChat.incompatible.title=Amazon Q Chat not Supported on this Platform
amazonqInlineChat.hint.edit = Edit
amazonqInlineChat.popup.accept=Accept \u23CE
amazonqInlineChat.popup.cancel=Cancel \u238B
Expand Down
Loading