diff --git a/CHANGELOG.md b/CHANGELOG.md index 59567da..c4234f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [4.9.0] - 2025-09-25 +## [4.9.3] - 2025-10-06 - Disables CodeSync group if an invalid project is opened ## [4.8.0] - 2025-03-11 diff --git a/build.gradle b/build.gradle index a05aa43..513d1c9 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { } group 'com.codesync' -version '4.9.0' +version '4.9.3' compileJava.options.encoding = "UTF-8" diff --git a/src/main/java/org/intellij/sdk/codesync/Constants.java b/src/main/java/org/intellij/sdk/codesync/Constants.java index 8edfacb..4d3f479 100644 --- a/src/main/java/org/intellij/sdk/codesync/Constants.java +++ b/src/main/java/org/intellij/sdk/codesync/Constants.java @@ -201,6 +201,10 @@ private Notification() { public static final String ACCOUNT_DEACTIVATED = "Your account has been deactivated. Please click 'Reactivate Account' below to resume syncing."; public static final String ACCOUNT_REACTIVATE_BUTTON = "Reactivate Account"; public static final String REACTIVATED_SUCCESS = "Successfully reactivated your account"; + + // Invalid project related notification messages + public static final String INVALID_PROJECT_OPEN_FOLDER = "CodeSync only works with folders. Please open a folder to start syncing."; + public static final String INVALID_PROJECT_ACCOUNT_DEACTIVATED = "Your account is deactivated. In order to use CodeSync’s features, please use an active account."; } @@ -262,11 +266,4 @@ private CustomErrorCodes() { public static final int IS_FROZEN_REPO = 4000; public static final int PRIVATE_REPO_COUNT_LIMIT_REACHED = 4006; } - - public static final class StatusBarMessages { - public static final String OPEN_FOLDER = "CodeSync notification: CodeSync only works with folders. Please open a folder to start syncing."; - public static final String ACCOUNT_DEACTIVATED = "CodeSync notification: Your account is deactivated. In order to use CodeSync’s features, please use an active account."; - } } - - diff --git a/src/main/java/org/intellij/sdk/codesync/actions/CodeSyncActionGroup.java b/src/main/java/org/intellij/sdk/codesync/actions/CodeSyncActionGroup.java index 418da31..1800b2c 100644 --- a/src/main/java/org/intellij/sdk/codesync/actions/CodeSyncActionGroup.java +++ b/src/main/java/org/intellij/sdk/codesync/actions/CodeSyncActionGroup.java @@ -16,6 +16,7 @@ import org.intellij.sdk.codesync.utils.ProjectUtils; import com.intellij.openapi.ui.Messages; import org.intellij.sdk.codesync.Constants.*; +import org.intellij.sdk.codesync.NotificationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.StatusBar; @@ -57,12 +58,15 @@ public void update(@NotNull AnActionEvent e) { Project project = e.getProject(); boolean visible = true; - // Hide group if account is deactivated if (StateUtils.getGlobalState().isAccountDeactivated) { visible = false; // Display alert message - showStatusBarMessage(StatusBarMessages.ACCOUNT_DEACTIVATED, project); + NotificationManager.getInstance().notifyInformation( + Notification.INVALID_PROJECT_ACCOUNT_DEACTIVATED, project + ); + // Setting wasAlertShown=true so it only shows once + wasAlertShown = true; } // Hide group if invalid project path @@ -70,18 +74,27 @@ public void update(@NotNull AnActionEvent e) { visible = false; } - VirtualFile repoRoot = this.getRepoRoot(e, project); - if (repoRoot == null) { - visible = false; + if (project == null) { + e.getPresentation().setVisible(visible); + return; } - // A single file is opened, no need to sync it. - if (!repoRoot.isDirectory()) { + VirtualFile repoRoot = this.getRepoRoot(e, project); + if (repoRoot == null) { visible = false; - // Display alert message - showStatusBarMessage(StatusBarMessages.OPEN_FOLDER, project); + } else { + // A single file is opened, no need to sync it. + if (!repoRoot.isDirectory()) { + visible = false; + if (!wasAlertShown) { + NotificationManager.getInstance().notifyInformation( + Notification.INVALID_PROJECT_OPEN_FOLDER, project + ); + // Setting wasAlertShown=true so it only shows once + wasAlertShown = true; + } + } } - e.getPresentation().setVisible(visible); e.getPresentation().setEnabled(visible); }