Skip to content

Commit 88dc9cf

Browse files
show Deploy to Azure node under Deployment Targets node if never deployed
1 parent 70fb3f6 commit 88dc9cf

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,25 @@
1616
import com.intellij.openapi.vfs.VirtualFile;
1717
import com.microsoft.azure.toolkit.ide.common.IActionsContributor;
1818
import com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor;
19+
import com.microsoft.azure.toolkit.ide.common.icon.AzureIcons;
1920
import com.microsoft.azure.toolkit.intellij.common.fileexplorer.VirtualFileActions;
2021
import com.microsoft.azure.toolkit.intellij.common.properties.IntellijShowPropertiesViewAction;
2122
import com.microsoft.azure.toolkit.lib.common.action.Action;
23+
import com.microsoft.azure.toolkit.lib.common.action.ActionGroup;
2224
import com.microsoft.azure.toolkit.lib.common.action.AzureActionManager;
2325
import com.microsoft.azure.toolkit.lib.common.event.AzureEventBus;
2426
import com.microsoft.azure.toolkit.lib.common.model.AzResource;
2527
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
2628
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
2729

30+
import java.util.Arrays;
2831
import java.util.Objects;
2932
import java.util.function.BiConsumer;
3033

3134
public class IntellijActionsContributor implements IActionsContributor {
3235
public static final Action.Id<Object> TRY_ULTIMATE = Action.Id.of("user/database.try_ultimate");
3336
private static final String IDE_DOWNLOAD_URL = "https://www.jetbrains.com/idea/download/";
37+
public static final String ACTIONS_DEPLOY_TO_AZURE = "actions.common.deploy_to_azure";
3438

3539
@Override
3640
public void registerHandlers(AzureActionManager am) {
@@ -80,6 +84,16 @@ public void registerActions(AzureActionManager am) {
8084
.register(am);
8185
}
8286

87+
@Override
88+
public void registerGroups(final AzureActionManager am) {
89+
final ActionGroup deployToAzure = new ActionGroup(Arrays.asList(
90+
"Actions.DeployFunction",
91+
"Actions.DeploySpringCloud",
92+
"Actions.WebDeployAction"
93+
), new Action.View("Deploy to Azure...", AzureIcons.Action.DEPLOY.getIconPath(), true, null));
94+
am.registerGroup(ACTIONS_DEPLOY_TO_AZURE, deployToAzure);
95+
}
96+
8397
@Override
8498
public int getOrder() {
8599
return ResourceCommonActionsContributor.INITIALIZE_ORDER + 1; //after azure resource common actions registered

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.intellij.openapi.actionSystem.ShortcutSet;
2424
import com.intellij.openapi.extensions.ExtensionPointName;
2525
import com.intellij.openapi.project.DumbAware;
26+
import com.intellij.openapi.ui.popup.JBPopupFactory;
2627
import com.microsoft.azure.toolkit.ide.common.IActionsContributor;
2728
import com.microsoft.azure.toolkit.ide.common.action.ResourceCommonActionsContributor;
2829
import com.microsoft.azure.toolkit.intellij.common.IntelliJAzureIcons;
@@ -32,6 +33,7 @@
3233
import com.microsoft.azure.toolkit.lib.common.action.IActionGroup;
3334
import com.microsoft.azure.toolkit.lib.common.model.AbstractAzResource;
3435
import com.microsoft.azure.toolkit.lib.common.model.Emulatable;
36+
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
3537
import com.microsoft.azure.toolkit.lib.common.view.IView;
3638
import lombok.Getter;
3739
import org.apache.commons.lang3.StringUtils;
@@ -199,6 +201,10 @@ public ActionGroupWrapper(@Nonnull ActionGroup group) {
199201
this.group = group;
200202
this.setPopup(true);
201203
this.addActions(group.getActions());
204+
final Presentation presentation = this.getTemplatePresentation();
205+
presentation.setPerformGroup(true);
206+
final IView.Label view = this.group.getView();
207+
Optional.ofNullable(this.group.getView()).ifPresent(v -> presentation.setText(v.getLabel()));
202208
}
203209

204210
@Override
@@ -208,7 +214,10 @@ public void update(@Nonnull AnActionEvent e) {
208214
final Presentation presentation = e.getPresentation();
209215
Optional.ofNullable(view).ifPresent(v -> {
210216
presentation.setText(v.getLabel());
211-
Optional.ofNullable(v.getIconPath()).filter(StringUtils::isNotBlank).ifPresent(IntelliJAzureIcons::getIcon);
217+
presentation.setDescription(v.getDescription());
218+
presentation.setEnabled(v.isEnabled());
219+
presentation.setVisible(v.isVisible());
220+
Optional.ofNullable(v.getIconPath()).filter(StringUtils::isNotBlank).map(IntelliJAzureIcons::getIcon).ifPresent(presentation::setIcon);
212221
});
213222
}
214223

@@ -223,6 +232,15 @@ private void addActions(List<Object> actions) {
223232
}
224233
}
225234

235+
@Override
236+
public void actionPerformed(@Nonnull AnActionEvent e) {
237+
AzureTaskManager.getInstance().runLater(() -> JBPopupFactory.getInstance().createActionGroupPopup(
238+
e.getPresentation().getText(), this, e.getDataContext(),
239+
JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
240+
false, null, -1, null, ActionPlaces.getPopupPlace(e.getPlace()))
241+
.showInBestPositionFor(e.getDataContext()));
242+
}
243+
226244
@Override
227245
public IView.Label getView() {
228246
return group.getView();

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,16 @@ protected Collection<? extends AbstractAzureFacetNode<?>> buildChildren() {
5757
@Override
5858
protected void buildView(@Nonnull PresentationData presentation) {
5959
final IView.Label view = this.getValue().getView(this.source);
60-
presentation.addText(StringUtils.capitalize(view.getLabel()), SimpleTextAttributes.LINK_ATTRIBUTES);
60+
presentation.addText(StringUtils.capitalize(view.getLabel()), view.isEnabled() && view.isVisible() ? SimpleTextAttributes.LINK_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES);
6161
presentation.setTooltip(view.getDescription());
6262
}
6363

6464
@Override
6565
public void onClicked(Object event) {
66+
final IView.Label view = this.getValue().getView(this.source);
67+
if (!view.isVisible() || !view.isEnabled()) {
68+
return;
69+
}
6670
final Action<T> value = getValue();
6771
if (event instanceof AnActionEvent) {
6872
value.getContext().setTelemetryProperty(Action.PLACE, ((AnActionEvent) event).getPlace());

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@
2525
import com.microsoft.azure.toolkit.lib.common.event.AzureEventBus;
2626
import com.microsoft.azure.toolkit.lib.common.model.AbstractAzResource;
2727
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
28+
import org.apache.commons.collections4.CollectionUtils;
2829

2930
import javax.annotation.Nonnull;
3031
import javax.annotation.Nullable;
32+
import java.util.ArrayList;
3133
import java.util.Arrays;
3234
import java.util.Collection;
35+
import java.util.List;
3336
import java.util.Objects;
3437
import java.util.Optional;
3538

39+
import static com.microsoft.azure.toolkit.intellij.common.action.IntellijActionsContributor.ACTIONS_DEPLOY_TO_AZURE;
3640
import static com.microsoft.azure.toolkit.intellij.connector.ResourceConnectionActionsContributor.REFRESH_MODULE_TARGETS;
3741

3842
public class DeploymentTargetsNode extends AbstractAzureFacetNode<DeploymentTargetManager> {
@@ -60,12 +64,18 @@ private void onEvent(@Nonnull final AzureEvent azureEvent) {
6064
@Override
6165
@Nonnull
6266
public Collection<? extends AbstractAzureFacetNode<?>> buildChildren() {
63-
return Optional.ofNullable(this.getValue()).stream()
67+
final List<? extends AbstractAzureFacetNode<?>> children = Optional.ofNullable(this.getValue()).stream()
6468
.flatMap(p -> p.getTargets().stream())
6569
.map(id -> Azure.az().getById(id))
6670
.filter(Objects::nonNull)
6771
.map(this::createResourceNode)
6872
.toList();
73+
if (CollectionUtils.isNotEmpty(children)) {
74+
return children;
75+
}
76+
final ArrayList<AbstractAzureFacetNode<?>> nodes = new ArrayList<>();
77+
nodes.add(new ActionNode<>(this.getProject(), Action.Id.of(ACTIONS_DEPLOY_TO_AZURE), this.getValue().getProfile().getModule().getModule()));
78+
return nodes;
6979
}
7080

7181
@Override

0 commit comments

Comments
 (0)