diff --git a/build.gradle.kts b/build.gradle.kts index e7f4d9e0..07202e4e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "com.couchbase" -version = "1.1.1" +version = "1.1.2" java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 @@ -80,7 +80,7 @@ tasks { } patchPluginXml { - sinceBuild.set("233.*") + sinceBuild.set("232.10227.8") untilBuild.set("246.*") } diff --git a/src/main/java/com/couchbase/intellij/tree/iq/CapellaOrganizationList.java b/src/main/java/com/couchbase/intellij/tree/iq/CapellaOrganizationList.java index a9e5480b..9ab71b10 100644 --- a/src/main/java/com/couchbase/intellij/tree/iq/CapellaOrganizationList.java +++ b/src/main/java/com/couchbase/intellij/tree/iq/CapellaOrganizationList.java @@ -25,8 +25,6 @@ public CapellaOrganizationList getOnlyIqEnabledOrgs() { .filter(org -> org.getData() != null) .filter(org -> org.getData().getIq() != null) .filter(org -> org.getData().getIq().isEnabled()) - .filter(org -> org.getData().getIq().getOther() != null) - .filter(org -> org.getData().getIq().getOther().getIsTermsAcceptedForOrg()) .collect(Collectors.toList()) ); return filteredList; diff --git a/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java b/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java index 5fab4e2b..25024e3b 100644 --- a/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java +++ b/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java @@ -87,7 +87,7 @@ public void onLogin(IQCredentials credentials) { this.credentials = credentials; this.removeAll(); try { - this.organizationList = credentials.getOrganizations(); + this.organizationList = credentials.getOrganizations().getOnlyIqEnabledOrgs(); if (organizationList.getData().isEmpty()) { Notifications.Bus.notify(new Notification(ChatGptBundle.message("group.id"), "No Capella organizations found", "At least one organization is required to use Couchbase IQ. No organizations found.", NotificationType.ERROR)); onLogout(null); @@ -143,7 +143,9 @@ public void onOrgSelected(CapellaOrganization organization) { if (!credentials.checkIqIsEnabled(organization.getId())) { Notifications.Bus.notify(new Notification(ChatGptBundle.message("group.id"), "Unable to use this organization", "Capella iQ is not enabled for this organization.", NotificationType.ERROR)); - onLogout(null); + if (chatPanel == null) { + onLogout(null); + } return; } diff --git a/src/main/java/com/couchbase/intellij/tree/iq/settings/OpenAISettingsState.java b/src/main/java/com/couchbase/intellij/tree/iq/settings/OpenAISettingsState.java index 68d1467d..4394144b 100644 --- a/src/main/java/com/couchbase/intellij/tree/iq/settings/OpenAISettingsState.java +++ b/src/main/java/com/couchbase/intellij/tree/iq/settings/OpenAISettingsState.java @@ -151,9 +151,11 @@ public String getApiKey() { } public void setApiKey(String apiKey) { - var credentialAttributes = createCredentialAttributes(getModelPage()); - PasswordSafe.getInstance().setPassword(credentialAttributes, apiKey); - setApiKeyMasked(maskText(apiKey)); + ApplicationManager.getApplication().executeOnPooledThread(() -> { + var credentialAttributes = createCredentialAttributes(getModelPage()); + PasswordSafe.getInstance().setPassword(credentialAttributes, apiKey); + setApiKeyMasked(maskText(apiKey)); + }); } private static String maskText(String text) { diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java index 83b56072..45ec7c75 100644 --- a/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java +++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java @@ -39,6 +39,7 @@ import java.util.Comparator; import java.util.List; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; import static com.couchbase.intellij.workbench.CustomSqlFileEditor.NO_QUERY_CONTEXT_SELECTED; @@ -204,10 +205,11 @@ public void actionPerformed(@NotNull AnActionEvent e) { private JPanel createSettingsPanel(CapellaOrganizationList organizationList, ChatPanel.LogoutListener logoutListener) { JPanel panel = new NonOpaquePanel(new GridLayout(0, 1)); JPanel orgPanel = new NonOpaquePanel(new BorderLayout()); + + orgSelector = new ComboBox<>(organizationList.getData().stream() - .map(org -> org.getData()) - .filter(data -> data.getIq() != null && data.getIq().isEnabled()) - .map(data -> data.getName()) + .map(CapellaOrganizationList.Entry::getData) + .map(CapellaOrganization::getName) .toArray(String[]::new)); orgSelector.setSelectedIndex(organizationList.indexOf(organization)); diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/view/CapellaOrgSelectorView.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/view/CapellaOrgSelectorView.java index 21319823..536df1f8 100644 --- a/src/main/java/com/couchbase/intellij/tree/iq/ui/view/CapellaOrgSelectorView.java +++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/view/CapellaOrgSelectorView.java @@ -28,7 +28,6 @@ public CapellaOrgSelectorView(CapellaOrganizationList organizationList, ChatPane add(new JLabel(SELECT_ORG_LABEL), gbc); ComboBox orgSelector = new ComboBox<>(organizationList.getData().stream() .map(org -> org.getData()) - .filter(data -> data.getIq() != null && data.getIq().isEnabled()) .map(data -> String.format("%s%s", data.getName(), !data.getIq().getOther().getIsTermsAcceptedForOrg() ? " (*)" : "")) .toArray(String[]::new));