Skip to content

Commit 167ddea

Browse files
Merge remote-tracking branch 'origin/wangmi/5-deployment-targets' into develop
2 parents 6551a30 + a9e82d7 commit 167ddea

File tree

83 files changed

+1606
-671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1606
-671
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice-java/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/action/DeployFunctionAppAction.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ public class DeployFunctionAppAction extends AnAction {
5050
@AzureOperation(name = "user/function.deploy_app")
5151
public void actionPerformed(@Nonnull AnActionEvent event) {
5252
OperationContext.current().setTelemetryProperty(PLACE, StringUtils.firstNonBlank(event.getPlace(), EMPTY_PLACE));
53-
final Module module = LangDataKeys.MODULE.getData(event.getDataContext());
54-
final Project project = Objects.requireNonNull(event.getProject());
55-
if (Objects.nonNull(module)) {
56-
AzureLoginHelper.requireSignedIn(module.getProject(), () -> deploy(module));
57-
} else {
58-
AzureLoginHelper.requireSignedIn(project, () -> deploy(project));
59-
}
53+
AzureTaskManager.getInstance().runLater(() -> {
54+
final Module module = LangDataKeys.MODULE.getData(event.getDataContext());
55+
final Project project = Objects.requireNonNull(event.getProject());
56+
if (Objects.nonNull(module)) {
57+
AzureLoginHelper.requireSignedIn(module.getProject(), () -> deploy(module));
58+
} else {
59+
AzureLoginHelper.requireSignedIn(project, () -> deploy(project));
60+
}
61+
});
6062
}
6163

6264
@Override

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice-java/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentState.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.microsoft.azure.toolkit.ide.appservice.AppServiceActionsContributor;
1313
import com.microsoft.azure.toolkit.intellij.common.RunProcessHandler;
1414
import com.microsoft.azure.toolkit.intellij.common.RunProcessHandlerMessenger;
15+
import com.microsoft.azure.toolkit.intellij.connector.dotazure.AzureModule;
1516
import com.microsoft.azure.toolkit.intellij.connector.dotazure.DotEnvBeforeRunTaskProvider;
1617
import com.microsoft.azure.toolkit.intellij.legacy.common.AzureRunProfileState;
1718
import com.microsoft.azure.toolkit.intellij.legacy.function.runner.core.FunctionUtils;
@@ -78,6 +79,11 @@ public FunctionDeploymentState(Project project, FunctionDeployConfiguration func
7879
OperationContext.current().setMessager(new RunProcessHandlerMessenger(processHandler));
7980
applyResourceConnection();
8081
final FunctionAppBase<?, ?, ?> target = FunctionAppService.getInstance().createOrUpdateFunctionApp(deployModel.getFunctionAppConfig());
82+
final AzureTaskManager tm = AzureTaskManager.getInstance();
83+
tm.runOnPooledThread(()-> Optional.ofNullable(this.functionDeployConfiguration.getModule()).map(AzureModule::from)
84+
.ifPresent(module -> tm.runLater(() -> tm.write(() -> module
85+
.initializeWithDefaultProfileIfNot()
86+
.addApp(target).save()))));
8187
stagingFolder = FunctionUtils.getTempStagingFolder();
8288
prepareStagingFolder(stagingFolder, operation);
8389
// deploy function to Azure

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice-java/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/webapp/action/DeployWebAppAction.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ public class DeployWebAppAction extends AnAction {
4242
@Override
4343
@AzureOperation(name = "user/webapp.deploy_app")
4444
public void actionPerformed(@Nonnull AnActionEvent event) {
45-
OperationContext.current().setTelemetryProperty(PLACE, StringUtils.firstNonBlank(event.getPlace(), EMPTY_PLACE));
46-
final Module module = LangDataKeys.MODULE.getData(event.getDataContext());
47-
final Project project = Objects.requireNonNull(event.getProject());
48-
if (Objects.nonNull(module)) {
49-
AzureLoginHelper.requireSignedIn(module.getProject(), () -> deploy(module));
50-
} else {
51-
AzureLoginHelper.requireSignedIn(project, () -> deploy(project));
52-
}
45+
AzureTaskManager.getInstance().runLater(() -> {
46+
OperationContext.current().setTelemetryProperty(PLACE, StringUtils.firstNonBlank(event.getPlace(), EMPTY_PLACE));
47+
final Module module = LangDataKeys.MODULE.getData(event.getDataContext());
48+
final Project project = Objects.requireNonNull(event.getProject());
49+
if (Objects.nonNull(module)) {
50+
AzureLoginHelper.requireSignedIn(module.getProject(), () -> deploy(module));
51+
} else {
52+
AzureLoginHelper.requireSignedIn(project, () -> deploy(project));
53+
}
54+
});
5355
}
5456

5557
public static void deploy(@Nonnull final WebApp webApp, @Nonnull final Project project) {

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

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

88
import com.intellij.execution.process.ProcessOutputTypes;
99
import com.intellij.openapi.project.Project;
10+
import com.intellij.openapi.vfs.VfsUtil;
1011
import com.intellij.util.PathUtil;
1112
import com.microsoft.azure.toolkit.intellij.common.AzureArtifact;
1213
import com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager;
1314
import com.microsoft.azure.toolkit.intellij.common.RunProcessHandler;
1415
import com.microsoft.azure.toolkit.intellij.connector.IJavaAgentSupported;
16+
import com.microsoft.azure.toolkit.intellij.connector.dotazure.AzureModule;
1517
import com.microsoft.azure.toolkit.intellij.connector.dotazure.DotEnvBeforeRunTaskProvider;
1618
import com.microsoft.azure.toolkit.intellij.legacy.common.AzureRunProfileState;
1719
import com.microsoft.azure.toolkit.intellij.legacy.webapp.runner.Constants;
@@ -20,12 +22,19 @@
2022
import com.microsoft.azure.toolkit.lib.appservice.model.AppServiceFile;
2123
import com.microsoft.azure.toolkit.lib.appservice.model.DeployType;
2224
import com.microsoft.azure.toolkit.lib.appservice.model.WebContainer;
23-
import com.microsoft.azure.toolkit.lib.appservice.webapp.*;
25+
import com.microsoft.azure.toolkit.lib.appservice.webapp.AzureWebApp;
26+
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebApp;
27+
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebAppBase;
28+
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebAppDeploymentSlot;
29+
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebAppDeploymentSlotDraft;
30+
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebAppDraft;
31+
import com.microsoft.azure.toolkit.lib.appservice.webapp.WebAppModule;
2432
import com.microsoft.azure.toolkit.lib.common.bundle.AzureString;
2533
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
2634
import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager;
2735
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
2836
import com.microsoft.azure.toolkit.lib.common.operation.OperationContext;
37+
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
2938
import com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel;
3039
import com.microsoft.azuretools.telemetry.TelemetryConstants;
3140
import com.microsoft.azuretools.telemetrywrapper.Operation;
@@ -47,7 +56,12 @@
4756
import java.net.URISyntaxException;
4857
import java.net.URL;
4958
import java.nio.file.Paths;
50-
import java.util.*;
59+
import java.util.Collections;
60+
import java.util.HashMap;
61+
import java.util.Map;
62+
import java.util.Objects;
63+
import java.util.Optional;
64+
import java.util.Set;
5165
import java.util.stream.Collectors;
5266

5367
import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message;
@@ -82,6 +96,14 @@ public WebAppRunState(Project project, WebAppConfiguration webAppConfiguration)
8296
throw new FileNotFoundException(message("webapp.deploy.error.noTargetFile", artifact.getAbsolutePath()));
8397
}
8498
final WebAppBase<?, ?, ?> deployTarget = getOrCreateDeployTargetFromAppSettingModel(processHandler);
99+
final AzureTaskManager tm = AzureTaskManager.getInstance();
100+
tm.runOnPooledThread(()-> Optional.ofNullable(this.webAppConfiguration.getModule()).map(AzureModule::from)
101+
.or(() -> Optional.ofNullable(artifact)
102+
.map(f -> VfsUtil.findFileByIoFile(f, true))
103+
.map(f -> AzureModule.from(f, this.project)))
104+
.ifPresent(module -> tm.runLater(() -> tm.write(() -> module
105+
.initializeWithDefaultProfileIfNot()
106+
.addApp(deployTarget).save()))));
85107
applyResourceConnections(deployTarget);
86108
updateApplicationSettings(deployTarget, processHandler);
87109
AzureWebAppMvpModel.getInstance().deployArtifactsToWebApp(deployTarget, artifact, webAppSettingModel.isDeployToRoot(), processHandler);

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice-java/src/main/resources/META-INF/azure-intellij-plugin-appservice-java.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@
3232
<actions>
3333
<!-- WebApp Start -->
3434
<action id="Actions.WebDeployAction" class="com.microsoft.azure.toolkit.intellij.legacy.webapp.action.DeployWebAppAction"
35-
text="Deploy to Azure Web Apps" description="Deploy to Azure Web Apps"
35+
text="Deploy to Azure Web Apps..." description="Deploy selected module to Azure WebApp"
3636
icon="/icons/WebApp/Deploy.svg">
3737
</action>
3838
<action id="Actions.WebAppOnLinux" class="com.microsoft.azure.toolkit.intellij.legacy.webapp.action.WebAppOnLinuxAction"
39-
text="Run on Web App for Containers" description="Run on Web App for Containers"
39+
text="Run on Web App for Containers..." description="Run on Web App for Containers"
4040
icon="/icons/DockerSupport/RunOnWebApp.svg">
4141
</action>
4242
<!-- WebApp End -->
4343
<!-- Functions Start -->
4444
<action id="Actions.RunFunction" class="com.microsoft.azure.toolkit.intellij.legacy.function.action.RunFunctionAction"
45-
text="Run Function" description="Run function project locally"
45+
text="Run Function..." description="Run function project locally"
4646
icon="/icons/FunctionApp/Run.svg">
4747
</action>
4848
<action id="Actions.DeployFunction" class="com.microsoft.azure.toolkit.intellij.legacy.function.action.DeployFunctionAppAction"
49-
text="Deploy to Azure Functions" description="Deploy Java Function to Azure"
49+
text="Deploy to Azure Functions..." description="Deploy selected module to Azure Functions"
5050
icon="/icons/FunctionApp/Deploy.svg">
5151
</action>
5252
<action id="page.new" class="com.microsoft.azure.toolkit.intellij.legacy.function.action.CreateFunctionAction"
5353
text="Azure Function Class"
54-
description="Create New Azure Function Class">
54+
description="Create new Azure Function class">
5555
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFile"/>
5656
</action>
5757
<!-- Functions End -->

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceComboBox.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ public AppServiceComboBox(final Project project) {
4848
}
4949

5050
@Override
51-
public void setValue(T val) {
52-
if (isDraftResource(val)) {
53-
this.draftItems.remove(val);
51+
public void setValue(T val, Boolean fixed) {
52+
if (isDraftResource(val) && !this.draftItems.contains(val)) {
5453
this.draftItems.add(0, val);
5554
this.reloadItems();
5655
}
57-
super.setValue(val);
56+
super.setValue(val, fixed);
5857
}
5958

6059
@Nonnull

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/appservice/insights/ApplicationInsightsComboBox.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ public void setSubscription(Subscription subscription) {
5151
}
5252

5353
@Override
54-
public void setValue(final ApplicationInsightsConfig val) {
55-
if (val != null && val.isNewCreate()) {
56-
this.draftItems.remove(val);
54+
public void setValue(final ApplicationInsightsConfig val, Boolean fixed) {
55+
if (val != null && val.isNewCreate() && !this.draftItems.contains(val)) {
5756
this.draftItems.add(0, val);
5857
this.reloadItems();
5958
}
60-
super.setValue(val);
59+
super.setValue(val, fixed);
6160
}
6261

6362
@Nonnull

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/appservice/serviceplan/ServicePlanComboBox.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,12 @@ public void setRegion(Region region) {
9696
}
9797

9898
@Override
99-
public void setValue(@Nullable AppServicePlan val) {
100-
if (Objects.nonNull(val) && val.isDraftForCreating()) {
101-
this.draftItems.remove(val);
99+
public void setValue(@Nullable AppServicePlan val, Boolean fixed) {
100+
if (Objects.nonNull(val) && val.isDraftForCreating() && !this.draftItems.contains(val)) {
102101
this.draftItems.add(0, val);
103102
this.reloadItems();
104103
}
105-
super.setValue(val);
104+
super.setValue(val, fixed);
106105
}
107106

108107
@Nullable

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/ui/components/DeploymentSlotComboBox.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ public void setAppService(final String appServiceId) {
4747
}
4848

4949
@Override
50-
public void setValue(DeploymentSlotConfig val) {
51-
if (isDraftResource(val)) {
52-
this.draftItems.remove(val);
50+
public void setValue(DeploymentSlotConfig val, Boolean fixed) {
51+
if (isDraftResource(val) && !this.draftItems.contains(val)) {
5352
this.draftItems.add(0, val);
5453
this.reloadItems();
5554
}
56-
super.setValue(val);
55+
super.setValue(val, fixed);
5756
}
5857

5958
@Nonnull
@@ -84,10 +83,9 @@ private void createResource() {
8483
@Override
8584
protected List<? extends DeploymentSlotConfig> loadItems() throws Exception {
8685
final AbstractAzResource<?, ?, ?> resource = StringUtils.isEmpty(appServiceId) ? null : Azure.az().getById(appServiceId);
87-
final IDeploymentSlotModule<?, ?, ?> module = Optional.ofNullable(resource)
88-
.map(r -> r.getSubModules().stream().filter(m -> m instanceof IDeploymentSlotModule).findFirst().orElse(null))
89-
.map(m -> (IDeploymentSlotModule<?, ?, ?>) m)
90-
.orElse(null);
86+
final IDeploymentSlotModule<?, ?, ?> module = (IDeploymentSlotModule<?, ?, ?>) Optional.ofNullable(resource)
87+
.flatMap(r -> r.getSubModules().stream().filter(m -> m instanceof IDeploymentSlotModule).findFirst())
88+
.orElse(null);
9189
if (module == null) {
9290
return Collections.emptyList();
9391
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-containerapps/src/main/java/com/microsoft/azure/toolkit/intellij/containerapps/component/ACRRegistryComboBox.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ public void setSubscription(Subscription subscription) {
6161
}
6262

6363
@Override
64-
public void setValue(@Nullable ContainerRegistry val) {
65-
if (Objects.nonNull(val) && val.isDraftForCreating() && !val.exists()) {
66-
this.draftItems.remove(val);
64+
public void setValue(@Nullable ContainerRegistry val, Boolean fixed) {
65+
if (Objects.nonNull(val) && val.isDraftForCreating() && !this.draftItems.contains(val)) {
6766
this.draftItems.add(0, val);
6867
this.reloadItems();
6968
}
70-
super.setValue(val);
69+
super.setValue(val, fixed);
7170
}
7271

7372
@Nullable

0 commit comments

Comments
 (0)