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 Non-TC locales and extended locales remain open longer #3795

Merged
merged 10 commits into from
Jun 13, 2024
28 changes: 27 additions & 1 deletion tools/cldr-apps/js/src/esm/cldrLoad.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,10 +1049,30 @@ function getLocaleDir(locale) {
return localeDir;
}

/** @returns true if locmap has been loaded from data */
function localeMapReady() {
return !!locmap.locmap;
}

/** event ID for localeMap changes */
const LOCALEMAP_EVENT = "localeMapReady";

/**
* Calls the callback when the localeMap is ready (with real data).
* Calls right away if the localeMap was already loaded.
*/
function onLocaleMapReady(callback) {
if (localeMapReady()) {
callback();
} else {
cldrStatus.on(LOCALEMAP_EVENT, callback);
}
}

function setTheLocaleMap(lm) {
locmap = lm;
cldrStatus.dispatchEvent(new Event(LOCALEMAP_EVENT));
}

/**
* Convenience for calling getTheLocaleMap().getLocaleName(loc)
* @param {String} loc
Expand All @@ -1062,6 +1082,10 @@ function getLocaleName(loc) {
return locmap.getLocaleName(loc);
}

function getLocaleInfo(loc) {
return locmap.getLocaleInfo(loc);
}

/**
* Get the window location hash
*
Expand Down Expand Up @@ -1145,13 +1169,15 @@ export {
flipToOtherDiv,
getHash,
getLocaleDir,
getLocaleInfo,
getLocaleName,
getTheLocaleMap,
handleCoverageChanged,
insertLocaleSpecialNote,
linkToLocale,
localeSpecialNote,
myLoad,
onLocaleMapReady,
parseHashAndUpdate,
reloadV,
replaceHash,
Expand Down
20 changes: 20 additions & 0 deletions tools/cldr-apps/js/src/esm/cldrStatus.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function on(type, callback) {
getStatusTarget().addEventListener(type, callback);
}

/**
* Fire off an event manually
* @param type the type to dispatch
*/
function dispatchEvent(type) {
return getStatusTarget().dispatchEvent(type);
}
Expand All @@ -75,6 +79,9 @@ function updateAll(status) {
if (status.phase) {
setPhase(status.phase);
}
if (status.extendedPhase) {
setExtendedPhase(status.extendedPhase);
}
if (status.specialHeader) {
setSpecialHeader(status.specialHeader);
}
Expand Down Expand Up @@ -300,6 +307,16 @@ function setPhase(p) {
phase = p;
}

let extendedPhase = "";

function getExtendedPhase() {
return extendedPhase;
}

function setExtendedPhase(p) {
extendedPhase = p;
}

/**
* Is this a "beta" phase of Survey Tool? (Boolean)
*/
Expand Down Expand Up @@ -466,6 +483,7 @@ function setAutoImportBusy(busy) {
}

export {
dispatchEvent,
getAutoImportBusy,
getContextPath,
getCurrentId,
Expand All @@ -474,6 +492,7 @@ export {
getCurrentPage,
getCurrentSection,
getCurrentSpecial,
getExtendedPhase,
getIsPhaseBeta,
getIsUnofficial,
getNewVersion,
Expand All @@ -500,6 +519,7 @@ export {
setCurrentPage,
setCurrentSection,
setCurrentSpecial,
setExtendedPhase,
setIsDisconnected,
setIsPhaseBeta,
setIsUnofficial,
Expand Down
48 changes: 37 additions & 11 deletions tools/cldr-apps/js/src/views/MainHeader.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<template>
<header id="st-header">
<a-spin v-if="!loaded" :delay="250" />
<ul>
<li>{{ stVersionPhase }}</li>
<li>
{{ stVersion }} {{ stPhase }}
<span
class="extendedException"
v-if="extendedException"
title="Note: This phase has been extended for this locale."
Copy link
Member

Choose a reason for hiding this comment

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

If TC locales are in Vetting mode, and DDL locales are still in Submission mode, then if a DDL locale is selected, will this show "Vetting (extended)" or "Submission (extended)"? I'm guessing the latter but not quite sure

Copy link
Member Author

Choose a reason for hiding this comment

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

The latter. And it doesn't have to be a DDL locale, it could be one on the extended list.

>
(extended)
</span>
</li>
<li>
<a href="#menu///"><span class="main-menu-icon">☰</span></a>
</li>
Expand Down Expand Up @@ -79,6 +89,7 @@
<script>
import * as cldrAnnounce from "../esm/cldrAnnounce.mjs";
import * as cldrCoverage from "../esm/cldrCoverage.mjs";
import * as cldrLoad from "../esm/cldrLoad.mjs";
import * as cldrMenu from "../esm/cldrMenu.mjs";
import * as cldrStatus from "../esm/cldrStatus.mjs";
import * as cldrText from "../esm/cldrText.mjs";
Expand All @@ -87,6 +98,7 @@ import * as cldrVote from "../esm/cldrVote.mjs";
export default {
data() {
return {
loaded: false,
announcementsTitle: null,
coverageLevel: null,
coverageMenu: [],
Expand All @@ -96,7 +108,10 @@ export default {
orgCoverage: null,
sessionMessage: null,
specialHeader: null,
stVersionPhase: null,
stPhase: null,
stVersion: null,
tcLocale: true,
extendedException: false,
unreadAnnouncementCount: 0,
userName: null,
voteCountMenu: null,
Expand All @@ -105,7 +120,12 @@ export default {
},

mounted() {
this.updateData();
// load after the localemap is ready
cldrLoad.onLocaleMapReady(() => {
this.updateData();
});
// reload if locale changes
cldrStatus.on("locale", () => this.updateData());
},

methods: {
Expand All @@ -114,9 +134,9 @@ export default {
* This function is called both locally, to initialize, and from other module(s), to update.
*/
updateData() {
const orgCoverage = cldrCoverage.getSurveyOrgCov(
cldrStatus.getCurrentLocale()
);
this.loaded = true;
const loc = cldrStatus.getCurrentLocale();
const orgCoverage = cldrCoverage.getSurveyOrgCov(loc);
if (orgCoverage != this.orgCoverage) {
this.orgCoverage = orgCoverage;
}
Expand Down Expand Up @@ -155,11 +175,13 @@ export default {
}
this.sessionMessage = cldrStatus.getSessionMessage();
this.specialHeader = cldrStatus.getSpecialHeader();
this.stVersionPhase =
"Survey Tool " +
cldrStatus.getNewVersion() +
" " +
cldrStatus.getPhase();
this.stVersion = "Survey Tool " + cldrStatus.getNewVersion();
this.extendedException = cldrLoad.getLocaleInfo(loc)?.extended;
if (!loc || !this.extendedException) {
this.stPhase = cldrStatus.getPhase();
} else if (this.extendedException) {
this.stPhase = cldrStatus.getExtendedPhase();
}
cldrAnnounce.getUnreadCount(this.setUnreadCount);
},

Expand Down Expand Up @@ -261,4 +283,8 @@ label {
#coverageLevel {
width: 16ch;
}

.extendedException {
background-color: yellow;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,12 @@ public JSONObject toJSONObject() throws JSONException {

@Override
public CheckCLDR.Phase getPhase() {
return SurveyMain.phase().getCPhase();
return SurveyMain.getOverallSurveyPhase().toCheckCLDRPhase();
}

@Override
public CheckCLDR.Phase getExtendedPhase() {
return SurveyMain.getOverallExtendedPhase().toCheckCLDRPhase();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.unicode.cldr.util.CldrUtility;
import org.unicode.cldr.util.PathHeader;
import org.unicode.cldr.util.StackTracker;
import org.unicode.cldr.web.SurveyMain.Phase;

/** Singleton utility class for simple(r) DB access. */
public class DBUtils {
Expand Down Expand Up @@ -963,8 +962,7 @@ public static StringBuilder appendVersionString(

/** Append a versioned string */
public static StringBuilder appendVersionString(StringBuilder sb) {
return appendVersionString(
sb, SurveyMain.getNewVersion(), SurveyMain.phase() == SurveyMain.Phase.BETA);
return appendVersionString(sb, SurveyMain.getNewVersion(), SurveyMain.isPhaseBeta());
}

private static String[] arrayOfResult(ResultSet rs) throws SQLException {
Expand Down Expand Up @@ -1380,8 +1378,7 @@ public synchronized String toString() {
"Error: don't use Table.toString before CLDRConfig is setup.");
}
defaultString =
forVersion(SurveyMain.getNewVersion(), SurveyMain.phase() == Phase.BETA)
.toString();
forVersion(SurveyMain.getNewVersion(), SurveyMain.isPhaseBeta()).toString();
}
return defaultString;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,7 @@ public Map<String, String> getNonDistinguishingAttributes() {
*/
public StatusAction getStatusAction(InputMethod inputMethod) {
// null because this is for display.
return SurveyMain.phase()
.getCPhase()
return SurveyMain.checkCLDRPhase(locale)
.getShowRowAction(this, inputMethod, getPathHeader(), userForVotelist);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,8 @@ private static JSONObject createJSONLocMap(SurveyMain sm) throws JSONException {
locale.put("highestParent", loc.getHighestNonrootParent());
locale.put("dcParent", dcParent);
locale.put("dcChild", dcChild);
locale.put("tc", SubmissionLocales.isTcLocale(loc));
locale.put("extended", SubmissionLocales.isOpenForExtendedSubmission(loc));
locale.put(
"type",
Factory.getSourceTreeType(disk.getSourceDirectoryForLocale(loc.getBaseName())));
Expand Down Expand Up @@ -2656,7 +2658,7 @@ public static void handleBulkSubmit(
final List<CheckCLDR.CheckStatus> checkResult = new ArrayList<>();
TestCache.TestResultBundle cc = stf.getTestResult(loc, DataPage.getOptions(cs, loc));
UserRegistry.User u = theirU;
CheckCLDR.Phase cPhase = CLDRConfig.getInstance().getPhase();
CheckCLDR.Phase cPhase = SurveyMain.checkCLDRPhase(loc);
Set<String> allValidPaths = stf.getPathsForFile(loc);
CLDRProgressTask progress = sm.openProgress("Bulk:" + loc, all.size());
CLDRFile cldrUnresolved = cf.getUnresolved();
Expand Down
Loading
Loading