Skip to content

Commit c0186be

Browse files
committed
Merge branch 'develop' into qianjin-sqlserver
2 parents 56dce6f + 865d14f commit c0186be

File tree

24 files changed

+723
-350
lines changed

24 files changed

+723
-350
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*/
5+
6+
package com.microsoft.azure.toolkit.intellij.common;
7+
8+
import com.intellij.openapi.util.SystemInfo;
9+
import com.intellij.ui.components.JBLabel;
10+
import com.intellij.ui.scale.JBUIScale;
11+
import com.intellij.util.ui.UIUtil;
12+
import org.jetbrains.annotations.NotNull;
13+
14+
import javax.swing.plaf.FontUIResource;
15+
import javax.swing.plaf.LabelUI;
16+
import java.awt.*;
17+
18+
public class AzureCommentLabel extends JBLabel {
19+
public AzureCommentLabel(@NotNull String text) {
20+
super(text);
21+
setForeground(UIUtil.getContextHelpForeground());
22+
}
23+
24+
@Override
25+
public void setUI(LabelUI ui) {
26+
super.setUI(ui);
27+
28+
if (SystemInfo.isMac) {
29+
Font font = getFont();
30+
float size = font.getSize2D();
31+
font = new FontUIResource(font.deriveFont(size - JBUIScale.scale(2))); // Allow to reset the font by UI
32+
setFont(font);
33+
}
34+
}
35+
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/AppServiceStreamingLogConsoleView.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import com.intellij.execution.ui.ConsoleViewContentType;
99
import com.intellij.openapi.project.Project;
1010
import org.jetbrains.annotations.NotNull;
11-
import rx.Observable;
12-
import rx.Subscription;
13-
import rx.schedulers.Schedulers;
11+
import reactor.core.Disposable;
12+
import reactor.core.publisher.Flux;
13+
import reactor.core.scheduler.Schedulers;
1414

1515
import static com.intellij.execution.ui.ConsoleViewContentType.NORMAL_OUTPUT;
1616
import static com.intellij.execution.ui.ConsoleViewContentType.SYSTEM_OUTPUT;
@@ -22,32 +22,32 @@ public class AppServiceStreamingLogConsoleView extends ConsoleViewImpl {
2222

2323
private boolean isDisposed;
2424
private String resourceId;
25-
private Subscription subscription;
25+
private Disposable subscription;
2626

2727
public AppServiceStreamingLogConsoleView(@NotNull Project project, String resourceId) {
2828
super(project, true);
2929
this.isDisposed = false;
3030
this.resourceId = resourceId;
3131
}
3232

33-
public void startStreamingLog(Observable<String> logStreaming) {
33+
public void startStreamingLog(Flux<String> logStreaming) {
3434
if (!isActive()) {
3535
printlnToConsole(message("appService.logStreaming.hint.connect"), SYSTEM_OUTPUT);
36-
subscription = logStreaming.subscribeOn(Schedulers.io())
36+
subscription = logStreaming.subscribeOn(Schedulers.boundedElastic())
3737
.doAfterTerminate(() -> printlnToConsole(message("appService.logStreaming.hint.disconnected"), SYSTEM_OUTPUT))
3838
.subscribe((log) -> printlnToConsole(log, NORMAL_OUTPUT));
3939
}
4040
}
4141

4242
public void closeStreamingLog() {
4343
if (isActive()) {
44-
subscription.unsubscribe();
44+
subscription.dispose();
4545
printlnToConsole(message("appService.logStreaming.hint.disconnected"), SYSTEM_OUTPUT);
4646
}
4747
}
4848

4949
public boolean isActive() {
50-
return subscription != null && !subscription.isUnsubscribed();
50+
return subscription != null && !subscription.isDisposed();
5151
}
5252

5353
public boolean isDisposed() {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/AppServiceStreamingLogManager.java

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
*/
55
package com.microsoft.azure.toolkit.intellij.appservice;
66

7+
import com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils;
78
import com.google.gson.JsonObject;
89
import com.intellij.openapi.project.Project;
910
import com.microsoft.azure.management.applicationinsights.v2015_05_01.ApplicationInsightsComponent;
10-
import com.microsoft.azure.management.appservice.AppSetting;
11-
import com.microsoft.azure.management.appservice.FunctionApp;
12-
import com.microsoft.azure.management.appservice.OperatingSystem;
13-
import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils;
1411
import com.microsoft.azure.toolkit.lib.Azure;
1512
import com.microsoft.azure.toolkit.lib.appservice.AzureAppService;
1613
import com.microsoft.azure.toolkit.lib.appservice.model.DiagnosticConfig;
14+
import com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem;
15+
import com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp;
1716
import com.microsoft.azure.toolkit.lib.appservice.service.IWebApp;
1817
import com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot;
1918
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
@@ -23,15 +22,12 @@
2322
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
2423
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
2524
import com.microsoft.azuretools.core.mvp.model.AzureMvpModel;
26-
import com.microsoft.azuretools.core.mvp.model.function.AzureFunctionMvpModel;
2725
import com.microsoft.azuretools.sdkmanage.IdentityAzureManager;
2826
import com.microsoft.intellij.util.PluginUtil;
2927
import com.microsoft.tooling.msservices.components.DefaultLoader;
3028
import com.microsoft.tooling.msservices.helpers.azure.sdk.AzureSDKManager;
31-
import hu.akarnokd.rxjava3.interop.RxJavaInterop;
3229
import org.apache.commons.lang3.StringUtils;
33-
import reactor.adapter.rxjava.RxJava3Adapter;
34-
import rx.Observable;
30+
import reactor.core.publisher.Flux;
3531

3632
import java.io.IOException;
3733
import java.net.URLEncoder;
@@ -107,7 +103,7 @@ private void showAppServiceStreamingLog(Project project, String resourceId, ILog
107103
return;
108104
}
109105
}
110-
final Observable<String> log = logStreaming.getStreamingLogContent();
106+
final Flux<String> log = logStreaming.getStreamingLogContent();
111107
if (log == null) {
112108
return;
113109
}
@@ -137,7 +133,7 @@ default boolean isLogStreamingSupported() {
137133

138134
String getTitle() throws IOException;
139135

140-
Observable<String> getStreamingLogContent() throws IOException;
136+
Flux<String> getStreamingLogContent() throws IOException;
141137
}
142138

143139
static class FunctionLogStreaming implements ILogStreaming {
@@ -147,20 +143,23 @@ static class FunctionLogStreaming implements ILogStreaming {
147143
private static final String MUST_CONFIGURE_APPLICATION_INSIGHTS = message("appService.logStreaming.error.noApplicationInsights");
148144

149145
private final String resourceId;
150-
private FunctionApp functionApp;
146+
private IFunctionApp functionApp;
151147

152148
FunctionLogStreaming(final String resourceId) {
153149
this.resourceId = resourceId;
154150
}
155151

156152
@Override
157153
public boolean isLogStreamingEnabled() {
158-
return getFunctionApp().operatingSystem() == OperatingSystem.LINUX || AzureFunctionMvpModel.isApplicationLogEnabled(getFunctionApp());
154+
return getFunctionApp().getRuntime().getOperatingSystem() == OperatingSystem.LINUX ||
155+
getFunctionApp().getDiagnosticConfig().isEnableApplicationLog();
159156
}
160157

161158
@Override
162159
public void enableLogStreaming() {
163-
AzureFunctionMvpModel.enableApplicationLog(getFunctionApp());
160+
final DiagnosticConfig diagnosticConfig = getFunctionApp().getDiagnosticConfig();
161+
diagnosticConfig.setEnableApplicationLog(true);
162+
getFunctionApp().update().withDiagnosticConfig(diagnosticConfig).commit();
164163
}
165164

166165
@Override
@@ -169,8 +168,8 @@ public String getTitle() {
169168
}
170169

171170
@Override
172-
public Observable<String> getStreamingLogContent() throws IOException {
173-
if (getFunctionApp().operatingSystem() == OperatingSystem.LINUX) {
171+
public Flux<String> getStreamingLogContent() throws IOException {
172+
if (getFunctionApp().getRuntime().getOperatingSystem() == OperatingSystem.LINUX) {
174173
// For linux function, we will just open the "Live Metrics Stream" view in the portal
175174
openLiveMetricsStream();
176175
return null;
@@ -181,11 +180,10 @@ public Observable<String> getStreamingLogContent() throws IOException {
181180
// Refers https://github.com/microsoft/vscode-azurefunctions/blob/v0.22.0/src/
182181
// commands/logstream/startStreamingLogs.ts#L53
183182
private void openLiveMetricsStream() throws IOException {
184-
final AppSetting aiAppSettings = functionApp.getAppSettings().get(APPINSIGHTS_INSTRUMENTATIONKEY);
185-
if (aiAppSettings == null) {
183+
final String aiKey = functionApp.entity().getAppSettings().get(APPINSIGHTS_INSTRUMENTATIONKEY);
184+
if (StringUtils.isEmpty(aiKey)) {
186185
throw new IOException(MUST_CONFIGURE_APPLICATION_INSIGHTS);
187186
}
188-
final String aiKey = aiAppSettings.value();
189187
final String subscriptionId = AzureMvpModel.getSegment(resourceId, SUBSCRIPTIONS);
190188
final List<ApplicationInsightsComponent> insightsResources =
191189
subscriptionId == null ? Collections.EMPTY_LIST : AzureSDKManager.getInsightsResources(subscriptionId);
@@ -208,9 +206,9 @@ private String getApplicationInsightLiveMetricsUrl(ApplicationInsightsComponent
208206
return String.format(APPLICATION_INSIGHT_PATTERN, portalUrl, componentId, aiResourceId);
209207
}
210208

211-
private FunctionApp getFunctionApp() {
209+
private IFunctionApp getFunctionApp() {
212210
if (functionApp == null) {
213-
functionApp = AzureFunctionMvpModel.getInstance().getFunctionById(AzureMvpModel.getSegment(resourceId, SUBSCRIPTIONS), resourceId);
211+
functionApp = Azure.az(AzureAppService.class).functionApp(resourceId);
214212
}
215213
return functionApp;
216214
}
@@ -240,8 +238,8 @@ public String getTitle() {
240238
}
241239

242240
@Override
243-
public Observable<String> getStreamingLogContent() {
244-
return RxJavaInterop.toV1Observable(RxJava3Adapter.fluxToFlowable(webApp.streamAllLogsAsync()));
241+
public Flux<String> getStreamingLogContent() {
242+
return webApp.streamAllLogsAsync();
245243
}
246244
}
247245

@@ -269,8 +267,8 @@ public String getTitle() {
269267
}
270268

271269
@Override
272-
public Observable<String> getStreamingLogContent() {
273-
return RxJavaInterop.toV1Observable(RxJava3Adapter.fluxToFlowable(deploymentSlot.streamAllLogsAsync()));
270+
public Flux<String> getStreamingLogContent() {
271+
return deploymentSlot.streamAllLogsAsync();
274272
}
275273
}
276274

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/properties/AzureSlider.form

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
1414
</constraints>
1515
<properties>
16-
<majorTickSpacing value="50"/>
17-
<maximum value="500"/>
16+
<majorTickSpacing value="5"/>
17+
<maximum value="25"/>
1818
<minimum value="0"/>
19-
<minorTickSpacing value="10"/>
19+
<minorTickSpacing value="1"/>
2020
<paintLabels value="true"/>
2121
<paintTicks value="true"/>
2222
<paintTrack value="true"/>
2323
<snapToTicks value="false"/>
24-
<value value="50"/>
24+
<value value="1"/>
2525
<valueIsAdjusting value="true"/>
2626
</properties>
2727
</component>

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/properties/AzureSlider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public int getValue() {
6262
return (int) this.numValue.getValue();
6363
}
6464

65+
public void prepare() {
66+
this.numSlider.setLabelTable(null);
67+
}
68+
6569
private void createUIComponents() {
6670
this.numValue = new JBIntSpinner(1, 0, 10);
6771
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/properties/SpringCloudAppPanel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ private void updateForm() {
182182
numCpuModel.addAll(IntStream.range(1, 1 + (basic ? 1 : 4)).boxed().collect(Collectors.toList()));
183183
numMemoryModel.removeAllElements();
184184
numMemoryModel.addAll(IntStream.range(1, 1 + (basic ? 2 : 8)).boxed().collect(Collectors.toList()));
185+
this.numInstance.prepare();
185186
this.numInstance.setMaximum(basic ? 25 : 500);
186187
this.numInstance.setMajorTickSpacing(basic ? 5 : 50);
187188
this.numInstance.setMinorTickSpacing(basic ? 1 : 10);

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/properties/SpringCloudAppPropertiesEditor.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.openapi.project.Project;
99
import com.intellij.ui.components.ActionLink;
1010
import com.microsoft.azure.toolkit.intellij.common.BaseEditor;
11+
import com.microsoft.azure.toolkit.lib.common.event.AzureEventBus;
1112
import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager;
1213
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1314
import com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp;
@@ -112,15 +113,24 @@ private void initListeners() {
112113
new DeploySpringCloudAppTask(this.appPanel.getData()).execute();
113114
this.refresh();
114115
}));
115-
// TODO: add listener: update view on app updated and close editor on app deleted.
116+
AzureEventBus.after("springcloud|app.remove", (SpringCloudApp app) -> {
117+
if (this.app.name().equals(app.name())) {
118+
this.closeEditor();
119+
}
120+
});
121+
AzureEventBus.after("springcloud|app.update", (SpringCloudApp app) -> {
122+
if (this.app.name().equals(app.name())) {
123+
this.refresh();
124+
}
125+
});
116126
}
117127

118128
private void refresh() {
119129
this.reset.setVisible(false);
120130
this.saveButton.setEnabled(false);
121131
AzureTaskManager.getInstance().runLater(() -> {
122132
final String refreshTitle = String.format("Refreshing app(%s)...", Objects.requireNonNull(this.app).name());
123-
AzureTaskManager.getInstance().runInModal(refreshTitle, () -> {
133+
AzureTaskManager.getInstance().runInBackground(refreshTitle, () -> {
124134
this.appPanel.refresh();
125135
this.resetToolbar();
126136
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.execution.process.ProcessOutputTypes;
99
import com.intellij.openapi.project.Project;
1010
import com.intellij.openapi.util.Comparing;
11+
import com.microsoft.azure.toolkit.lib.appservice.service.IWebAppBase;
1112
import com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException;
1213
import com.microsoft.azure.toolkit.intellij.common.AzureArtifact;
1314
import com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager;
@@ -69,7 +70,7 @@ public IAppService executeSteps(@NotNull RunProcessHandler processHandler, @NotN
6970
throw new FileNotFoundException(message("webapp.deploy.error.noTargetFile", file.getAbsolutePath()));
7071
}
7172
webAppConfiguration.setTargetName(file.getName());
72-
final IAppService deployTarget = getOrCreateDeployTargetFromAppSettingModel(processHandler);
73+
final IWebAppBase deployTarget = getOrCreateDeployTargetFromAppSettingModel(processHandler);
7374
updateApplicationSettings(deployTarget, processHandler);
7475
AzureWebAppMvpModel.getInstance().deployArtifactsToWebApp(deployTarget, file, webAppSettingModel.isDeployToRoot(), processHandler);
7576
return deployTarget;
@@ -138,7 +139,7 @@ protected Map<String, String> getTelemetryMap() {
138139
}
139140

140141
@NotNull
141-
private IAppService getOrCreateDeployTargetFromAppSettingModel(@NotNull RunProcessHandler processHandler) throws Exception {
142+
private IWebAppBase getOrCreateDeployTargetFromAppSettingModel(@NotNull RunProcessHandler processHandler) throws Exception {
142143
final AzureAppService azureAppService = AzureWebAppMvpModel.getInstance().getAzureAppServiceClient(webAppSettingModel.getSubscriptionId());
143144
final IWebApp webApp = getOrCreateWebappFromAppSettingModel(azureAppService, processHandler);
144145
if (!isDeployToSlot()) {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/actions/AzureSignInAction.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import com.intellij.openapi.project.Project;
1212
import com.intellij.openapi.ui.DialogWrapper;
1313
import com.intellij.openapi.wm.WindowManager;
14+
import com.microsoft.azure.toolkit.lib.Azure;
15+
import com.microsoft.azure.toolkit.lib.auth.AzureAccount;
1416
import com.microsoft.azure.toolkit.lib.auth.exception.AzureToolkitAuthenticationException;
1517
import com.microsoft.azure.toolkit.lib.auth.model.AuthType;
1618
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
@@ -91,7 +93,7 @@ private static String getSignOutWarningMessage(@NotNull AuthMethodManager authMe
9193
final String warningMessage;
9294
switch (authType) {
9395
case SERVICE_PRINCIPAL:
94-
warningMessage = String.format("Signed in using file \"%s\"", authMethodDetails.getCredFilePath());
96+
warningMessage = String.format("Signed in using service principal \"%s\"", authMethodDetails.getClientId());
9597
break;
9698
case OAUTH2:
9799
case DEVICE_CODE:
@@ -123,7 +125,16 @@ public static void onAzureSignIn(Project project) {
123125
});
124126
}
125127
} else {
126-
doSignIn(authMethodManager, project).subscribe();
128+
doSignIn(authMethodManager, project).subscribe(r -> {
129+
if (r) {
130+
AzureAccount az = Azure.az(AzureAccount.class);
131+
authMethodManager.getAzureManager().getSelectedSubscriptions().stream().limit(5).forEach(s -> {
132+
// pre-load regions;
133+
az.listRegions(s.getId());
134+
});
135+
}
136+
137+
});
127138
}
128139
}
129140

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/helpers/MvpUIHelperImpl.java

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

66
package com.microsoft.intellij.helpers;
77

8+
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
89
import com.microsoft.azuretools.core.mvp.ui.base.MvpUIHelper;
10+
import com.microsoft.intellij.secure.IdeaSecureStore;
911
import com.microsoft.tooling.msservices.components.DefaultLoader;
1012

1113
import javax.swing.*;
@@ -21,4 +23,10 @@ public void showError(String msg) {
2123
public void showException(String msg, Exception e) {
2224
DefaultLoader.getUIHelper().showError(e.getMessage(), msg);
2325
}
26+
27+
@Deprecated
28+
@Override
29+
public String loadPasswordFromSecureStore(@NotNull String key) {
30+
return IdeaSecureStore.getInstance().loadPassword(key);
31+
}
2432
}

0 commit comments

Comments
 (0)