Skip to content

Commit 1f77944

Browse files
committed
Show mysql connction line marker only if user is signed in and check authentication status in line marker navigation
1 parent 6f5ac6d commit 1f77944

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/SpringDatasourceLineMarkerProvider.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.microsoft.azure.toolkit.intellij.link.mysql.JdbcUrl;
2020
import com.microsoft.azure.toolkit.intellij.link.po.LinkPO;
2121
import com.microsoft.azure.toolkit.intellij.link.po.MySQLResourcePO;
22+
import com.microsoft.azuretools.authmanage.AuthMethodManager;
2223
import com.microsoft.azuretools.core.mvp.model.mysql.MySQLMvpModel;
2324
import com.microsoft.intellij.AzureLinkStorage;
2425
import com.microsoft.intellij.AzureMySQLStorage;
@@ -36,6 +37,10 @@ public class SpringDatasourceLineMarkerProvider implements LineMarkerProvider {
3637

3738
@Override
3839
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
40+
// Do not show azure line marker if not signed in
41+
if (!AuthMethodManager.getInstance().isSignedIn()) {
42+
return null;
43+
}
3944
if (element instanceof PropertyImpl) {
4045
PropertyImpl property = (PropertyImpl) element;
4146
String value = property.getValue();
@@ -85,6 +90,12 @@ public class SpringDatasourceNavigationHandler implements GutterIconNavigationHa
8590

8691
@Override
8792
public void navigate(MouseEvent mouseEvent, PsiElement psiElement) {
93+
if (!AuthMethodManager.getInstance().isSignedIn()) {
94+
final String resourceName = ResourceId.fromString(resourceId).name();
95+
final String message = String.format("Failed to connect Azure Database for MySQL (%s) , please sign in Azure first.", resourceName);
96+
DefaultLoader.getUIHelper().showError(message, "Connect to Azure Datasource for MySQL");
97+
return;
98+
}
8899
ResourceId resourceIdObject = ResourceId.fromString(resourceId);
89100
Server server = MySQLMvpModel.findServer(resourceIdObject.subscriptionId(), resourceIdObject.resourceGroupName(), resourceIdObject.name());
90101
if (Objects.nonNull(server)) {

0 commit comments

Comments
 (0)