Skip to content

Commit

Permalink
Merge pull request #210 from couchbaselabs/loginfix
Browse files Browse the repository at this point in the history
Fixes logins
  • Loading branch information
deniswsrosa authored May 28, 2024
2 parents fb092ba + 1b76d77 commit b17ee39
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,7 +80,7 @@ tasks {
}

patchPluginXml {
sinceBuild.set("233.*")
sinceBuild.set("232.10227.8")
untilBuild.set("246.*")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit b17ee39

Please sign in to comment.