function showContributionStatus()

in ignite-tc-helper-web/src/main/webapp/js/prs-1.2.js [399:539]


function showContributionStatus(status, prId, row, srvId, suiteIdSelected) {
    let tdForPr = $('#showResultFor' + prId);

    if (!isDefinedAndFilled(status)) {
        console.log("Status for " + prId + " is undefined. Wait for the Bot to load the suite list.");

        return;
    }

    let buildIsCompleted = isDefinedAndFilled(status.branchWithFinishedSuite);
    let hasJiraIssue = isDefinedAndFilled(row.jiraIssueId);
    let hasQueued = status.queuedBuilds > 0 || status.runningBuilds > 0;
    let queuedStatus = "Has queued builds: " + status.queuedBuilds  + " queued " + " " + status.runningBuilds  + " running";

    let replaintCall = "repaintLater(" +
        "\"" + srvId + "\"" +
        ");";

    var linksToRunningBuilds = "";
    for (let i = 0; i < status.webLinksQueuedSuites.length; i++) {
        const l = status.webLinksQueuedSuites[i];
        linksToRunningBuilds += "<a href=" + l + ">View queued at TC</a> "
    }
    $('#viewQueuedBuildsFor' + prId).html(linksToRunningBuilds);

    if (buildIsCompleted) {
        let finishedBranch = status.branchWithFinishedSuite;

        let reportLink = "<a id='showReportlink_" + prId + "' href='" + prShowHref(srvId, suiteIdSelected, finishedBranch) + "'>" +
            "<button id='show_" + prId + "'>Show " + finishedBranch + " report</button>" +
            "</a>";
        if(isDefinedAndFilled(status.finishedSuiteCommit)) {
            reportLink += "<br>(" + status.finishedSuiteCommit + ")";
        }


        tdForPr.html(reportLink);

        if (hasJiraIssue) {
            let jiraBtn = "<button onclick='" +
                "commentJira(" +
                "\"" + srvId + "\", " +
                "\"" + finishedBranch + "\", " +
                "\"" + suiteIdSelected + "\", " +
                "\"" + row.jiraIssueId + "\"," +
                "\"\"" + // base TC branch
                "); " +
                replaintCall +
                "'";

            if (hasQueued) {
                jiraBtn += " class='disabledbtn' title='" + queuedStatus + "'";
            }
            jiraBtn += ">Comment JIRA</button>";

            $('#commentJiraFor' + prId).html(jiraBtn);
        }
    } else {
        tdForPr.html("No builds, please trigger " + suiteIdSelected);
    }


    showStageResult(1, prId, hasJiraIssue, !hasJiraIssue);

    let buildFinished = isDefinedAndFilled(status.suiteFinished) && status.suiteFinished;
    let noNeedToTrigger = hasQueued || buildIsCompleted;
    showStageResult(2, prId, noNeedToTrigger, false);
    showStageResult(3, prId, buildIsCompleted, false);
    if(hasQueued) {
        showWaitingResults(3, prId, queuedStatus);
    }

    if(isDefinedAndFilled(status.observationsStatus)) {
        showWaitingResults(4, prId, status.observationsStatus);
    }

    function prepareStatusOfTrigger() {
        var res  = "";
        if (hasQueued || buildIsCompleted) {
            res += " class='disabledbtn'";
            if (hasQueued)
                res += " title='" + queuedStatus + "'";
            else
                res += " title='Results are ready. It is still possible to trigger Build'";
        }
        return res;
    }

    if (isDefinedAndFilled(status.resolvedBranch)) {
        var jiraOptional = hasJiraIssue ? row.jiraIssueId : "";
        // triggerBuilds(serverId, suiteIdList, branchName, top, observe, ticketId)  defined in test fails
        let triggerBuildsCall = "triggerBuilds(" +
            "\"" + srvId + "\", " +
            "null, " +
            "\"" + suiteIdSelected + "\", " +
            "\"" + status.resolvedBranch + "\"," +
            " false," +
            " false," +
            "\"" + jiraOptional + "\"); ";
        var res = "<button onClick='" + triggerBuildsCall + replaintCall + "'";
        res += prepareStatusOfTrigger();

        res += ">Trigger build</button>";
        $("#triggerBuildFor" + prId).html(res);
    }

    if (hasJiraIssue && isDefinedAndFilled(status.resolvedBranch)) {
        // triggerBuilds(serverId, suiteIdList, branchName, top, observe, ticketId)  defined in test fails
        let trigObserveCall = "triggerBuilds(" +
            "\"" + srvId + "\", " +
            "null, " +
            "\"" + suiteIdSelected + "\", " +
            "\"" + status.resolvedBranch + "\"," +
            " false," +
            " true," +
            "\"" + jiraOptional + "\"); ";
        var trigAndObs = "<button onClick='" + trigObserveCall + replaintCall + "'";

        trigAndObs += prepareStatusOfTrigger();

        trigAndObs += ">Trigger build and comment JIRA after finish</button>";

        $('#triggerAndObserveBuildFor' + prId).html(trigAndObs);
    }


    $('#testDraw').html(testDraw);

    if(isDefinedAndFilled(status.branchWithFinishedSuite)) {
        $.ajax({
            url: "rest/visa/visaStatus" +
                "?serverId=" + srvId +
                "&suiteId=" + suiteIdSelected +
                "&tcBranch=" + status.branchWithFinishedSuite,
            success:
                function (result) {
                    showStageBlockers(3, prId, result.blockers);
                }
        });
    }
}