ProxyAI/src/main/java/ee/carlrobert/codegpt/actions/toolwindow/DeleteConversationAction.java
keith siilats 8f9980fbf1
anymous telemetry based on redhat (#212)
* initial telemetry

* fixed segment bugs

* Move telemetry impl to submodule, add more actions

* Replace privacy policy link, minor refactoring

---------

Co-authored-by: Carl-Robert Linnupuu <carlrobertoh@gmail.com>
2023-09-27 18:44:01 +03:00

43 lines
1.5 KiB
Java

package ee.carlrobert.codegpt.actions.toolwindow;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.Messages;
import ee.carlrobert.codegpt.actions.editor.EditorActionsUtil;
import ee.carlrobert.codegpt.completions.TelemetryAction;
import ee.carlrobert.codegpt.conversations.ConversationService;
import ee.carlrobert.codegpt.conversations.ConversationsState;
import ee.carlrobert.codegpt.util.OverlayUtils;
import org.jetbrains.annotations.NotNull;
public class DeleteConversationAction extends AnAction {
private final Runnable onDelete;
public DeleteConversationAction(Runnable onDelete) {
super("Delete Conversation", "Delete single conversation", AllIcons.General.Remove);
this.onDelete = onDelete;
EditorActionsUtil.registerOrReplaceAction(this);
}
@Override
public void update(@NotNull AnActionEvent event) {
event.getPresentation().setEnabled(ConversationsState.getCurrentConversation() != null);
}
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
if (OverlayUtils.showDeleteConversationDialog() == Messages.YES) {
var project = event.getProject();
if (project != null) {
TelemetryAction.createActionMessage(TelemetryAction.IDE_ACTION)
.property("action", "DELETE_CONVERSATION")
.send();
ConversationService.getInstance().deleteSelectedConversation();
onDelete.run();
}
}
}
}