Skip to content

Commit 6c72ed2

Browse files
#1905108: [Test]Select to deploy Function app from the project, the local.settings.json file has been loading when import app settings
1 parent d47a879 commit 6c72ed2

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/component/table/AppSettingsDialogPresenter.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
import com.microsoft.azure.toolkit.lib.Azure;
99
import com.microsoft.azure.toolkit.lib.appservice.AzureAppService;
1010
import com.microsoft.azure.toolkit.lib.appservice.service.impl.FunctionApp;
11+
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
1112
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1213
import com.microsoft.azuretools.core.mvp.ui.base.MvpPresenter;
1314
import rx.Observable;
1415

1516
import java.nio.file.Path;
17+
import java.util.Map;
1618

1719
public class AppSettingsDialogPresenter<V extends ImportAppSettingsView> extends MvpPresenter<V> {
1820
public void onLoadFunctionApps() {
@@ -40,16 +42,17 @@ public void onLoadFunctionAppSettings(FunctionApp functionApp) {
4042
}
4143

4244
public void onLoadLocalSettings(Path localSettingsJsonPath) {
43-
Observable.fromCallable(() -> {
45+
final AzureTaskManager tm = AzureTaskManager.getInstance();
46+
tm.runOnPooledThread(() -> {
4447
getMvpView().beforeFillAppSettings();
45-
return AppSettingsTableUtils.getAppSettingsFromLocalSettingsJson(localSettingsJsonPath.toFile());
46-
}).subscribeOn(getSchedulerProvider().io())
47-
.subscribe(appSettings -> AzureTaskManager.getInstance().runLater(() -> {
48-
if (isViewDetached()) {
49-
return;
50-
}
51-
getMvpView().fillFunctionAppSettings(appSettings);
52-
}));
48+
final Map<String, String> settings = AppSettingsTableUtils.getAppSettingsFromLocalSettingsJson(localSettingsJsonPath.toFile());
49+
tm.runLater(() -> {
50+
if (isViewDetached()) {
51+
return;
52+
}
53+
getMvpView().fillFunctionAppSettings(settings);
54+
}, AzureTask.Modality.ANY);
55+
});
5356
}
5457

5558
private void errorHandler(Throwable e) {

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/component/table/AppSettingsTableUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.io.IOException;
4040
import java.util.HashMap;
4141
import java.util.Map;
42+
import java.util.Optional;
4243

4344
import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message;
4445

@@ -114,11 +115,11 @@ public void windowClosed(WindowEvent windowEvent) {
114115
@Override
115116
public void actionPerformed(AnActionEvent anActionEvent) {
116117
try {
117-
FileSaverDescriptor fileDescriptor = new FileSaverDescriptor(message("function.appSettings.export.description"), "");
118+
final FileSaverDescriptor fileDescriptor = new FileSaverDescriptor(message("function.appSettings.export.description"), "");
118119
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(fileDescriptor, (Project) null);
119120
final VirtualFile userHome = LocalFileSystem.getInstance().findFileByPath(System.getProperty("user.home"));
120121
final VirtualFileWrapper fileWrapper = dialog.save(userHome, LOCAL_SETTINGS_JSON);
121-
final File file = fileWrapper.getFile();
122+
final File file = Optional.ofNullable(fileWrapper).map(VirtualFileWrapper::getFile).orElse(null);
122123
if (file != null) {
123124
AppSettingsTableUtils.exportLocalSettingsJsonFile(file, appSettingsTable.getAppSettings());
124125
AzureMessager.getMessager().info(message("function.appSettings.export.succeed.title"), message("function.appSettings.export.succeed.message"));

0 commit comments

Comments
 (0)