function formatContributionDetails()

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


function formatContributionDetails(row, srvId) {
    //  row  is the original data object for the row
    if(!isDefinedAndFilled(row))
        return;

    let prId = row.prNumber;
    var res = "";
    res += "<div class='formgroup'>";
    res += "<table cellpadding='5' cellspacing='0' border='0' style='padding-left:50px;'>\n";
    res += "<tr><td colspan='4' id='choiceOfChain_" + prId + "'></td></tr>";

    //caption of stage
    res += "<tr>\n" +
        "                <td>PR naming</td>\n" +
        "                <td>Build Queued</td>\n" +
        "                <td>Results ready</td>\n" +
        "                <td>JIRA comment</td>\n" +
        //todo  "                <td>Validity check</td>\n" +
        "            </tr>\n";

    //icon of stage
    res += "<tr>\n" +
        "                <th title='PR should have valid naming starting with issue name'><span class='visaStage' id='visaStage_1_" + prId + "'></span></th>\n" +
        "                <th title='Suite should be triggered'><span class='visaStage' id='visaStage_2_" + prId + "'></span></th>\n" +
        "                <th><span class='visaStage' id='visaStage_3_" + prId + "'></span></th>\n" +
         "               <th><span class='visaStage' id='visaStage_4_" + prId + "'></span></th>\n" +
        //todo validityCheck;"                <th><span class='visaStage' id='visaStage_5_" + prId + "'></span></th>\n" +
        "            </tr>\n";

    //action for stage
    res += "        <tr>\n" +
        "            <td></td>\n" +
        "            <td id='triggerBuildFor" + prId + "'>Loading builds...</td>\n" +
        "            <td id='showResultFor" + prId + "'>Loading builds...</td>\n" +
        "            <td id='commentJiraFor" + prId + "'></td>\n" +
        "        </tr>";

    //action row 2
    res += "        <tr>\n" +
        "            <td id='testDraw'></td>\n" +
        "            <td id='triggerAndObserveBuildFor" + prId + "' colspan='3' align='center'></td>\n" +
        "           </tr>";

    //References
    res += "        <tr>\n";

    if (row.prNumber > 0)
        res += "            <td>Edit PR: " + "<a href='" + row.prHtmlUrl + "'>#" + row.prNumber + "</a>" + "</td>\n";
    else
        res += "            <td></td>\n";

    res += "            <td id='viewQueuedBuildsFor" + prId + "'></td>\n" +
        "            <td></td>\n" +
        "            <td></td>\n" +
        "        </tr>";

    res += "    </table>";

    res += "</div>";

    $.ajax({
        url: "rest/visa/contributionStatus" +
            "?serverId=" + srvId +
            "&prId=" + prId,
        success:
            function (result) {
                let selectHtml = "<select id='selectChain_" + prId + "' style='width: 350px'>";

                let isDefault = [],
                    isCompleted = [],
                    isIncompleted = [],
                    suites = new Map();

                //See also org.apache.ignite.ci.tcbot.visa.ContributionCheckStatus
                for (let status of result) {
                    suites.set(status.suiteId, status);

                    if (isDefinedAndFilled(status.defaultBuildType) && status.defaultBuildType === true)
                        isDefault.push(status);
                    else if (isDefinedAndFilled(status.branchWithFinishedSuite))
                        isCompleted.push(status);
                    else
                        isIncompleted.push(status);
                }

                for (let status of isDefault)
                    selectHtml += "<option value='true' style='font-weight: bold; color: darkblue'>" + status.suiteId + "</option>";

                for (let status of isCompleted)
                    selectHtml += "<option value='true'>" + status.suiteId + "</option>";

                for (let status of isIncompleted)
                    selectHtml += "<option value='false' style='color:grey'>" + status.suiteId + "</option>";

                selectHtml += "</select>";

                $('#choiceOfChain_' + prId).html(selectHtml);

                prs.set(prId, suites);

                let select = $("#selectChain_" + prId);

                select.change(function () {
                    let pr = prs.get(prId);
                    let selectedOption = $("#selectChain_" + prId + " option:selected").text();
                    let buildIsCompleted = select.val() === 'true';

                    showContributionStatus(pr.get(selectedOption), prId, row, srvId, selectedOption, buildIsCompleted);
                });

                select.change();
            }
    });
    return res;
}