From 370056c4f3df4d456a55ee97956a769c0e531985 Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Fri, 26 Apr 2024 12:23:17 +0200 Subject: [PATCH] fix: 'Delete Project' label is confusing when using kubernetes cluster (#804) Signed-off-by: Stephane Bouchet --- .../actions/project/DeleteProjectAction.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jboss/tools/intellij/openshift/actions/project/DeleteProjectAction.java b/src/main/java/org/jboss/tools/intellij/openshift/actions/project/DeleteProjectAction.java index 89595383a..7a2b2d3b4 100644 --- a/src/main/java/org/jboss/tools/intellij/openshift/actions/project/DeleteProjectAction.java +++ b/src/main/java/org/jboss/tools/intellij/openshift/actions/project/DeleteProjectAction.java @@ -34,31 +34,45 @@ public DeleteProjectAction() { } @Override - public String getTelemetryActionName() { return "delete project"; } + public void update(AnActionEvent e) { + super.update(e); + if (e.getPresentation().isVisible()) { + Odo odo = getOdo(e); + if (odo == null) { + return; + } + // overrides label given in plugin.xml + e.getPresentation().setText("Delete " + odo.getNamespaceKind()); + } + } + + @Override + public String getTelemetryActionName() {return "delete project";} @Override public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object selected, @NotNull Odo odo) { + String kind = odo.getNamespaceKind(); NamespaceNode namespaceNode = (NamespaceNode) selected; - if (Messages.NO == Messages.showYesNoDialog("Delete Project '" + namespaceNode.getName() + "'.\nAre you sure?", "Delete Project", - Messages.getQuestionIcon())) { - sendTelemetryResults(TelemetryResult.ABORTED); - return; + if (Messages.NO == Messages.showYesNoDialog("Delete " + kind + " '" + namespaceNode.getName() + "'.\n\nDELETING " + kind.toUpperCase() + " WILL DELETE ALL ASSOCIATED RESOURCES ON THE CLUSTER.\n\nAre you sure?", "Delete " + kind, + Messages.getQuestionIcon())) { + sendTelemetryResults(TelemetryResult.ABORTED); + return; } runWithProgress((ProgressIndicator progress) -> { try { - Notification notif = NotificationUtils.notifyInformation("Delete project", "Deleting project " + namespaceNode.getName()); + Notification notif = NotificationUtils.notifyInformation("Delete " + kind, "Deleting " + kind.toLowerCase() + " " + namespaceNode.getName()); Notifications.Bus.notify(notif); odo.deleteProject(namespaceNode.getName()); notif.expire(); - NotificationUtils.notifyInformation("Delete project", "Project " + namespaceNode.getName() + " has been successfully deleted"); + NotificationUtils.notifyInformation("Delete " + kind, kind + " " + namespaceNode.getName() + " has been successfully deleted"); NodeUtils.fireRemoved(namespaceNode); sendTelemetryResults(TelemetryResult.SUCCESS); } catch (IOException e) { sendTelemetryError(e); - UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete Project")); + UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete " + kind)); } }, - "Delete Project " + namespaceNode.getName(), + "Delete " + kind + " " + namespaceNode.getName(), getEventProject(anActionEvent) ); }