From 4e571e0e8ec3d6f25d1ca5a6de3d3b4f2f5df571 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 10 Mar 2022 16:08:13 +0530 Subject: [PATCH] final cleanup before merging support-categories --- customize.dist/pages.js | 10 ++- scripts/translations/lint-translations.js | 4 +- www/admin/app-admin.less | 5 ++ www/admin/inner.js | 62 +++++++++-------- www/common/application_config_internal.js | 81 ++++++++++++++--------- www/support/ui.js | 4 +- 6 files changed, 98 insertions(+), 68 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 2012fc103..b438e4a58 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -107,10 +107,10 @@ define([ var customURLs = Pages.customURLs = {}; (function () { var defaultURLs = { - //imprint: '/imprint.html', // XXX cryptpad.org/default-imprint.html? - //privacy: '/privacy.html', // XXX cryptpad.org/default-privacy.html? - terms: '/terms.html', // XXX cryptpad.org/default-terms.html? - //roadmap: '/roadmap.html', // XXX cryptpad.org/default-roadmap.html? + //imprint: '/imprint.html', + //privacy: '/privacy.html', + terms: '/terms.html', + //roadmap: '/roadmap.html', source: 'https://github.com/xwiki-labs/cryptpad', }; var l = Msg._getLanguage(); @@ -133,8 +133,6 @@ define([ }); }()); - Msg.footer_source = 'Source code'; // XXX - // used for the about menu Pages.imprintLink = footLink(customURLs.imprint, 'imprint'); Pages.privacyLink = footLink(customURLs.privacy, 'privacy'); diff --git a/scripts/translations/lint-translations.js b/scripts/translations/lint-translations.js index 4eaab86b5..62ee8c60a 100644 --- a/scripts/translations/lint-translations.js +++ b/scripts/translations/lint-translations.js @@ -78,8 +78,8 @@ var processLang = function (map, lang, primary) { }); var weirdCapitalization; - s.replace(/cryptpad(\.fr)*/gi, function (brand) { - if (['CryptPad', 'cryptpad.fr'].includes(brand)) { return; } + s.replace(/cryptpad(\.fr|\.org)*/gi, function (brand) { + if (['CryptPad', 'cryptpad.fr', 'cryptpad.org'].includes(brand)) { return; } weirdCapitalization = true; }); diff --git a/www/admin/app-admin.less b/www/admin/app-admin.less index 482369a6e..4f0737cef 100644 --- a/www/admin/app-admin.less +++ b/www/admin/app-admin.less @@ -21,6 +21,11 @@ text-decoration: underline; } + .alert.alert-info.cp-admin-bigger-alert { + font-size: 16px; + } + + .cp-admin-setlimit-form, .cp-admin-broadcast-form { label { font-weight: normal !important; diff --git a/www/admin/inner.js b/www/admin/inner.js index a7688be43..1bef66b1d 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -56,6 +56,8 @@ define([ 'cp-admin-registration', 'cp-admin-email', + 'cp-admin-instance-info-notice', + 'cp-admin-name', 'cp-admin-description', 'cp-admin-jurisdiction', @@ -256,7 +258,7 @@ define([ cmd: archive ? 'ARCHIVE_DOCUMENT' : 'RESTORE_ARCHIVED_DOCUMENT', data: { id: channel, - reason: $reason.val(), // XXX + reason: $reason.val(), }, }, function (err, obj) { var e = err || (obj && obj.error); @@ -269,7 +271,8 @@ define([ UI.log(archive ? Messages.archivedFromServer : Messages.restoredFromServer); $input.val(''); $pwInput.val(''); - $reason.val(''); + // disabled because it's actually pretty annoying to re-enter this each time if you are archiving many files + //$reason.val(''); }); }); }); @@ -330,8 +333,6 @@ define([ var key = data.key; var $div = makeBlock(key); - // XXX support disabling this checkboxes in certain conditions, ie. when telemetry is off - var labelKey = 'admin_' + keyToCamlCase(key) + 'Label'; var titleKey = 'admin_' + keyToCamlCase(key) + 'Title'; var $cbox = $(UI.createCheckbox('cp-admin-' + key, @@ -375,9 +376,10 @@ define([ }, }); + // XXX remove emailButton create['email'] = function () { var key = 'email'; - var $div = makeBlock(key, true); // Msg.admin_emailHint, Msg.admin_emailTitle, Msg.admin_emailButton // XXX drop 'emailButton' + var $div = makeBlock(key, true); // Msg.admin_emailHint, Msg.admin_emailTitle var $button = $div.find('button').text(Messages.settings_save); var input = h('input', { @@ -429,12 +431,11 @@ define([ var spinner = UI.makeSpinner($(innerDiv)); $button.click(function () { - if (!$input.val()) { return; } // XXX spinner.spin(); $button.attr('disabled', 'disabled'); sFrameChan.query('Q_ADMIN_RPC', { cmd: 'ADMIN_DECREE', - data: ['SET_INSTANCE_JURISDICTION', [$input.val()]] // XXX + data: ['SET_INSTANCE_JURISDICTION', [$input.val().trim()]] }, function (e, response) { $button.removeAttr('disabled'); if (e || response.error) { @@ -454,6 +455,19 @@ define([ return $div; }; + Messages.admin_infoNotice1 = "The following fields describe your instance. Data entered will only be included in your server's telemetry if you opt in to inclusion in the list of public CryptPad instances."; // XXX + Messages.admin_infoNotice2 = "See the 'Network' tab for more details."; // XXX + + create['instance-info-notice'] = function () { + return $(h('div.cp-admin-instance-info-notice.cp-sidebarlayout-element', + h('div.alert.alert-info.cp-admin-bigger-alert', [ + Messages.admin_infoNotice1, + ' ', + Messages.admin_infoNotice2, + ]) + )); + }; + create['name'] = function () { var key = 'name'; var $div = makeBlock(key, true); @@ -463,20 +477,19 @@ define([ var input = h('input.cp-listing-info', { type: 'text', value: APP.instanceStatus.instanceName || ApiConfig.httpUnsafeOrigin || '', - placeholder: ApiConfig.httpUnsafeOrigin, //Messages.admin_namePlaceholder, // XXX + placeholder: ApiConfig.httpUnsafeOrigin, style: 'margin-bottom: 5px;', }); var $input = $(input); - var innerDiv = h('div.cp-admin-setname-form', input); // XXX fix styles + var innerDiv = h('div.cp-admin-setname-form', input); var spinner = UI.makeSpinner($(innerDiv)); $button.click(function () { - if (!$input.val()) { return; } // XXX spinner.spin(); $button.attr('disabled', 'disabled'); sFrameChan.query('Q_ADMIN_RPC', { cmd: 'ADMIN_DECREE', - data: ['SET_INSTANCE_NAME', [$input.val()]] // XXX not implemented + data: ['SET_INSTANCE_NAME', [$input.val().trim()]] }, function (e, response) { $button.removeAttr('disabled'); if (e || response.error) { @@ -498,19 +511,17 @@ define([ create['description'] = function () { var key = 'description'; - var $div = makeBlock(key, true); + var $div = makeBlock(key, true); // Msg.admin_descriptionHint - var textarea = h('textarea.cp-admin-description-text.cp-listing-info', { // XXX use something from UI elements? - placeholder: Messages.home_host || '', // XXX + var textarea = h('textarea.cp-admin-description-text.cp-listing-info', { + placeholder: Messages.home_host || '', }, APP.instanceStatus.instanceDescription || ''); var $button = $div.find('button').text(Messages.settings_save); $button.addClass('cp-listing-action'); - var innerDiv = h('div.cp-admin-setdescription-form', { - //style: 'margin-bottom: 5px', // XXX LOL NO - }, [ + var innerDiv = h('div.cp-admin-setdescription-form', [ textarea, ]); $button.before(innerDiv); @@ -519,12 +530,11 @@ define([ var spinner = UI.makeSpinner($(innerDiv)); $button.click(function () { - if (!$input.val()) { return; } // XXX spinner.spin(); $button.attr('disabled', 'disabled'); sFrameChan.query('Q_ADMIN_RPC', { cmd: 'ADMIN_DECREE', - data: ['SET_INSTANCE_DESCRIPTION', [$input.val()]] // XXX + data: ['SET_INSTANCE_DESCRIPTION', [$input.val().trim()]] }, function (e, response) { $button.removeAttr('disabled'); if (e || response.error) { @@ -1915,9 +1925,9 @@ define([ }; Messages.admin_enableDiskMeasurementsTitle = "Measure disk performance"; // XXX - Messages.admin_enableDiskMeasurementsHint = "If enabled, a JSON endpoint will be exposed under /api/profiling which keeps a running measurement of disk I/O within a configurable window. This setting can impact server performance and may reveal data you'd rather keep hidden. It is recommended that you leave it disabled unless you know what you are doing."; // XXX + Messages.admin_enableDiskMeasurementsHint = "If enabled, a JSON endpoint will be exposed under /api/profiling which keeps a running measurement of disk I/O within a configurable window (set below). This setting can impact server performance and may reveal data you'd rather keep hidden. It is recommended that you leave it disabled unless you know what you are doing."; // XXX - create['enable-disk-measurements'] = makeAdminCheckbox({ + create['enable-disk-measurements'] = makeAdminCheckbox({ // Msg.admin_enableDiskMeasurementsTitle.admin_enableDiskMeasurementsHint key: 'enable-disk-measurements', getState: function () { return APP.instanceStatus.enableProfiling; @@ -1938,10 +1948,10 @@ define([ }, }); - Messages.admin_bytesWrittenTitle = "Disk performance measurement window"; + Messages.admin_bytesWrittenTitle = "Disk performance measurement window"; // XXX Messages.admin_bytesWrittenHint = "If you have enabled disk performance measurements then the duration of the window can be configured below."; // XXX Messages.admin_bytesWrittenDuration = "Duration of the window in milliseconds: {0}"; // XXX - Messages.admin_defaultDuration = "admin_defaultDuration"; // XXX + //Messages.admin_defaultDuration = "admin_defaultDuration"; // XXX Messages.admin_setDuration = "Set duration"; // XXX var isPositiveInteger = function (n) { @@ -1985,7 +1995,7 @@ define([ UI.warn(Messages.error); return void console.error(e, response); } - $div.find('.cp-admin-bytes-written-duration').text(Messages._getKey('admin_limit', [d])); + $div.find('.cp-admin-bytes-written-duration').text(Messages._getKey('admin_bytesWrittenDuration', [d])); }); }); @@ -2037,7 +2047,6 @@ define([ }, }); - // XXX disable this checkbox if server telemetry is disabled? create['list-my-instance'] = makeAdminCheckbox({ // Messages.admin_listMyInstanceTitle.admin_listMyInstanceHint.admin_listMyInstanceLabel key: 'list-my-instance', getState: function () { @@ -2274,6 +2283,7 @@ define([ APP.instanceStatus = data[0]; console.log("Status", APP.instanceStatus); +/* var isListed = Boolean(APP.instanceStatus.listMyInstance); var $actions = $('.cp-listing-action'); var $fields = $('.cp-listing-info'); @@ -2285,7 +2295,7 @@ define([ $actions.attr('disabled', 'disabled'); $fields.attr('disabled', 'disabled'); } - +*/ cb(); }); }; diff --git a/www/common/application_config_internal.js b/www/common/application_config_internal.js index 1943cbd29..0dde18da3 100644 --- a/www/common/application_config_internal.js +++ b/www/common/application_config_internal.js @@ -48,48 +48,63 @@ define(function() { */ //AppConfig.availableLanguages = ['en', 'fr', 'de']; + /* + * AppConfig.imprint, AppConfig.privacy, AppConfig.terms, AppConfig.source, and AppConfig.roadmap + * define values used in at least one of the static pages' footer or the 'About CryptPad' menu. + * + * They can each be configured in one of three manners: + * + * 1. set their value to `false` to cause them not to be displayed, even if a default value exists + * example: + * AppConfig.privacy = false; + * 2. set their value to `true` to use the default value if it exists. + * example: + * AppConfig.privacy = true; + * 3. set their value to an object which maps language codes or a default setting to the relevant URL (as a string) + * example: + * AppConfig.privacy = { + * "default": 'https://example.com/privacy.html', + * "en": 'https://example.com/privacy.en.html', // in case English is not your default language + * "fr": 'https://example.com/privacy.fr.html', // another language + * "de": 'https://example.com/privacy.de.html', // you get the idea? + * }; + * + */ + /* You can display a link to the imprint (legal notice) of your website in the static pages - * footer. To do so, you can either set the following value to `true` and create an imprint.html page - * in the `customize` directory. You can also set it to an absolute URL if your imprint page already exists. + * footer. Since this is different for each individual or organization there is + * no default value. + * + * See the comments above for a description of possible configurations. */ AppConfig.imprint = false; - // AppConfig.imprint = true; - // AppConfig.imprint = 'https://xwiki.com/en/company/legal-notice'; /* You can display a link to your own privacy policy in the static pages footer. - * To do so, set the following value to the absolute URL of your privacy policy. + * Since this is different for each individual or organization there is no default value. + * See the comments above for a description of possible configurations. */ - // AppConfig.privacy = 'https://xwiki.com/en/company/PrivacyPolicy'; + AppConfig.privacy = false; - /* We (the project's developers) include the ability to display a 'Roadmap' in static pages footer. - * This is disabled by default. - * We use this to publish the project's development roadmap, but you can use it however you like. - * To do so, set the following value to an absolute URL. + /* You can display a link to your instances's terms of service in the static pages footer. + * Since this is different for each individual or organization there is no default value. + * + * See the comments above for a description of possible configurations. */ - //AppConfig.roadmap = 'https://cryptpad.fr/kanban/#/2/kanban/view/PLM0C3tFWvYhd+EPzXrbT+NxB76Z5DtZhAA5W5hG9wo/'; - - // XXX -/* -AppConfig.imprint, AppConfig.privacy, AppConfig.terms, AppConfig.source, and AppConfig.roadmap can each be configured in one of three manners: - -// to prevent the display of privacy policy entirely: -AppConfig.privacy = false; - -// to display the default privacy policy: -AppConfig.privacy = true; - -// to display translated versions of the privacy policy depending on -// the user's configured or inferred language -AppConfig.privacy = { - 'default': '...', // displayed if there is no exact match - 'en': '/privacy.en.html', - 'fr': '/privacy.fr.html', -}; - - -*/ - AppConfig.source = 'https://github.com/xwiki-labs/cryptpad/'; // XXX + AppConfig.terms = false; + + /* The terms of CryptPad's license require that its source code be made available + * to anyone who uses the software. If you have not made any modifications to the platform + * then it is sufficient to leave this as-is. If you have made changes, customize + * this value to a software repository which includes the source code including your modifications. + * + * See the comments above for a description of possible configurations. + */ + AppConfig.source = true; + /* If you wish to communicate your organization's roadmap to your users you may use the setting below. + * Since this is different for each individual or organization there is no default value. + */ + AppConfig.roadmap = false; /* Cryptpad apps use a common API to display notifications to users * by default, notifications are hidden after 5 seconds diff --git a/www/support/ui.js b/www/support/ui.js index b1ee309a6..ac935cc29 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -147,6 +147,7 @@ Messages.support_formCategoryError = "Please select a ticket category from the d var makeCategoryDropdown = function (ctx, container, onChange, all) { var categories = [ + // Msg.support_cat_data is left included because old tickets may still use it 'account', // Msg.support_cat_account 'drives', // Msg.support_cat_drives 'document', // Msg.support_cat_document, @@ -213,7 +214,8 @@ Messages.support_formCategoryError = "Please select a ticket category from the d makeCategoryDropdown(ctx, catContainer, function (key) { $(category).val(key); - console.log(key); + //console.log(key); + // Msg.support_warning_abuse.support_warning_account.support_warning_bug.support_warning_document.support_warning_drives.support_warning_other var warning = Messages['support_warning_' + key] || ''; var warningLink = warningLinks[key]; if (!warningLink) {