Skip to content

Commit

Permalink
CLDR-16799 allow not-logged-in to see dashboard (#3843)
Browse files Browse the repository at this point in the history
  • Loading branch information
srl295 authored Jul 5, 2024
1 parent 9707787 commit 5bb8280
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 0 additions & 4 deletions tools/cldr-apps/js/src/views/DashboardWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ export default {
},
fetchData() {
if (!cldrStatus.getSurveyUser()) {
this.fetchErr = "Please log in to see the Dashboard.";
return;
}
this.locale = cldrStatus.getCurrentLocale();
this.level = cldrCoverage.effectiveName(this.locale);
if (!this.locale || !this.level) {
Expand Down
15 changes: 13 additions & 2 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,22 @@ public ReviewEntry(String code) {
public ReviewOutput get(
CLDRLocale locale, UserRegistry.User user, Level coverageLevel, String xpath) {
final SurveyMain sm = CookieSession.sm;
Organization usersOrg = Organization.fromString(user.voterOrg());
Organization usersOrg = Organization.unaffiliated;
if (user != null) {
usersOrg = Organization.fromString(user.voterOrg());
}
STFactory sourceFactory = sm.getSTFactory();
VettingViewer<Organization> vv =
new VettingViewer<>(
sm.getSupplementalDataInfo(), sourceFactory, new STUsersChoice(sm));
EnumSet<NotificationCategory> choiceSet =
VettingViewer.getDashboardNotificationCategories(usersOrg);
VettingParameters args = new VettingParameters(choiceSet, locale, coverageLevel);
args.setUserAndOrganization(user.id, usersOrg);
if (user != null) {
args.setUserAndOrganization(user.id, usersOrg);
} else {
args.setUserAndOrganization(UserRegistry.NO_USER, usersOrg);
}
args.setFiles(locale, sourceFactory, sm.getDiskFactory());
if (xpath != null) {
args.setXpath(xpath);
Expand Down Expand Up @@ -286,6 +293,10 @@ private void addNotificationEntries(

notification = getNextNotification(reviewOutput, notification, entry);

if (notification.category.equals("Abstained")
&& args.getUserId() == UserRegistry.NO_USER) {
continue; // don't show abstained when the user can't vote.
}
addNotificationGroup(args, notification, englishFile, entry);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,10 @@ private void internalSetVoteForValue(

@Override
public boolean userDidVote(User myUser, String somePath) {
if (myUser == null || myUser.id == UserRegistry.NO_USER) {
// if there is no user, by definition the user did not vote.
return false;
}
PerXPathData xpd = peekXpathData(somePath);
return (xpd != null && xpd.userDidVote(myUser));
}
Expand Down

0 comments on commit 5bb8280

Please sign in to comment.