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-16835 DDL announcement #3796

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion tools/cldr-apps/js/src/views/AnnounceForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<a-radio-group v-model:value="formState.orgs">
<a-radio value="Mine" title="Only your own organization">Mine</a-radio>
<a-radio value="TC" title="All TC organizations">TC Orgs</a-radio>
<a-radio value="NonTC" title="Non-TC organizations"
>Non-TC Orgs</a-radio
>
<a-radio value="All" title="All organizations">All</a-radio>
</a-radio-group>
</a-form-item>
Expand All @@ -42,7 +45,7 @@
<a-form-item class="formItems" label="Locales" name="locs">
<a-input
v-model:value="formState.locs"
placeholder="Optional list of locales (like: aa fr zh) (fr implies fr_CA/etc.) (empty for all locales)"
placeholder="Optional list of locales (like: aa fr zh) (fr implies fr_CA/etc.) (empty for all locales, '!' for non-TC)"
srl295 marked this conversation as resolved.
Show resolved Hide resolved
@blur="validateLocales()"
/>
</a-form-item>
Expand Down Expand Up @@ -158,6 +161,8 @@ export default defineComponent({
return "all organizations";
case "TC":
return "TC organizations";
case "NonTC":
return "Non-TC organizations";
case "Mine":
return "your organization only";
default:
Expand All @@ -166,12 +171,14 @@ export default defineComponent({
},

describeLocs() {
if (this.formState.locs === "!") return "Non-TC locales";
return this.formState.locs === "" || this.formState.locs === "*"
? "all locales"
: "the following locale(s): " + this.formState.locs;
},

validateLocales() {
if (this.formState.locs === "!") return;
srl295 marked this conversation as resolved.
Show resolved Hide resolved
cldrAnnounce.combineAndValidateLocales(
this.formState.locs,
this.updateValidatedLocales
Expand Down
9 changes: 6 additions & 3 deletions tools/cldr-apps/js/src/views/AnnouncePost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<section class="announcementToFrom">
To: {{ announcement.audience }} •
{{ "Organization(s): " + announcement.orgs }} •
{{
announcement.locs ? "Locale(s): " + announcement.locs : "All locales"
}}
{{ localeText }}
</section>
<section class="announcementSubject">
{{ announcement.subject }}
Expand Down Expand Up @@ -50,6 +48,11 @@ export default {
.replaceAll("\n", "\n<br>\n")
.replaceAll(/(http\S+)/g, "<a href='$1'>$1</a>");
},
localeText() {
if (!this.announcement.locs) return "All locales";
if (this.announcement.locs === "!") return "DDL Locales";
srl295 marked this conversation as resolved.
Show resolved Hide resolved
return "Locale(s): " + this.announcement.locs;
},
},
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import com.ibm.icu.dev.util.ElapsedTimer;
import java.sql.*;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.unicode.cldr.test.SubmissionLocales;
import org.unicode.cldr.util.*;
import org.unicode.cldr.web.api.Announcements;

Expand Down Expand Up @@ -148,6 +149,7 @@ private static void emailNotify(
}
String subject = "CLDR Survey Tool announcement: " + request.subject;
String locs = (request.locs == null || request.locs.isEmpty()) ? "All" : request.locs;
if (locs.equals(Announcements.LOCS_NON_TC)) locs = "(DDL Locales)";
srl295 marked this conversation as resolved.
Show resolved Hide resolved
String body =
"From: "
+ poster.name
Expand Down Expand Up @@ -223,7 +225,16 @@ private static void addRecipientIfPasses(
AnnouncementFilter aFilter = new AnnouncementFilter(user);
Announcements.Announcement a =
new Announcements.Announcement(0, poster.id, null, null, null);
a.setFilters(request.locs, request.orgs, request.audience);
String filterLocs = request.locs;
if (filterLocs != null && filterLocs.equals(Announcements.LOCS_NON_TC)) {
// expand the filter
filterLocs =
SurveyMain.getLocalesSet().stream()
.filter(loc -> !SubmissionLocales.isTcLocale(loc))
.map(l -> l.getBaseName())
.collect(Collectors.joining(" "));
}
a.setFilters(filterLocs, request.orgs, request.audience);
if (aFilter.passes(a)) {
logger.fine("In AnnouncementData.addRecipientIfPasses, adding recipient: " + user.id);
recipients.add(user.id);
Expand Down Expand Up @@ -470,6 +481,8 @@ private boolean matchOrg(String orgs, int posterId) {
return true;
} else if (Announcements.ORGS_TC.equals(orgs)) {
return user.getOrganization().isTCOrg();
} else if (Announcements.ORGS_NON_TC.equals(orgs)) {
return !user.getOrganization().isTCOrg();
} else if (Announcements.ORGS_MINE.equals(orgs)) {
UserRegistry.User posterUser = CookieSession.sm.reg.getInfo(posterId);
return posterUser != null && posterUser.isSameOrg(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ public class Announcements {

public static final String ORGS_MINE = "Mine";
public static final String ORGS_TC = "TC";
public static final String ORGS_NON_TC = "NonTC";
public static final String ORGS_ALL = "All";

public static final String LOCS_NON_TC = "!";

private static final Set<String> validAudiences =
new HashSet<>(
Arrays.asList(
AUDIENCE_TC, AUDIENCE_MANAGERS, AUDIENCE_VETTERS, AUDIENCE_EVERYONE));
private static final Set<String> validOrgs =
new HashSet<>(Arrays.asList(ORGS_MINE, ORGS_TC, ORGS_ALL));
new HashSet<>(Arrays.asList(ORGS_MINE, ORGS_NON_TC, ORGS_TC, ORGS_ALL));

@GET
@Produces(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -250,7 +253,7 @@ public boolean isValid() {
}

public void normalize() {
if (locs != null) {
if (locs != null && !locs.equals(LOCS_NON_TC)) {
String normalized = LocaleNormalizer.normalizeQuietly(locs);
LocaleSet locSet = LocaleNormalizer.setFromStringQuietly(normalized, null);
LocaleSet langSet = locSet.combineRegionalVariants();
Expand Down
Loading