Skip to content
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

Show notification if the download of an AppMap CLI binary failed #815

Merged
merged 1 commit into from
Jan 22, 2025
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
@@ -0,0 +1,20 @@
package appland.cli;

import appland.notifications.AppMapNotifications;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

public final class FailedDownloadNotificationListener implements AppLandDownloadListener {
@NotNull private final Project project;

public FailedDownloadNotificationListener(@NotNull Project project) {
this.project = project;
}

@Override
public void downloadFinished(@NotNull CliTool type, boolean success) {
if (!success) {
AppMapNotifications.showFailedCliBinaryDownloadNotification(project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,36 @@ public static void showCopilotAuthenticationRequired() {
}
});
}

/**
* See https://github.com/getappmap/appmap-intellij-plugin/issues/814.
*/
public static void showFailedCliBinaryDownloadNotification(@NotNull Project project) {
if (!AppMapApplicationSettingsService.getInstance().isShowFailedCliDownloadError()) {
return;
}

// the message should only appear once
AppMapApplicationSettingsService.getInstance().setShowFailedCliDownloadError(false);

ApplicationManager.getApplication().invokeLater(() -> {
Notification notification = new AppMapFullContentNotification(
GENERIC_NOTIFICATIONS_ID,
null,
AppMapBundle.get("notification.cliDownloadFailed.title"),
null,
AppMapBundle.get("notification.cliDownloadFailed.content"),
NotificationType.ERROR,
null
);

var showInstructionsAction = NotificationAction.create(lazy("notification.cliDownloadFailed.browseAction"), (e, n) -> {
n.expire();
BrowserUtil.browse("https://appmap.io/docs/reference/appmap-airgapped-install.html#download-the-appmap-application-binaries");
});

notification = notification.addAction(showInstructionsAction);
notification.notify(project);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class AppMapApplicationSettings {
*/
private volatile int maxPinnedFileSizeKB = 20;

private volatile boolean showFailedCliDownloadError = true;

public AppMapApplicationSettings() {
}

Expand Down
3 changes: 3 additions & 0 deletions plugin-core/src/main/resources/META-INF/appmap-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<listener topic="appland.cli.AppLandDownloadListener"
class="appland.cli.StartServicesAfterDownloadListener"/>

<listener topic="appland.cli.AppLandDownloadListener"
class="appland.cli.FailedDownloadNotificationListener"/>

<listener topic="appland.files.AppMapFileChangeListener"
class="appland.notifications.FirstAppMapListener"/>
</projectListeners>
Expand Down
5 changes: 5 additions & 0 deletions plugin-core/src/main/resources/messages/appland.properties
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ dirPathValidation.notDir=Please enter the location of a directory, not a file.

nameValidation.empty=Please enter a valid name.

notification.dontShowAgainOption=Don't show again
notification.closeButton=Close
notification.stopButton=Stop
notification.recordingHelpButton=Show Help
Expand Down Expand Up @@ -162,6 +163,10 @@ notification.exportAppMapJson.content=An error occurred while exporting AppMap J

notification.reloadProject.content=Please reload your project because the AppMap settings changed.

notification.cliDownloadFailed.title=Download Failed: AppMap CLI Tools
notification.cliDownloadFailed.content=Failed to download the AppMap CLI tools. This is a required dependency of the AppMap plugin. Please refer to the instructions to manually install it.
notification.cliDownloadFailed.browseAction=Show instructions

statusBar.recording.displayName=AppMap Recording
statusBar.recording.recordingStatus=Recording...

Expand Down
Loading