Bug 1830560 - ESMify our enterprise policy schema. r=aleca
Differential Revision: https://phabricator.services.mozilla.com/D176773 --HG-- rename : mail/components/enterprisepolicies/schemas/schema.jsm => mail/components/enterprisepolicies/schemas/schema.sys.mjs extra : moz-landing-system : lando
This commit is contained in:
Родитель
592e80126b
Коммит
cbb6191d49
|
@ -50,8 +50,8 @@ mail/branding/nightly/pref/thunderbird-branding.js
|
|||
mail/branding/thunderbird/pref/thunderbird-branding.js
|
||||
# This file is split into two in order to keep it as a valid json file
|
||||
# for documentation purposes (policies.json) but to be accessed by the
|
||||
# code as a .jsm (schema.jsm)
|
||||
mail/components/enterprisepolicies/schemas/schema.jsm
|
||||
# code as a JS module (schema.sys.mjs)
|
||||
mail/components/enterprisepolicies/schemas/schema.sys.mjs
|
||||
mail/components/im/all-im.js
|
||||
mail/extensions/am-e2e/prefs/e2e-prefs.js
|
||||
mail/locales/en-US/all-l10n.js
|
||||
|
|
|
@ -19,8 +19,8 @@ mailnews/mailnews.js
|
|||
|
||||
# This file is split into two in order to keep it as a valid json file
|
||||
# for documentation purposes (policies.json) but to be accessed by the
|
||||
# code as a .jsm (schema.jsm).
|
||||
mail/components/enterprisepolicies/schemas/schema.jsm
|
||||
# code as a JS module (schema.sys.mjs).
|
||||
mail/components/enterprisepolicies/schemas/schema.sys.mjs
|
||||
|
||||
# Third-party code.
|
||||
calendar/base/modules/Ical.jsm
|
||||
|
|
|
@ -8,8 +8,9 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
|
|||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
schema: "resource:///modules/policies/schema.jsm",
|
||||
const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
schema: "resource:///modules/policies/schema.sys.mjs",
|
||||
});
|
||||
|
||||
function col(text, className) {
|
||||
|
@ -62,7 +63,7 @@ function generateActivePolicies(data) {
|
|||
for (let policyName in data) {
|
||||
const color_class = ++policy_count % 2 === 0 ? "even" : "odd";
|
||||
|
||||
if (schema.properties[policyName].type == "array") {
|
||||
if (lazy.schema.properties[policyName].type == "array") {
|
||||
for (let count in data[policyName]) {
|
||||
let isFirstRow = count == 0;
|
||||
let isLastRow = count == data[policyName].length - 1;
|
||||
|
@ -78,7 +79,7 @@ function generateActivePolicies(data) {
|
|||
data[policyName].length > 1
|
||||
);
|
||||
}
|
||||
} else if (schema.properties[policyName].type == "object") {
|
||||
} else if (lazy.schema.properties[policyName].type == "object") {
|
||||
let count = 0;
|
||||
for (let obj in data[policyName]) {
|
||||
let isFirstRow = count == 0;
|
||||
|
@ -277,7 +278,7 @@ function generateDocumentation() {
|
|||
Certificates: "CertificatesDescription",
|
||||
};
|
||||
|
||||
for (let policyName in schema.properties) {
|
||||
for (let policyName in lazy.schema.properties) {
|
||||
let main_tbody = document.createElement("tbody");
|
||||
main_tbody.classList.add("collapsible");
|
||||
main_tbody.addEventListener("click", function() {
|
||||
|
@ -295,32 +296,35 @@ function generateDocumentation() {
|
|||
sec_tbody.classList.add("content");
|
||||
sec_tbody.classList.add("content-style");
|
||||
let schema_row = document.createElement("tr");
|
||||
if (schema.properties[policyName].properties) {
|
||||
if (lazy.schema.properties[policyName].properties) {
|
||||
let column = col(
|
||||
JSON.stringify(schema.properties[policyName].properties, null, 1),
|
||||
JSON.stringify(lazy.schema.properties[policyName].properties, null, 1),
|
||||
"schema"
|
||||
);
|
||||
column.colSpan = "2";
|
||||
schema_row.appendChild(column);
|
||||
sec_tbody.appendChild(schema_row);
|
||||
} else if (schema.properties[policyName].items) {
|
||||
} else if (lazy.schema.properties[policyName].items) {
|
||||
let column = col(
|
||||
JSON.stringify(schema.properties[policyName], null, 1),
|
||||
JSON.stringify(lazy.schema.properties[policyName], null, 1),
|
||||
"schema"
|
||||
);
|
||||
column.colSpan = "2";
|
||||
schema_row.appendChild(column);
|
||||
sec_tbody.appendChild(schema_row);
|
||||
} else {
|
||||
let column = col("type: " + schema.properties[policyName].type, "schema");
|
||||
let column = col(
|
||||
"type: " + lazy.schema.properties[policyName].type,
|
||||
"schema"
|
||||
);
|
||||
column.colSpan = "2";
|
||||
schema_row.appendChild(column);
|
||||
sec_tbody.appendChild(schema_row);
|
||||
if (schema.properties[policyName].enum) {
|
||||
if (lazy.schema.properties[policyName].enum) {
|
||||
let enum_row = document.createElement("tr");
|
||||
column = col(
|
||||
"enum: " +
|
||||
JSON.stringify(schema.properties[policyName].enum, null, 1),
|
||||
JSON.stringify(lazy.schema.properties[policyName].enum, null, 1),
|
||||
"schema"
|
||||
);
|
||||
column.colSpan = "2";
|
||||
|
|
|
@ -8,5 +8,5 @@ with Files("**"):
|
|||
BUG_COMPONENT = ("Thunderbird", "OS Integration")
|
||||
|
||||
EXTRA_PP_JS_MODULES.policies += [
|
||||
"schema.jsm",
|
||||
"schema.sys.mjs",
|
||||
]
|
||||
|
|
|
@ -2,9 +2,15 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const EXPORTED_SYMBOLS = ["schema"];
|
||||
|
||||
var schema =
|
||||
const initialSchema =
|
||||
#include policies-schema.json
|
||||
|
||||
export let schema = initialSchema;
|
||||
|
||||
export function modifySchemaForTests(customSchema) {
|
||||
if (customSchema) {
|
||||
schema = customSchema;
|
||||
} else {
|
||||
schema = initialSchema;
|
||||
}
|
||||
}
|
|
@ -19,8 +19,8 @@ function checkArrayIsSorted(array, msg) {
|
|||
}
|
||||
|
||||
add_task(async function test_policies_sorted() {
|
||||
let { schema } = ChromeUtils.import(
|
||||
"resource:///modules/policies/schema.jsm"
|
||||
let { schema } = ChromeUtils.importESModule(
|
||||
"resource:///modules/policies/schema.sys.mjs"
|
||||
);
|
||||
let { Policies } = ChromeUtils.importESModule(
|
||||
"resource:///modules/policies/Policies.sys.mjs"
|
||||
|
@ -37,8 +37,8 @@ add_task(async function test_policies_sorted() {
|
|||
});
|
||||
|
||||
add_task(async function check_naming_conventions() {
|
||||
let { schema } = ChromeUtils.import(
|
||||
"resource:///modules/policies/schema.jsm"
|
||||
let { schema } = ChromeUtils.importESModule(
|
||||
"resource:///modules/policies/schema.sys.mjs"
|
||||
);
|
||||
equal(
|
||||
Object.keys(schema.properties).some(key => key.includes("__")),
|
||||
|
|
|
@ -56,7 +56,7 @@ excluded_from_imports_prefix = list(
|
|||
"mail/app/profile/all-thunderbird.js",
|
||||
"mail/branding/thunderbird/pref/thunderbird-branding.js",
|
||||
"mail/components/compose/composer.js",
|
||||
"mail/components/enterprisepolicies/schemas/schema.jsm",
|
||||
"mail/components/enterprisepolicies/schemas/schema.sys.mjs",
|
||||
"mail/locales/en-US/all-l10n.js",
|
||||
"mail/extensions/am-e2e/prefs/e2e-prefs.js",
|
||||
"mailnews/extensions/mdn/mdn.js",
|
||||
|
|
|
@ -415,7 +415,6 @@
|
|||
"resource:///modules/matrixTextForEvent.jsm": "comm/chat/protocols/matrix/matrixTextForEvent.jsm",
|
||||
"resource:///modules/mimeParser.jsm": "comm/mailnews/mime/src/mimeParser.jsm",
|
||||
"resource:///modules/odnoklassniki.jsm": "comm/chat/protocols/odnoklassniki/odnoklassniki.jsm",
|
||||
"resource:///modules/policies/schema.jsm": "comm/mail/components/enterprisepolicies/schemas/schema.jsm",
|
||||
"resource:///modules/sax.jsm": "comm/chat/protocols/xmpp/sax.jsm",
|
||||
"resource:///modules/socket.jsm": "comm/chat/modules/socket.jsm",
|
||||
"resource:///modules/twitter.jsm": "comm/chat/protocols/twitter/twitter.jsm",
|
||||
|
|
Загрузка…
Ссылка в новой задаче