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-14788 Hide TC and manager level menu items from vetters #3871

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
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
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another way would be to expand the cldrStatus.getPermissions() struct ( a string -> boolean map i think) to include a new item from the server side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I'll follow up with a PR to get canDoList from the back end...

}

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 @@ -57,7 +57,7 @@ adlam, anonymous, canImportOldVotesSUBMISSION, false, ,
adlam, admin,userCanDoList, true, ,
adlam, tc,userCanDoList, true, ,
adlam, manager,userCanDoList, true, ,
adlam, vetter,userCanDoList, true, ,
adlam, vetter,userCanDoList, false, ,
adlam, guest,userCanDoList, false, ,
adlam, locked,userCanDoList, false, ,
adlam, anonymous,userCanDoList, false, ,
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit tests are failing here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Fixed by the 2nd commit

}

public boolean canCreateUsers() {
Expand Down
Loading