Skip to content

Commit

Permalink
fix: 'Delete Project' label is confusing when using kubernetes cluster (
Browse files Browse the repository at this point in the history
#804)

Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet authored Apr 26, 2024
1 parent c30fb8d commit 370056c
Showing 1 changed file with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
Expand Down

0 comments on commit 370056c

Please sign in to comment.