Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 370056c

Browse files
authored
fix: 'Delete Project' label is confusing when using kubernetes cluster (#804)
Signed-off-by: Stephane Bouchet <[email protected]>
1 parent c30fb8d commit 370056c

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/main/java/org/jboss/tools/intellij/openshift/actions/project/DeleteProjectAction.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,45 @@ public DeleteProjectAction() {
3434
}
3535

3636
@Override
37-
public String getTelemetryActionName() { return "delete project"; }
37+
public void update(AnActionEvent e) {
38+
super.update(e);
39+
if (e.getPresentation().isVisible()) {
40+
Odo odo = getOdo(e);
41+
if (odo == null) {
42+
return;
43+
}
44+
// overrides label given in plugin.xml
45+
e.getPresentation().setText("Delete " + odo.getNamespaceKind());
46+
}
47+
}
48+
49+
@Override
50+
public String getTelemetryActionName() {return "delete project";}
3851

3952
@Override
4053
public void actionPerformedOnSelectedObject(AnActionEvent anActionEvent, Object selected, @NotNull Odo odo) {
54+
String kind = odo.getNamespaceKind();
4155
NamespaceNode namespaceNode = (NamespaceNode) selected;
42-
if (Messages.NO == Messages.showYesNoDialog("Delete Project '" + namespaceNode.getName() + "'.\nAre you sure?", "Delete Project",
43-
Messages.getQuestionIcon())) {
44-
sendTelemetryResults(TelemetryResult.ABORTED);
45-
return;
56+
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,
57+
Messages.getQuestionIcon())) {
58+
sendTelemetryResults(TelemetryResult.ABORTED);
59+
return;
4660
}
4761
runWithProgress((ProgressIndicator progress) -> {
4862
try {
49-
Notification notif = NotificationUtils.notifyInformation("Delete project", "Deleting project " + namespaceNode.getName());
63+
Notification notif = NotificationUtils.notifyInformation("Delete " + kind, "Deleting " + kind.toLowerCase() + " " + namespaceNode.getName());
5064
Notifications.Bus.notify(notif);
5165
odo.deleteProject(namespaceNode.getName());
5266
notif.expire();
53-
NotificationUtils.notifyInformation("Delete project", "Project " + namespaceNode.getName() + " has been successfully deleted");
67+
NotificationUtils.notifyInformation("Delete " + kind, kind + " " + namespaceNode.getName() + " has been successfully deleted");
5468
NodeUtils.fireRemoved(namespaceNode);
5569
sendTelemetryResults(TelemetryResult.SUCCESS);
5670
} catch (IOException e) {
5771
sendTelemetryError(e);
58-
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete Project"));
72+
UIHelper.executeInUI(() -> Messages.showErrorDialog("Error: " + e.getLocalizedMessage(), "Delete " + kind));
5973
}
6074
},
61-
"Delete Project " + namespaceNode.getName(),
75+
"Delete " + kind + " " + namespaceNode.getName(),
6276
getEventProject(anActionEvent)
6377
);
6478
}

0 commit comments

Comments
 (0)