From 5f502b43db4282b56075f765c64fac7109577218 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 22 Apr 2024 19:34:25 -0500 Subject: [PATCH 1/7] CLDR-16499 CLA for SurveyTool users - new claSigned bit must be true to allow writing - store CLAs as JSON blobs in user prefs - API to read/update/revoke CLA - static list of signatory orgs - new menu item for CLA Other improvements/ - store JSON in the user settings data - load .md file via webpack - display markdown using marked (same as the error/wikimedia abstracts) - fix the client so that it doesn't hit the OpenAPI spec multiple times --- tools/cldr-apps/js/src/esm/cldrClient.mjs | 22 +- tools/cldr-apps/js/src/esm/cldrComponents.mjs | 2 + tools/cldr-apps/js/src/esm/cldrNotify.mjs | 4 +- tools/cldr-apps/js/src/esm/cldrText.mjs | 1 + tools/cldr-apps/js/src/esm/cldrVueMap.mjs | 2 + tools/cldr-apps/js/src/md/cla.md | 25 ++ tools/cldr-apps/js/src/views/MainHeader.vue | 20 +- tools/cldr-apps/js/src/views/MainMenu.vue | 1 + tools/cldr-apps/js/src/views/SignCla.vue | 233 ++++++++++++++++++ tools/cldr-apps/js/webpack.config.js | 4 + .../org/unicode/cldr/web/UserRegistry.java | 92 ++++++- .../org/unicode/cldr/web/UserSettings.java | 14 ++ .../org/unicode/cldr/web/api/UserAPI.java | 87 +++++++ .../org/unicode/cldr/web/api/VoteAPI.java | 10 +- 14 files changed, 505 insertions(+), 12 deletions(-) create mode 100644 tools/cldr-apps/js/src/md/cla.md create mode 100644 tools/cldr-apps/js/src/views/SignCla.vue diff --git a/tools/cldr-apps/js/src/esm/cldrClient.mjs b/tools/cldr-apps/js/src/esm/cldrClient.mjs index 6bfce485392..d1404211f78 100644 --- a/tools/cldr-apps/js/src/esm/cldrClient.mjs +++ b/tools/cldr-apps/js/src/esm/cldrClient.mjs @@ -3,6 +3,17 @@ import { getSessionId } from "./cldrStatus.mjs"; import { SURVEY_TOOL_SESSION_HEADER } from "./cldrAjax.mjs"; const OAS3_ROOT = "/openapi"; // Path to the 'openapi' (sibling to cldr-apps). Needs to be a host-relative URL. +let client = null; + +function makeClient() { + return SwaggerClient(OAS3_ROOT, { + requestInterceptor: (obj) => { + // add the session header to each request + obj.headers[SURVEY_TOOL_SESSION_HEADER] = getSessionId(); + return obj; + }, + }); +} /** * Create a promise to a swagger client for ST operations. @@ -16,13 +27,10 @@ const OAS3_ROOT = "/openapi"; // Path to the 'openapi' (sibling to cldr-apps). N * @returns Promise */ function getClient() { - return new SwaggerClient(OAS3_ROOT, { - requestInterceptor: (obj) => { - // add the session header to each request - obj.headers[SURVEY_TOOL_SESSION_HEADER] = getSessionId(); - return obj; - }, - }); + if (!client) { + client = makeClient(); + } + return client; } export { getClient }; diff --git a/tools/cldr-apps/js/src/esm/cldrComponents.mjs b/tools/cldr-apps/js/src/esm/cldrComponents.mjs index 44c2185a97c..27544aee45d 100644 --- a/tools/cldr-apps/js/src/esm/cldrComponents.mjs +++ b/tools/cldr-apps/js/src/esm/cldrComponents.mjs @@ -12,6 +12,7 @@ import CldrValue from "../views/CldrValue.vue"; import LoginButton from "../views/LoginButton.vue"; import ReportResponse from "../views/ReportResponse.vue"; import SearchButton from "../views/SearchButton.vue"; +import SignCla from "../views/SignCla.vue"; // 3rd party component(s) @@ -80,6 +81,7 @@ function setup(app) { app.component("cldr-report-response", ReportResponse); app.component("cldr-searchbutton", SearchButton); app.component("cldr-value", CldrValue); + app.component("cldr-cla", SignCla); } export { setup }; diff --git a/tools/cldr-apps/js/src/esm/cldrNotify.mjs b/tools/cldr-apps/js/src/esm/cldrNotify.mjs index f622926d3c9..8c6e0a3d86f 100644 --- a/tools/cldr-apps/js/src/esm/cldrNotify.mjs +++ b/tools/cldr-apps/js/src/esm/cldrNotify.mjs @@ -36,12 +36,14 @@ const NO_TIMEOUT = 0; * * @param {String} message the title, displayed at the top * @param {String} description the more detailed description + * @param {Function} onClick optional function called when clicking */ -function open(message, description) { +function open(message, description, onClick) { notification.open({ message: message, description: description, duration: MEDIUM_DURATION, + onClick, }); } diff --git a/tools/cldr-apps/js/src/esm/cldrText.mjs b/tools/cldr-apps/js/src/esm/cldrText.mjs index e4de7986805..7b855accef1 100644 --- a/tools/cldr-apps/js/src/esm/cldrText.mjs +++ b/tools/cldr-apps/js/src/esm/cldrText.mjs @@ -472,6 +472,7 @@ const strings = { special_add_user: "Add a Survey Tool user", special_auto_import: "Import Old Winning Votes", special_bulk_close_posts: "Bulk Close Posts", + special_cla: "Contributor License Agreement", special_createAndLogin: "Create and Login", special_default: "Missing Page", special_dashboard: "Dashboard", diff --git a/tools/cldr-apps/js/src/esm/cldrVueMap.mjs b/tools/cldr-apps/js/src/esm/cldrVueMap.mjs index 5254489a8de..b7f9a3e9a51 100644 --- a/tools/cldr-apps/js/src/esm/cldrVueMap.mjs +++ b/tools/cldr-apps/js/src/esm/cldrVueMap.mjs @@ -7,6 +7,7 @@ import GeneralInfo from "../views/GeneralInfo.vue"; import LockAccount from "../views/LockAccount.vue"; import LookUp from "../views/LookUp.vue"; import MainMenu from "../views/MainMenu.vue"; +import SignCla from "../views/SignCla.vue"; import TestPanel from "../views/TestPanel.vue"; import TransferVotes from "../views/TransferVotes.vue"; import UnknownPanel from "../views/UnknownPanel.vue"; @@ -35,6 +36,7 @@ const specialToComponentMap = { upload: UploadPanel, vetting_participation2: VettingParticipation2, vsummary: VettingSummary, + cla: SignCla, // If no match, end up here default: UnknownPanel, }; diff --git a/tools/cldr-apps/js/src/md/cla.md b/tools/cldr-apps/js/src/md/cla.md new file mode 100644 index 00000000000..24b5747b9f0 --- /dev/null +++ b/tools/cldr-apps/js/src/md/cla.md @@ -0,0 +1,25 @@ +Thank you for your interest in The Unicode Consortium, a nonprofit California corporation incorporated as Unicode, Inc. (hereafter "the Consortium"). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Consortium must have a Contributor License Agreement (CLA) on file that has been executed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Consortium and its users; it does not change your rights to use your own Contributions for any other purpose. Read this document carefully before signing and keep a copy for your records. + +You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Consortium. Except for the license granted herein to the Consortium and recipients of products distributed by the Consortium, You reserve all right, title, and interest in and to Your Contributions. + +1. Definitions. + +- "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with the Consortium. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +- "Contribution" shall mean the specifications, standards, software, code, data and databases, documentation, or any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the Consortium for inclusion in, or documentation of, any of the products owned or managed by the Consortium (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Consortium or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Consortium for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution." + +2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to the Consortium and to recipients of products distributed by the Consortium a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works. + +3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to the Consortium and to recipients of products distributed by the Consortium a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed. + +4. You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Consortium, or that your employer has executed a separate Corporate CLA with the Consortium. + +5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions. + +6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + +7. Should You wish to submit work that is not Your original creation, You may submit it to the Consortium separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]". + +8. You agree to notify the Consortium of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect. + +– end – diff --git a/tools/cldr-apps/js/src/views/MainHeader.vue b/tools/cldr-apps/js/src/views/MainHeader.vue index 3a8d4a7532c..03b8f1dfe13 100644 --- a/tools/cldr-apps/js/src/views/MainHeader.vue +++ b/tools/cldr-apps/js/src/views/MainHeader.vue @@ -11,7 +11,7 @@ {{ unreadAnnouncementCount }} -
  • +
  • -
  • +