Skip to content

Commit 323be12

Browse files
Merge remote-tracking branch 'origin/endgame-june' into endgame-june.next
2 parents e10e7b3 + 411ff5c commit 323be12

File tree

11 files changed

+20
-74
lines changed

11 files changed

+20
-74
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-resource-connector-lib/src/main/java/com/microsoft/azure/toolkit/intellij/connector/ModuleResource.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
package com.microsoft.azure.toolkit.intellij.connector;
77

8-
import com.intellij.openapi.module.Module;
9-
import com.intellij.openapi.module.ModuleManager;
108
import com.intellij.openapi.project.Project;
11-
import com.intellij.openapi.project.ProjectManager;
129
import com.microsoft.azure.toolkit.intellij.common.AzureFormJPanel;
1310
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
1411
import lombok.EqualsAndHashCode;
@@ -18,8 +15,6 @@
1815
import org.jdom.Element;
1916

2017
import javax.annotation.Nullable;
21-
import java.util.Arrays;
22-
import java.util.Objects;
2318

2419
@Getter
2520
@RequiredArgsConstructor
@@ -29,23 +24,12 @@ public final class ModuleResource implements Resource {
2924
private final String type = Definition.IJ_MODULE.type;
3025
@EqualsAndHashCode.Include
3126
private final String moduleName;
32-
private Module module;
3327

3428
@Override
3529
public String getId() {
3630
return moduleName;
3731
}
3832

39-
public Module getModule() {
40-
if (this.module == null) {
41-
final Project project = ProjectManager.getInstance().getOpenProjects()[0];
42-
this.module = Arrays.stream(ModuleManager.getInstance(project).getModules())
43-
.filter(m -> Objects.equals(m.getName(), moduleName)).findAny()
44-
.orElse(null);
45-
}
46-
return this.module;
47-
}
48-
4933
public String toString() {
5034
return String.format("Module \"%s\"", this.moduleName);
5135
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/connector/database/DatabaseResourceConnection.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public boolean isApplicableFor(@Nonnull RunConfiguration configuration) {
8585
@Override
8686
@AzureOperation(name = "connector|mysql.prepare_before_run", type = AzureOperation.Type.ACTION)
8787
public boolean prepareBeforeRun(@Nonnull RunConfiguration configuration, DataContext dataContext) {
88-
this.env = this.initEnv();
88+
this.env = this.initEnv(configuration.getProject());
8989
if (configuration instanceof WebAppConfiguration) { // set envs for remote deploy
9090
final WebAppConfiguration webAppConfiguration = (WebAppConfiguration) configuration;
9191
webAppConfiguration.setApplicationSettings(this.env);
@@ -116,19 +116,17 @@ private static Module getTargetModule(@NotNull RunConfiguration configuration) {
116116
return null;
117117
}
118118

119-
private Map<String, String> initEnv() {
119+
private Map<String, String> initEnv(@Nonnull final Project project) {
120120
final Map<String, String> env = new HashMap<>();
121-
final Module module = this.consumer.getModule();
122121
final DatabaseResource mysql = this.resource;
123-
assert module != null : "loading password from unknown module";
124122
env.put(mysql.getEnvPrefix() + "URL", this.resource.getJdbcUrl().toString());
125123
env.put(mysql.getEnvPrefix() + "USERNAME", this.resource.getUsername());
126-
env.put(mysql.getEnvPrefix() + "PASSWORD", loadPassword(mysql).or(() -> inputPassword(module, mysql)).orElse(""));
124+
env.put(mysql.getEnvPrefix() + "PASSWORD", loadPassword(mysql).or(() -> inputPassword(project, mysql)).orElse(""));
127125
return env;
128126
}
129127

130128
private static Optional<String> loadPassword(@Nonnull final DatabaseResource resource) {
131-
if (Optional.ofNullable(resource.getPassword()).map(Password::saveType).get() == Password.SaveType.NEVER) {
129+
if (Objects.nonNull(resource.getPassword()) && resource.getPassword().saveType() == Password.SaveType.NEVER) {
132130
return Optional.empty();
133131
}
134132
final String saved = PasswordStore.loadPassword(resource.getId(), resource.getUsername(), resource.getPassword().saveType());
@@ -143,11 +141,11 @@ private static Optional<String> loadPassword(@Nonnull final DatabaseResource res
143141
}
144142

145143
@Nonnull
146-
private static Optional<String> inputPassword(@Nonnull final Module module, @Nonnull final DatabaseResource resource) {
144+
private static Optional<String> inputPassword(@Nonnull final Project project, @Nonnull final DatabaseResource resource) {
147145
final AtomicReference<Password> passwordRef = new AtomicReference<>();
148146
final IAzureOperationTitle title = AzureOperationBundle.title("mysql.update_password");
149147
AzureTaskManager.getInstance().runAndWait(title, () -> {
150-
final PasswordDialog dialog = new PasswordDialog(module.getProject(), resource);
148+
final PasswordDialog dialog = new PasswordDialog(project, resource);
151149
if (dialog.showAndGet()) {
152150
final Password password = dialog.getData();
153151
resource.getPassword().saveType(password.saveType());

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/WebAppComboBox.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.microsoft.azure.toolkit.intellij.appservice.AppServiceComboBox;
10+
import com.microsoft.azure.toolkit.lib.Azure;
11+
import com.microsoft.azure.toolkit.lib.appservice.AzureAppService;
1012
import com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion;
1113
import com.microsoft.azure.toolkit.lib.appservice.service.IWebApp;
1214
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
1315
import com.microsoft.azure.toolkit.lib.webapp.WebAppService;
1416
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
15-
import com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel;
1617
import com.microsoft.tooling.msservices.components.DefaultLoader;
1718

1819
import java.util.List;
@@ -47,7 +48,7 @@ protected void createResource() {
4748
type = AzureOperation.Type.SERVICE
4849
)
4950
protected List<WebAppComboBoxModel> loadAppServiceModels() {
50-
final List<IWebApp> webApps = AzureWebAppMvpModel.getInstance().listAzureWebApps(false);
51+
final List<IWebApp> webApps = Azure.az(AzureAppService.class).webapps(false);
5152
return webApps.stream()
5253
.filter(webApp -> webApp.getRuntime().getJavaVersion() != null && webApp.getRuntime().getJavaVersion() != JavaVersion.OFF)
5354
.sorted((a, b) -> a.name().compareToIgnoreCase(b.name()))

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/docker/webapponlinux/WebAppOnLinuxDeployState.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,9 @@ protected Operation createOperation() {
123123
type = AzureOperation.Type.TASK
124124
)
125125
protected void onSuccess(IAppService result, @NotNull RunProcessHandler processHandler) {
126-
processHandler.setText("Updating cache ... ");
127-
AzureWebAppMvpModel.getInstance().listAzureWebApps(true); // todo: replace with cache framework
128-
processHandler.setText("Job done");
129126
processHandler.notifyComplete();
130127
if (deployModel.isCreatingNewWebAppOnLinux() && AzureUIRefreshCore.listeners != null) {
131-
AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, null));
128+
AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, result));
132129
}
133130
}
134131

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/runner/webappconfig/WebAppRunState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected Operation createOperation() {
115115
@AzureOperation(name = "webapp.complete_starting.state", type = AzureOperation.Type.ACTION)
116116
protected void onSuccess(IAppService result, @NotNull RunProcessHandler processHandler) {
117117
if (webAppSettingModel.isCreatingNew() && AzureUIRefreshCore.listeners != null) {
118-
AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, null));
118+
AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, result));
119119
}
120120
updateConfigurationDataModel(result);
121121
int indexOfDot = webAppSettingModel.getTargetName().lastIndexOf(".");

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/container/WebAppOnLinuxDeployPresenter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.microsoft.azure.toolkit.lib.appservice.service.IWebApp;
1313
import com.microsoft.azure.toolkit.lib.auth.AzureAccount;
1414
import com.microsoft.azuretools.core.mvp.model.AzureMvpModel;
15-
import com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel;
1615
import com.microsoft.azuretools.core.mvp.ui.base.MvpPresenter;
1716
import com.microsoft.tooling.msservices.components.DefaultLoader;
1817
import reactor.core.publisher.Flux;
@@ -34,7 +33,7 @@ public class WebAppOnLinuxDeployPresenter<V extends WebAppOnLinuxDeployView> ext
3433
private static final String CANNOT_LIST_APP_SERVICE_PLAN = "Failed to list app service plan.";
3534

3635
private List<IWebApp> retrieveListOfWebAppOnLinux(boolean force) {
37-
return AzureWebAppMvpModel.getInstance().listAzureWebApps(force).stream()
36+
return Azure.az(AzureAppService.class).webapps(force).stream()
3837
.filter(iWebApp -> iWebApp.getRuntime().getOperatingSystem() != OperatingSystem.WINDOWS) // docker and linux
3938
.collect(Collectors.toList());
4039
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/function/FunctionAppNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
package com.microsoft.tooling.msservices.serviceexplorer.azure.function;
77

8-
import com.microsoft.azure.toolkit.lib.Azure;
9-
import com.microsoft.azure.toolkit.lib.appservice.AzureAppService;
108
import com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp;
119
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
1210
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
@@ -29,7 +27,7 @@ public class FunctionAppNode extends WebAppBaseNode {
2927

3028
private static final String FUNCTION_LABEL = "Function";
3129

32-
private IFunctionApp functionApp;
30+
private final IFunctionApp functionApp;
3331

3432
public FunctionAppNode(@Nonnull AzureRefreshableNode parent, @Nonnull IFunctionApp functionApp) {
3533
super(parent, FUNCTION_LABEL, functionApp);

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/function/FunctionModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void removeNode(String sid, String id, Node node) {
4444
@Override
4545
@AzureOperation(name = "function.reload_all", type = AzureOperation.Type.ACTION)
4646
protected void refreshItems() {
47-
Azure.az(AzureAppService.class).functionApps()
47+
Azure.az(AzureAppService.class).functionApps(true)
4848
.stream().map(functionApp -> new FunctionAppNode(FunctionModule.this, functionApp))
4949
.forEach(this::addChildNode);
5050
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/webapp/WebAppModule.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
1010
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
1111
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
12-
import com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel;
1312
import com.microsoft.azuretools.utils.AzureUIRefreshCore;
1413
import com.microsoft.azuretools.utils.AzureUIRefreshEvent;
1514
import com.microsoft.azuretools.utils.AzureUIRefreshListener;
16-
import com.microsoft.azuretools.utils.WebAppUtils;
17-
import com.microsoft.tooling.msservices.components.DefaultLoader;
1815
import com.microsoft.tooling.msservices.serviceexplorer.AzureIconSymbol;
1916
import com.microsoft.tooling.msservices.serviceexplorer.AzureRefreshableNode;
2017
import com.microsoft.tooling.msservices.serviceexplorer.Node;
@@ -68,12 +65,12 @@ public void run() {
6865
if (event.opsType == AzureUIRefreshEvent.EventType.SIGNIN || event.opsType == AzureUIRefreshEvent
6966
.EventType.SIGNOUT) {
7067
removeAllChildNodes();
71-
} else if (event.object == null && (event.opsType == AzureUIRefreshEvent.EventType.UPDATE || event
68+
} else if (event.object instanceof IWebApp && (event.opsType == AzureUIRefreshEvent.EventType.UPDATE || event
7269
.opsType == AzureUIRefreshEvent.EventType.REMOVE)) {
7370
if (hasChildNodes()) {
7471
load(true);
7572
}
76-
} else if (event.object == null && event.opsType == AzureUIRefreshEvent.EventType.REFRESH) {
73+
} else if (event.object instanceof IWebApp && event.opsType == AzureUIRefreshEvent.EventType.REFRESH) {
7774
load(true);
7875
}
7976
}
@@ -88,4 +85,5 @@ public void renderChildren(@NotNull final List<IWebApp> resourceExes) {
8885
.map(webApp -> new WebAppNode(this, webApp))
8986
.forEach(this::addChildNode);
9087
}
88+
9189
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/webapp/WebAppModulePresenter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package com.microsoft.tooling.msservices.serviceexplorer.azure.webapp;
77

8+
import com.microsoft.azure.toolkit.lib.Azure;
9+
import com.microsoft.azure.toolkit.lib.appservice.AzureAppService;
810
import com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel;
911
import com.microsoft.azuretools.core.mvp.ui.base.MvpPresenter;
1012

@@ -15,7 +17,7 @@ public class WebAppModulePresenter<V extends WebAppModuleView> extends MvpPresen
1517
public void onModuleRefresh() {
1618
final WebAppModuleView view = getMvpView();
1719
if (view != null) {
18-
view.renderChildren(AzureWebAppMvpModel.getInstance().listAzureWebApps(true));
20+
view.renderChildren(Azure.az(AzureAppService.class).webapps(true));
1921
}
2022
}
2123

0 commit comments

Comments
 (0)