Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-15275 ST forum stuck on loading if user lacks permission #1682

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 41 additions & 34 deletions tools/cldr-apps/js/src/esm/cldrForum.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,49 +99,20 @@ function loadForum(locale, userId, forumMessage, params) {
setLocale(locale);
const url = getLoadForumUrl();
const errorHandler = function (err) {
params.special.showError(params, null, {
loadHandler({
err: err,
what: "Loading forum data",
err_code: "Loading forum data",
});
};
const loadHandler = function (json) {
if (json.err) {
if (params.special) {
params.special.showError(params, json, {
what: "Loading forum data",
});
}
return;
}
/*
* The server has already confirmed that the user is logged in and has permission to view the forum.
* Note: the criteria (here) for posting in the main forum window are less strict than in the info
* panel; see the other call to setUserCanPost. Here, we have no "json.canModify" set by the server.
*/
setUserCanPost(true);

// set up the 'right sidebar'
const message = cldrText.get(params.name + "Guidance");
cldrInfo.showMessage(message);

const ourDiv = document.createElement("div");
ourDiv.appendChild(forumCreateChunk(forumMessage, "h4", ""));

const filterMenu = cldrForumFilter.createMenu(cldrLoad.reloadV);
const summaryDiv = document.createElement("div");
summaryDiv.innerHTML = "";
ourDiv.appendChild(summaryDiv);
ourDiv.appendChild(filterMenu);
ourDiv.appendChild(document.createElement("hr"));
const posts = json.ret;
if (posts.length == 0) {
ourDiv.appendChild(
forumCreateChunk(cldrText.get("forum_noposts"), "p", "helpContent")
);
if (json.err) {
loadBad(ourDiv, json);
} else {
const content = parseContent(posts, "main");
ourDiv.appendChild(content);
summaryDiv.innerHTML = getForumSummaryHtml(forumLocale, userId, true); // after parseContent
loadOk(ourDiv, json, userId, forumMessage);
}
// No longer loading
cldrSurvey.hideLoader();
Expand All @@ -157,6 +128,42 @@ function loadForum(locale, userId, forumMessage, params) {
cldrAjax.sendXhr(xhrArgs);
}

function loadBad(ourDiv, json) {
let html = "<p>" + json.err + "</p>";
if (json.err_code) {
html += "<p>" + cldrText.get(json.err_code) + "</p>";
}
ourDiv.innerHTML = html;
}

function loadOk(ourDiv, json, userId, forumMessage) {
/*
* The server has already confirmed that the user is logged in and has permission to view the forum.
* Note: the criteria (here) for posting in the main forum window are less strict than in the info
* panel; see the other call to setUserCanPost. Here, we have no "json.canModify" set by the server.
*/
setUserCanPost(true);

ourDiv.appendChild(forumCreateChunk(forumMessage, "h4", ""));

const filterMenu = cldrForumFilter.createMenu(cldrLoad.reloadV);
const summaryDiv = document.createElement("div");
summaryDiv.innerHTML = "";
ourDiv.appendChild(summaryDiv);
ourDiv.appendChild(filterMenu);
ourDiv.appendChild(document.createElement("hr"));
const posts = json.ret;
if (posts.length == 0) {
ourDiv.appendChild(
forumCreateChunk(cldrText.get("forum_noposts"), "p", "helpContent")
);
} else {
const content = parseContent(posts, "main");
ourDiv.appendChild(content);
summaryDiv.innerHTML = getForumSummaryHtml(forumLocale, userId, true); // after parseContent
}
}

// called as special.handleIdChanged
function handleIdChanged(strid) {
if (strid) {
Expand Down