All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ui.static.topic.createTopic.js Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
$(document).ready(function () {
    $("#create-btn").click(createTopic);
});

function createTopic() {
    let topicDescription = extractTopicDescription();
    createTopicDescription(topicDescription);
}

function createTopicDescription(topicDescription) {
    let validateErrors = validateTopicDescription(topicDescription);
    if (validateErrors.length > 0) {
        showOpError("Failed validation", validateErrors.join("\n"));
        return;
    }
    let updateMsg = extractUpdateMessage();
    if (updateMsg.trim() === "") {
        updateMsg = "initial creation";
    }
    updateMsg = appendJiraIssuesIfAny(updateMsg, topicDescription.description);
    showOpProgress("Creating topic...");
    $
        .ajax("api/topics?message=" + encodeURI(updateMsg) + "&" + targetBranchUriParam(), {
            method: "POST",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(topicDescription)
        })
        .done(function () {
            showOpSuccess("Creation completed with success, redirecting...");
            setTimeout(function () {
                $.get("api/topics/single?topicName=" + encodeURI(topicDescription.name))
                    .done(function () {
                        location.href = urlFor("topics.showTopic", {topicName: topicDescription.name})
                    })
                    .fail(function () {
                        location.href = urlFor("topics.showTopics");
                    })
            }, 1000);
        })
        .fail(function (error) {
            let errorMsg = extractErrMsg(error);
            showOpError("Creation failed: " + errorMsg);
        });
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy