Skip to content

Commit 02f96df

Browse files
#1905018: [Test] Reset/Apply don't work well in Azure/Settings
#1904988: [Test]In the settings, set the database save password method to never/forever, and it will be displayed as until restart after reopening
1 parent fc279cb commit 02f96df

File tree

1 file changed

+11
-21
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/intellij/ui

1 file changed

+11
-21
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/intellij/ui/AzurePanel.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.intellij.ui.SimpleListCellRenderer;
1515
import com.intellij.util.ui.UIUtil;
1616
import com.microsoft.azure.toolkit.ide.common.store.AzureConfigInitializer;
17-
import com.microsoft.azure.toolkit.intellij.connector.Password;
17+
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
1818
import com.microsoft.azure.toolkit.intellij.connector.database.component.PasswordSaveComboBox;
1919
import com.microsoft.azure.toolkit.lib.Azure;
2020
import com.microsoft.azure.toolkit.lib.AzureConfiguration;
@@ -31,23 +31,14 @@
3131
import org.jetbrains.annotations.NotNull;
3232

3333
import javax.annotation.Nonnull;
34-
import javax.swing.ComboBoxModel;
35-
import javax.swing.DefaultComboBoxModel;
36-
import javax.swing.JCheckBox;
37-
import javax.swing.JComboBox;
38-
import javax.swing.JComponent;
39-
import javax.swing.JLabel;
40-
import javax.swing.JList;
41-
import javax.swing.JPanel;
42-
import javax.swing.JTextPane;
43-
import java.awt.Dimension;
34+
import javax.swing.*;
35+
import java.awt.*;
4436
import java.awt.event.ItemEvent;
45-
import java.util.Arrays;
4637
import java.util.Objects;
4738

39+
import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message;
4840
import static com.microsoft.azuretools.telemetry.TelemetryConstants.ACCOUNT;
4941
import static com.microsoft.azuretools.telemetry.TelemetryConstants.SIGNOUT;
50-
import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message;
5142

5243

5344
@Slf4j
@@ -101,10 +92,7 @@ public void setData(AzureConfiguration config) {
10192
//ignore
10293
funcCoreToolsPath.setValue(config.getFunctionCoreToolsPath());
10394
}
104-
105-
savePasswordComboBox.setValue(Arrays.stream(Password.SaveType.values())
106-
.filter(e -> StringUtils.equals(e.name(), config.getDatabasePasswordSaveType())).findAny()
107-
.orElse(Password.SaveType.UNTIL_RESTART));
95+
savePasswordComboBox.setValue(new AzureComboBox.ItemReference<>(config.getDatabasePasswordSaveType().toLowerCase(), e -> e.name().toLowerCase()));
10896
allowTelemetryCheckBox.setSelected(config.getTelemetryEnabled());
10997

11098
azureEnvironmentComboBox.setSelectedItem(ObjectUtils.firstNonNull(AzureEnvironmentUtils.stringToAzureEnvironment(config.getCloud()),
@@ -135,11 +123,11 @@ private void displayDescriptionForAzureEnv() {
135123
azureEnvDesc.setIcon(AllIcons.General.Information);
136124
} else {
137125
setTextToLabel(azureEnvDesc,
138-
String.format("You are currently signed in with environment: %s, your change will sign out your account.", currentEnvStr));
126+
String.format("You are currently signed in to environment: %s, your change will sign out your account.", currentEnvStr));
139127
azureEnvDesc.setIcon(AllIcons.General.Warning);
140128
}
141129
} else {
142-
setTextToLabel(azureEnvDesc, "You are currently not signed, the environment will be applied when you sign in next time.");
130+
setTextToLabel(azureEnvDesc, "You are currently not signed in, the environment will be applied when you sign in next time.");
143131
azureEnvDesc.setIcon(AllIcons.General.Warning);
144132
}
145133
}
@@ -181,7 +169,7 @@ public boolean doOKAction() {
181169
config.setUserAgent(userAgent);
182170
CommonSettings.setUserAgent(config.getUserAgent());
183171
// apply changes
184-
172+
this.originalData = config;
185173
// we need to get rid of AuthMethodManager, using az.azure_account
186174
if (AuthMethodManager.getInstance().isSignedIn()) {
187175
final AuthMethodManager authMethodManager = AuthMethodManager.getInstance();
@@ -224,7 +212,9 @@ public boolean isModified() {
224212

225213
final AzureConfiguration data = getData();
226214

227-
if (!StringUtils.equalsIgnoreCase(data.getCloud(), originalData.getCloud())) {
215+
final AzureEnvironment newEnv = AzureEnvironmentUtils.stringToAzureEnvironment(data.getCloud());
216+
final AzureEnvironment oldEnv = AzureEnvironmentUtils.stringToAzureEnvironment(originalData.getCloud());
217+
if (!Objects.equals(newEnv, oldEnv)) {
228218
return true;
229219
}
230220

0 commit comments

Comments
 (0)