Skip to content

Commit 56ad5b5

Browse files
support removing deployment target from Project Explorer.
1 parent d8ac237 commit 56ad5b5

File tree

2 files changed

+24
-1
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-resource-connector-lib/src/main/java/com/microsoft/azure/toolkit/intellij/connector/projectexplorer
  • Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/resources/bundles/com/microsoft/azure/toolkit

2 files changed

+24
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
import com.intellij.ui.SimpleTextAttributes;
1212
import com.intellij.ui.tree.LeafState;
1313
import com.microsoft.azure.toolkit.ide.common.component.Node;
14+
import com.microsoft.azure.toolkit.ide.common.icon.AzureIcons;
1415
import com.microsoft.azure.toolkit.intellij.common.IntelliJAzureIcons;
1516
import com.microsoft.azure.toolkit.lib.common.action.Action;
17+
import com.microsoft.azure.toolkit.lib.common.action.ActionGroup;
1618
import com.microsoft.azure.toolkit.lib.common.action.IActionGroup;
19+
import com.microsoft.azure.toolkit.lib.common.model.AbstractAzResource;
20+
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1721
import lombok.EqualsAndHashCode;
1822
import lombok.extern.slf4j.Slf4j;
1923
import org.apache.commons.lang3.StringUtils;
@@ -88,7 +92,25 @@ public void onClicked(Object event) {
8892
@Override
8993
@Nullable
9094
public IActionGroup getActionGroup() {
91-
return Optional.ofNullable(getValue()).map(Node::getActions).orElse(null);
95+
IActionGroup group = Optional.ofNullable(getValue()).map(Node::getActions).orElse(null);
96+
final Object value = this.getValue().getValue();
97+
if (this.parent instanceof DeploymentTargetsNode targets && value instanceof AbstractAzResource<?, ?, ?> resource) {
98+
final AzureTaskManager tm = AzureTaskManager.getInstance();
99+
final Action<Object> removeTarget = new Action<>(Action.Id.of("user/connector.remove_target.app"))
100+
.withLabel("Remove")
101+
.withIdParam(this.getValue().getLabel())
102+
.withIcon(AzureIcons.Action.DELETE.getIconPath())
103+
.withHandler(ignore -> tm.runLater(() -> tm.write(() -> targets.getValue().getProfile().removeApp(resource).save())))
104+
.withAuthRequired(false);
105+
if (group != null) {
106+
group = new ActionGroup();
107+
group.appendActions(removeTarget, "---");
108+
group.appendActions(group.getActions());
109+
} else {
110+
group = new ActionGroup(removeTarget);
111+
}
112+
}
113+
return group;
92114
}
93115

94116
@Override

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/resources/bundles/com/microsoft/azure/toolkit/operation.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ user/connector.fix_connection=fix resource connection with invalid configuration
499499
user/connector.edit_connection_in_editor=edit module connection in editor
500500
user/connector.edit_connections_in_editor=edit module connections in editor
501501
user/connector.edit_targets_in_editor=edit deployment targets in editor
502+
user/connector.remove_target.app=remove deployment target {0} from this module (this will not remove the resource from Azure)
502503
user/connector.edit_env_in_editor=edit connection environment variable in editor
503504
user/connector.edit_envs_in_editor=edit connection environment variables in editor
504505
user/connector.connect_to_module=add/edit Azure resource connection of selected module

0 commit comments

Comments
 (0)