Skip to content

Commit

Permalink
update deprecated manifest notification to feature do not show again …
Browse files Browse the repository at this point in the history
…button
  • Loading branch information
Nicolas Borges committed Jan 24, 2025
1 parent e2a532e commit 6dc96ed
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

import org.eclipse.swt.widgets.Display;
import software.aws.toolkits.eclipse.amazonq.util.Constants;
import software.aws.toolkits.eclipse.amazonq.util.ToolkitNotification;
import software.aws.toolkits.eclipse.amazonq.util.PersistentToolkitNotification;
import org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup;
import org.osgi.framework.Version;

import software.aws.toolkits.eclipse.amazonq.exception.AmazonQPluginException;
import software.aws.toolkits.eclipse.amazonq.lsp.manager.fetcher.ArtifactUtils;
Expand Down Expand Up @@ -88,8 +89,12 @@ private LspInstallResult fetchLspInstallation() {
}
Manifest manifest = fetchManifest();

if (manifest.isManifestDeprecated()) {
showDeprecatedManifestNotification();
if (manifest.isManifestDeprecated() && manifest.manifestSchemaVersion() != null) {
try {
showDeprecatedManifestNotification(manifest.manifestSchemaVersion());
} catch (Exception e) {
Activator.getLogger().error("Failed to show deprecated manifest notification", e);
}
}

var platform = platformOverride != null ? platformOverride : PluginUtils.getPlatform();
Expand Down Expand Up @@ -247,14 +252,30 @@ private static void makeExecutable(final Path filePath) throws IOException {
PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_EXECUTE));
Files.setPosixFilePermissions(filePath, permissions);
}
private static void showDeprecatedManifestNotification() {
Display.getDefault().asyncExec(() -> {
AbstractNotificationPopup notification = new ToolkitNotification(
Display.getDefault(),
Constants.MANIFEST_DEPRECATED_NOTIFICATION_TITLE,
Constants.MANIFEST_DEPRECATED_NOTIFICATION_BODY);
notification.open();
});

private static void showDeprecatedManifestNotification(final String version) {
Version storedValue = Activator.getPluginStore().getObject(Constants.MANIFEST_DEPRECATED_NOTIFICATION_KEY, Version.class);
Version schemaVersion = ArtifactUtils.parseVersion(version);

if (storedValue == null || remoteVersionIsGreater(schemaVersion, storedValue)) {
Display.getDefault().asyncExec(() -> {
AbstractNotificationPopup notification = new PersistentToolkitNotification(Display.getCurrent(),
Constants.MANIFEST_DEPRECATED_NOTIFICATION_TITLE,
Constants.MANIFEST_DEPRECATED_NOTIFICATION_BODY ,
(selected) -> {
if (selected) {
Activator.getPluginStore().putObject(Constants.MANIFEST_DEPRECATED_NOTIFICATION_KEY, schemaVersion);
} else {
Activator.getPluginStore().remove(Constants.MANIFEST_DEPRECATED_NOTIFICATION_KEY);
}
});
notification.open();
});
}
}

private static boolean remoteVersionIsGreater(final Version remote, final Version storedValue) {
return remote.compareTo(storedValue) > 0;
}

public static class Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ private Constants() {
public static final String DO_NOT_SHOW_UPDATE_KEY = "doNotShowUpdate";
public static final String PLUGIN_UPDATE_NOTIFICATION_TITLE = "Amazon Q Update Available";
public static final String PLUGIN_UPDATE_NOTIFICATION_BODY = "Amazon Q plugin version %s is available."
+ "Please update to receive the latest features and bug fixes.";
+ " Please update to receive the latest features and bug fixes.";
public static final String LSP_CW_OPT_OUT_KEY = "shareCodeWhispererContentWithAWS";
public static final String LSP_CODE_REFERENCES_OPT_OUT_KEY = "includeSuggestionsWithCodeReferences";
public static final String IDE_CUSTOMIZATION_NOTIFICATION_TITLE = "Amazon Q Customization";
public static final String IDE_CUSTOMIZATION_NOTIFICATION_BODY_TEMPLATE = "Amazon Q inline suggestions are now coming from the %s";
public static final String MANIFEST_DEPRECATED_NOTIFICATION_KEY = "doNotShowDeprecatedManifest";
public static final String MANIFEST_DEPRECATED_NOTIFICATION_TITLE = "Update Amazon Q Extension";
public static final String MANIFEST_DEPRECATED_NOTIFICATION_BODY = "This version of the plugin will no longer receive updates to Amazon Q Language authoring features";
public static final String DEFAULT_Q_FOUNDATION_DISPLAY_NAME = "Amazon Q foundation (Default)";
Expand Down

0 comments on commit 6dc96ed

Please sign in to comment.