Search in sources :

Example 36 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.

the class ShowDiagnosticDataAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = instance().action(NAME_PREFIX_DIAG + "show diagnostic data");
    ExecHelper.submit(() -> {
        ParentableNode element = getElement(selected);
        String namespace = element.getNamespace();
        boolean hasDataToShow = false;
        try {
            if (element instanceof PipelineRunNode) {
                telemetry.property(PROP_RESOURCE_KIND, Constants.KIND_PIPELINERUN);
                hasDataToShow = tkncli.getDiagnosticData(namespace, "tekton.dev/pipelineRun", element.getName());
            } else if (element instanceof TaskRunNode) {
                telemetry.property(PROP_RESOURCE_KIND, Constants.KIND_TASKRUN);
                hasDataToShow = tkncli.getDiagnosticData(namespace, "tekton.dev/taskRun", element.getName());
            }
            if (!hasDataToShow) {
                String message = "No data available for " + element.getName() + " in namespace " + namespace + ".";
                telemetry.result(anonymizeResource(element.getName(), namespace, message)).send();
                UIHelper.executeInUI(() -> Messages.showWarningDialog("No data available for " + element.getName() + " in namespace " + namespace + ".", "Diagnostic Data"));
            } else {
                telemetry.success().send();
            }
        } catch (IOException e) {
            telemetry.error(anonymizeResource(element.getName(), namespace, e.getMessage())).send();
            UIHelper.executeInUI(() -> Messages.showErrorDialog("Failed to retrieve data for " + element.getName() + " in namespace " + namespace + ". An error occurred while retrieving them.\n" + e.getLocalizedMessage(), "Error"));
            logger.warn("Error: " + e.getLocalizedMessage(), e);
            return;
        }
    });
}
Also used : ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) TaskRunNode(com.redhat.devtools.intellij.tektoncd.tree.TaskRunNode) IOException(java.io.IOException) PipelineRunNode(com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode)

Example 37 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.

the class TektonHubAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "tekton hub");
    ExecHelper.submit(() -> {
        ParentableNode element = getElement(selected);
        Project project = getEventProject(anActionEvent);
        HubModel model = new HubModel(project, tkncli, element);
        telemetry.send();
        UIHelper.executeInUI(() -> {
            HubDialog wizard = new HubDialog(project, model);
            wizard.setModal(false);
            wizard.show();
            return wizard;
        });
    });
}
Also used : Project(com.intellij.openapi.project.Project) ParentableNode(com.redhat.devtools.intellij.tektoncd.tree.ParentableNode) HubDialog(com.redhat.devtools.intellij.tektoncd.ui.hub.HubDialog) ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) HubModel(com.redhat.devtools.intellij.tektoncd.ui.hub.HubModel)

Example 38 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.

the class CreateClusterTaskAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create cluster task").property(PROP_RESOURCE_KIND, KIND_CLUSTERTASK);
    ClusterTasksNode item = getElement(selected);
    String namespace = item.getParent().getName();
    String content = getSnippet("Tekton: ClusterTask");
    if (Strings.isNullOrEmpty(content)) {
        telemetry.error("snippet content empty").send();
    } else {
        String name = "newclustertask.yaml";
        try {
            VirtualFileHelper.createAndOpenVirtualFile(anActionEvent.getProject(), namespace, name, content, KIND_CLUSTERTASKS, item);
            telemetry.success().send();
        } catch (IOException e) {
            String errorMessage = "Could not create cluster cluster task: " + e.getLocalizedMessage();
            telemetry.error(anonymizeResource(name, namespace, errorMessage)).send();
            logger.warn(errorMessage, e);
        }
    }
}
Also used : ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) IOException(java.io.IOException) ClusterTasksNode(com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode)

Example 39 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.

the class CreatePipelineAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
    ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create pipeline").property(PROP_RESOURCE_KIND, KIND_PIPELINE);
    PipelinesNode item = getElement(selected);
    String namespace = item.getParent().getName();
    String content = getSnippet("Tekton: Pipeline");
    if (Strings.isNullOrEmpty(content)) {
        telemetry.error("snippet content empty").send();
    } else {
        String name = namespace + "-newpipeline.yaml";
        try {
            VirtualFileHelper.createAndOpenVirtualFile(anActionEvent.getProject(), namespace, name, content, KIND_PIPELINES, item);
            telemetry.send();
        } catch (IOException e) {
            telemetry.error(anonymizeResource(name, namespace, e.getMessage())).send();
            logger.warn("Could not create resource: " + e.getLocalizedMessage(), e);
        }
    }
}
Also used : PipelinesNode(com.redhat.devtools.intellij.tektoncd.tree.PipelinesNode) ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) IOException(java.io.IOException)

Aggregations

ActionMessage (com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage)39 Test (org.junit.jupiter.api.Test)26 IOException (java.io.IOException)11 ParentableNode (com.redhat.devtools.intellij.tektoncd.tree.ParentableNode)6 Notification (com.intellij.notification.Notification)3 PipelineRunNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode)3 TaskRunNode (com.redhat.devtools.intellij.tektoncd.tree.TaskRunNode)3 Tkn (com.redhat.devtools.intellij.tektoncd.tkn.Tkn)2 PipelineNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineNode)2 TektonTreeStructure (com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure)2 Duration (java.time.Duration)2 LocalDateTime (java.time.LocalDateTime)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 GenericResource (com.redhat.devtools.intellij.common.model.GenericResource)1 ExecHelper (com.redhat.devtools.intellij.common.utils.ExecHelper)1 UIHelper (com.redhat.devtools.intellij.common.utils.UIHelper)1