Skip to content

Commit c64f9b9

Browse files
allow toggling Azure node visibility via context menu
1 parent ebee0da commit c64f9b9

File tree

6 files changed

+74
-3
lines changed

6 files changed

+74
-3
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/IntelliJAzureIcons.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class IntelliJAzureIcons {
5757
put(AzureIcons.Common.RESTART, AllIcons.Actions.Restart);
5858
put(AzureIcons.Common.SHOW_PROPERTIES, AllIcons.Actions.Properties);
5959
put(AzureIcons.Common.UNKNOWN_ICON, AllIcons.Nodes.Unknown);
60+
put(AzureIcons.Common.HIDE, AllIcons.General.InspectionsEye);
6061
put(AzureIcons.Action.CONSOLE, AllIcons.Nodes.Console);
6162
put(AzureIcons.Action.SFTP, AllIcons.Nodes.Servlet);
6263
put(AzureIcons.Action.UPLOAD, AllIcons.Actions.Upload);

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package com.microsoft.azure.toolkit.intellij.connector;
77

88
import com.google.common.util.concurrent.Futures;
9+
import com.intellij.ide.projectView.ProjectView;
10+
import com.intellij.ide.util.PropertiesComponent;
911
import com.intellij.openapi.actionSystem.AnActionEvent;
1012
import com.intellij.openapi.module.Module;
1113
import com.intellij.openapi.module.ModuleManager;
@@ -42,12 +44,13 @@ public class ResourceConnectionActionsContributor implements IActionsContributor
4244
public static final Action.Id<AzureModule> CONNECT_TO_MODULE = Action.Id.of("user/connector.connect_to_module");
4345
public static final Action.Id<AzureModule> REFRESH_MODULE = Action.Id.of("user/connector.refresh_module");
4446
public static final Action.Id<AzureModule> REFRESH_MODULE_CONNECTIONS = Action.Id.of("user/connector.refresh_module_connections");
47+
public static final Action.Id<AzureModule> HIDE_AZURE = Action.Id.of("user/connector.hide_azure_root");
4548

4649
public static final Action.Id<Pair<String, String>> COPY_ENV_PAIR = Action.Id.of("user/connector.copy_env_pair");
4750
public static final Action.Id<Pair<String, String>> COPY_ENV_KEY = Action.Id.of("user/connector.copy_env_key");
4851
public static final Action.Id<Connection<?, ?>> COPY_ENV_VARS = Action.Id.of("user/connector.copy_env_variables");
4952
public static final Action.Id<Pair<String, String>> EDIT_ENV_IN_EDITOR = Action.Id.of("user/connector.edit_env_in_editor");
50-
public static final Action.Id<Connection<?,?>> EDIT_ENV_FILE_IN_EDITOR = Action.Id.of("user/connector.edit_env_file_in_editor");
53+
public static final Action.Id<Connection<?, ?>> EDIT_ENV_FILE_IN_EDITOR = Action.Id.of("user/connector.edit_env_file_in_editor");
5154

5255
public static final String MODULE_ACTIONS = "actions.connector.module";
5356
public static final String CONNECTION_ACTIONS = "actions.connector.connection";
@@ -72,6 +75,17 @@ public void registerActions(AzureActionManager am) {
7275
.withAuthRequired(false)
7376
.register(am);
7477

78+
new Action<>(HIDE_AZURE)
79+
.withLabel("Hide 'Azure' Node")
80+
.withIcon(AzureIcons.Common.HIDE.getIconPath())
81+
.withHandler((module, e) -> {
82+
final PropertiesComponent properties = PropertiesComponent.getInstance(module.getProject());
83+
properties.setValue(module.getModule().getName() + ".azure", "hide");
84+
ProjectView.getInstance(module.getProject()).getCurrentProjectViewPane().updateFromRoot(true);
85+
})
86+
.withAuthRequired(false)
87+
.register(am);
88+
7589
new Action<>(CONNECT_TO_MODULE)
7690
.withLabel("Connect to Azure Resource")
7791
.withIcon(AzureIcons.Connector.CONNECT.getIconPath())
@@ -209,6 +223,7 @@ public void registerGroups(AzureActionManager am) {
209223
"---",
210224
CONNECT_TO_MODULE,
211225
"---",
226+
HIDE_AZURE,
212227
"RevealGroup"
213228
);
214229
am.registerGroup(EXPLORER_MODULE_ROOT_ACTIONS, explorerModuleRootActions);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.facet;
7+
8+
import com.intellij.ide.projectView.ProjectView;
9+
import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode;
10+
import com.intellij.ide.util.PropertiesComponent;
11+
import com.intellij.openapi.actionSystem.AnAction;
12+
import com.intellij.openapi.actionSystem.AnActionEvent;
13+
import com.intellij.openapi.actionSystem.LangDataKeys;
14+
import com.intellij.openapi.actionSystem.PlatformDataKeys;
15+
import com.intellij.openapi.module.Module;
16+
import com.intellij.openapi.project.Project;
17+
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
18+
import com.microsoft.azure.toolkit.lib.common.operation.OperationContext;
19+
import org.apache.commons.lang3.StringUtils;
20+
import org.jetbrains.annotations.NotNull;
21+
22+
import javax.annotation.Nonnull;
23+
import java.util.Objects;
24+
25+
import static com.microsoft.azure.toolkit.lib.common.action.Action.EMPTY_PLACE;
26+
import static com.microsoft.azure.toolkit.lib.common.action.Action.PLACE;
27+
28+
public class ToggleAzureFacetNodeAction extends AnAction {
29+
@Override
30+
@AzureOperation(name = "user/connector.show_azure_node")
31+
public void actionPerformed(@Nonnull AnActionEvent event) {
32+
OperationContext.current().setTelemetryProperty(PLACE, StringUtils.firstNonBlank(event.getPlace(), EMPTY_PLACE));
33+
final Module module = LangDataKeys.MODULE.getData(event.getDataContext());
34+
if (Objects.nonNull(module)) {
35+
final Project project = Objects.requireNonNull(event.getProject());
36+
final PropertiesComponent properties = PropertiesComponent.getInstance(project);
37+
properties.setValue(module.getName() + ".azure", "show");
38+
ProjectView.getInstance(module.getProject()).getCurrentProjectViewPane().updateFromRoot(true);
39+
}
40+
}
41+
42+
@Override
43+
public void update(@NotNull AnActionEvent e) {
44+
final Module module = LangDataKeys.MODULE.getData(e.getDataContext());
45+
final Object[] selected = PlatformDataKeys.SELECTED_ITEMS.getData(e.getDataContext());
46+
final boolean onDotAzure = Objects.nonNull(selected) && selected.length == 1 && (selected[0] instanceof PsiDirectoryNode node) && ".azure".equalsIgnoreCase(node.getValue().getName());
47+
e.getPresentation().setEnabledAndVisible(Objects.nonNull(module) || onDotAzure);
48+
}
49+
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-resource-connector-lib/src/main/resources/META-INF/azure-intellij-resource-connector-lib.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
topic="com.microsoft.azure.toolkit.intellij.connector.ConnectionTopics$ConnectionChanged" />
2929
</projectListeners>
3030
<actions>
31+
<action
32+
id="Connector.ShowAzureNode"
33+
class="com.microsoft.azure.toolkit.intellij.facet.ToggleAzureFacetNodeAction"
34+
text="Show 'Azure' Node"
35+
icon="AllIcons.General.InspectionsEye"
36+
description="Show 'Azure' Node for resource connections management"/>
3137
<action
3238
id="AzureToolkit.ConnectToAzureResource"
3339
class="com.microsoft.azure.toolkit.intellij.connector.ModuleConnectorAction"

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,12 @@
201201
<action class="com.microsoft.intellij.actions.NewFeatureRequestFeedbackAction" id="AzureToolkit.FeatureRequest" text="Request a Feature" />
202202

203203
<group id="AzurePopupGroup" text="Azure" description="Azure" icon="/icons/Common/Azure.svg" popup="true" class="com.microsoft.intellij.actions.AzurePopupGroup">
204+
<reference ref="Connector.ShowAzureNode"/>
204205
<reference ref="AzureToolkit.ConnectToAzureResource"/>
205206
<separator/>
206207
<reference ref="Actions.RunFunction"/>
207208
<reference ref="Actions.DeployFunction"/>
208-
<separator/>
209209
<reference ref="Actions.DeploySpringCloud"/>
210-
<separator/>
211210
<reference ref="Actions.WebDeployAction"/>
212211
<separator/>
213212
<reference ref="Actions.AddDockerSupport"/>

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/java/com/microsoft/azure/toolkit/ide/common/icon/AzureIcons.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static final class Common {
2929
public static final AzureIcon AZURE_MONITOR = AzureIcon.builder().iconPath("icons/Common/log_analytics_workspace.svg").build();
3030
public static final AzureIcon AZURE_MONITOR_NEW = AzureIcon.builder().iconPath("icons/Common/log_analytics_workspace_bluedot.svg").build();
3131
public static final AzureIcon VARIABLE = AzureIcon.builder().iconPath("icons/Common/variable.svg").build();
32+
public static final AzureIcon HIDE = AzureIcon.builder().iconPath("icons/Common/hide").build();
3233
}
3334

3435
public static final class Action {

0 commit comments

Comments
 (0)