Skip to content

Commit f32b50d

Browse files
authored
Merge pull request #5074 from microsoft/function/fixAppSettings
Clear app settings table before load app settings
2 parents 4e8954a + 59f21ae commit f32b50d

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/FunctionDeployConfiguration.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package com.microsoft.azure.toolkit.intellij.function.runner.deploy;
77

8-
import com.intellij.execution.ExecutionException;
98
import com.intellij.execution.Executor;
109
import com.intellij.execution.configurations.ConfigurationFactory;
1110
import com.intellij.execution.configurations.RunConfiguration;
@@ -19,8 +18,8 @@
1918
import com.intellij.openapi.project.Project;
2019
import com.microsoft.azure.common.function.configurations.RuntimeConfiguration;
2120
import com.microsoft.azure.management.appservice.FunctionApp;
22-
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBoxModel;
2321
import com.microsoft.azure.toolkit.intellij.common.AzureRunConfigurationBase;
22+
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBoxModel;
2423
import com.microsoft.azure.toolkit.intellij.function.runner.core.FunctionUtils;
2524
import org.apache.commons.lang.StringUtils;
2625
import org.jetbrains.annotations.NotNull;
@@ -67,7 +66,7 @@ public String getFunctionId() {
6766
return functionDeployModel.getFunctionId();
6867
}
6968

70-
public Map getAppSettings() {
69+
public Map<String, String> getAppSettings() {
7170
return functionDeployModel.getAppSettings();
7271
}
7372

@@ -140,8 +139,7 @@ public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
140139

141140
@Nullable
142141
@Override
143-
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment)
144-
throws ExecutionException {
142+
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) {
145143
return new FunctionDeploymentState(getProject(), this);
146144
}
147145

@@ -227,7 +225,6 @@ public void setAppSettingsKey(String appSettingsStorageKey) {
227225
public void saveModel(FunctionAppComboBoxModel functionAppComboBoxModel) {
228226
if (functionAppComboBoxModel.getFunctionDeployModel() != null) {
229227
setFunctionDeployModel(functionAppComboBoxModel.getFunctionDeployModel());
230-
return;
231228
} else {
232229
functionDeployModel.saveModel(functionAppComboBoxModel);
233230
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/ui/FunctionDeployViewPresenter.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import com.microsoft.azure.management.appservice.FunctionApp;
99
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
10-
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
11-
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1210
import com.microsoft.azuretools.core.mvp.ui.base.MvpPresenter;
1311
import com.microsoft.tooling.msservices.components.DefaultLoader;
1412
import rx.Observable;
@@ -33,17 +31,15 @@ public void loadAppSettings(FunctionApp functionApp) {
3331
return;
3432
}
3533
unsubscribeSubscription(loadAppSettingsSubscription);
36-
loadAppSettingsSubscription = Observable.fromCallable(() -> {
37-
AzureTaskManager.getInstance().runAndWait(() -> getMvpView().beforeFillAppSettings(), AzureTask.Modality.ANY);
38-
return functionApp.getAppSettings();
39-
}).subscribeOn(getSchedulerProvider().io())
40-
.subscribe(appSettings -> DefaultLoader.getIdeHelper().invokeLater(() -> {
41-
if (isViewDetached()) {
42-
return;
43-
}
44-
final Map<String, String> result = new HashMap<>();
45-
appSettings.entrySet().forEach(entry -> result.put(entry.getKey(), entry.getValue().value()));
46-
getMvpView().fillAppSettings(result);
47-
}));
34+
loadAppSettingsSubscription =
35+
Observable.fromCallable(functionApp::getAppSettings).subscribeOn(getSchedulerProvider().io())
36+
.subscribe(appSettings -> DefaultLoader.getIdeHelper().invokeLater(() -> {
37+
if (isViewDetached()) {
38+
return;
39+
}
40+
final Map<String, String> result = new HashMap<>();
41+
appSettings.forEach((key, value) -> result.put(key, value.value()));
42+
getMvpView().fillAppSettings(result);
43+
}));
4844
}
4945
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/ui/FunctionDeploymentPanel.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import com.intellij.icons.AllIcons;
99
import com.intellij.openapi.module.Module;
1010
import com.intellij.openapi.project.Project;
11+
import com.intellij.openapi.ui.ComboBox;
1112
import com.intellij.packaging.artifacts.Artifact;
1213
import com.intellij.ui.HyperlinkLabel;
1314
import com.intellij.ui.ListCellRendererWrapper;
1415
import com.microsoft.azure.toolkit.intellij.appservice.AppServiceComboBoxModel;
15-
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
16+
import com.microsoft.azure.toolkit.intellij.common.AzureSettingPanel;
1617
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBox;
1718
import com.microsoft.azure.toolkit.intellij.function.FunctionAppComboBoxModel;
18-
import com.microsoft.azure.toolkit.intellij.common.AzureSettingPanel;
1919
import com.microsoft.azure.toolkit.intellij.function.runner.component.table.AppSettingsTable;
2020
import com.microsoft.azure.toolkit.intellij.function.runner.component.table.AppSettingsTableUtils;
2121
import com.microsoft.azure.toolkit.intellij.function.runner.core.FunctionUtils;
@@ -39,7 +39,7 @@
3939

4040
public class FunctionDeploymentPanel extends AzureSettingPanel<FunctionDeployConfiguration> implements FunctionDeployMvpView {
4141

42-
private FunctionDeployViewPresenter presenter = null;
42+
private final FunctionDeployViewPresenter<FunctionDeploymentPanel> presenter;
4343

4444
private JPanel pnlRoot;
4545
private HyperlinkLabel lblCreateFunctionApp;
@@ -53,10 +53,10 @@ public class FunctionDeploymentPanel extends AzureSettingPanel<FunctionDeployCon
5353

5454
public FunctionDeploymentPanel(@NotNull Project project, @NotNull FunctionDeployConfiguration functionDeployConfiguration) {
5555
super(project);
56-
this.presenter = new FunctionDeployViewPresenter();
56+
this.presenter = new FunctionDeployViewPresenter<>();
5757
this.presenter.onAttachView(this);
5858

59-
cbFunctionModule.setRenderer(new ListCellRendererWrapper<Module>() {
59+
cbFunctionModule.setRenderer(new ListCellRendererWrapper<>() {
6060
@Override
6161
public void customize(JList list, Module module, int i, boolean b, boolean b1) {
6262
if (module != null) {
@@ -101,7 +101,7 @@ public JPanel getMainPanel() {
101101
@NotNull
102102
@Override
103103
protected JComboBox<Artifact> getCbArtifact() {
104-
return new JComboBox<Artifact>();
104+
return new ComboBox<>();
105105
}
106106

107107
@NotNull
@@ -113,7 +113,7 @@ protected JLabel getLblArtifact() {
113113
@NotNull
114114
@Override
115115
protected JComboBox<MavenProject> getCbMavenProject() {
116-
return new JComboBox<MavenProject>();
116+
return new ComboBox<>();
117117
}
118118

119119
@NotNull
@@ -183,6 +183,7 @@ private void onSelectFunctionApp() {
183183
} else { // For existing Functions
184184
if (!AppServiceComboBoxModel.isSameApp(model, appSettingsFunctionApp) || appSettingsTable.isEmpty()) {
185185
// Do not refresh if selected function app is not changed except create run configuration from azure explorer
186+
this.beforeFillAppSettings();
186187
presenter.loadAppSettings(model.getResource());
187188
}
188189
}

0 commit comments

Comments
 (0)