Skip to content

Commit

Permalink
CLDR-14788 Hide TC and manager level menu items from vetters
Browse files Browse the repository at this point in the history
-Front end: hide buttons for Show all users, unless new function canListMultipleUsers returns true, that is, userIsManager

-Front end: in main menu hide My Organization section header if the section would be empty

-Front end: canListUsers and canMonitorVetting only if userIsManager

-Front end: canSeeUnofficialEmail only if isUnofficial and userIsManager

-Back end: canDoList only if isManagerOrStronger

-Back end: SurveyVettingParticipation only if isManagerOrStronger
  • Loading branch information
btangmu committed Jul 16, 2024
1 parent 49c74ad commit ab7b985
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
10 changes: 8 additions & 2 deletions tools/cldr-apps/js/src/esm/cldrAccount.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function getHtml(json) {
html += getOrgFilterMenu();
}
}
if (justUser) {
if (justUser && canListMultipleUsers()) {
html += "<p>" + listMultipleUsersButton + "</p>\n";
}
if (!isJustMe) {
Expand Down Expand Up @@ -345,7 +345,9 @@ function getTableStart() {
function getTableEnd(json) {
let html = "</tbody></table>" + "<br />\n";
if (justUser) {
html += listMultipleUsersButton;
if (canListMultipleUsers()) {
html += listMultipleUsersButton;
}
} else {
html += numberOfUsersShown(shownUsers ? shownUsers.length : 0);
html += getEmailControls(json);
Expand All @@ -354,6 +356,10 @@ function getTableEnd(json) {
return html;
}

function canListMultipleUsers() {
return !!cldrStatus.getPermissions()?.userIsManager;
}

function numberOfUsersShown(number) {
return (
"<div style='font-size: 70%'>Number of users shown: " + number + "</div>\n"
Expand Down
24 changes: 18 additions & 6 deletions tools/cldr-apps/js/src/views/MainMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@
</li>
</ul>
</li>
<li class="section-header">My Organization ({{ org }})</li>
<li
class="section-header"
v-if="
canUseVettingSummary ||
canListUsers ||
canMonitorForum ||
canMonitorVetting ||
accountLocked ||
isAdmin
"
>
My Organization ({{ org }})
</li>
<li v-if="canUseVettingSummary">
<ul>
<li><a href="#vsummary///">Priority Items Summary</a></li>
Expand Down Expand Up @@ -84,7 +96,7 @@
</li>
</ul>
</li>
<li v-if="isUnofficial">
<li v-if="canSeeUnofficialEmail">
<ul>
<li>
<a href="#mail///">Simulate Email Notifications (SMOKETEST ONLY)</a>
Expand Down Expand Up @@ -135,7 +147,7 @@ export default {
canUseVettingSummary: false,
isAdmin: false,
isTC: false,
isUnofficial: false,
canSeeUnofficialEmail: false,
loggedIn: false,
org: null,
recentActivityUrl: null,
Expand All @@ -153,13 +165,13 @@ export default {
const perm = cldrStatus.getPermissions();
this.accountLocked = perm && perm.userIsLocked;
this.canImportOldVotes = perm && perm.userCanImportOldVotes;
this.canListUsers = this.canMonitorVetting =
perm && (perm.userIsTC || perm.userIsVetter);
this.canListUsers = this.canMonitorVetting = !!perm?.userIsManager;
this.canMonitorForum = perm && perm.userCanMonitorForum;
// this.canSeeStatistics will be false until there is a new implementation
this.canUseVettingSummary = perm && perm.userCanUseVettingSummary;
this.isAdmin = perm && perm.userIsAdmin;
this.isUnofficial = cldrStatus.getIsUnofficial();
this.canSeeUnofficialEmail =
cldrStatus.getIsUnofficial() && !!perm?.userIsManager;
this.isTC = perm && perm.userIsTC;
const user = cldrStatus.getSurveyUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ private void processRequest(
mySession.userDidAction();
SurveyJSONWrapper r = newJSONStatus(request, sm);
r.put("what", what);
if (UserRegistry.userIsVetter(mySession.user)) {
if (UserRegistry.userIsManagerOrStronger(mySession.user)) {
String org = mySession.user.org;
if (UserRegistry.userCreateOtherOrgs(mySession.user)) {
org = null; // all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public boolean canImportOldVotes(CheckCLDR.Phase inPhase) {
}

public boolean canDoList() {
return isVetter();
return isManagerOrStronger();
}

public boolean canCreateUsers() {
Expand Down

0 comments on commit ab7b985

Please sign in to comment.