From 9d476ce9cdd0174116feda3d6d658cb3707b9bff Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 5 Jul 2019 17:06:02 +0200 Subject: [PATCH 01/27] Fix error in the console --- www/common/outer/mailbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index 08e7b9351..517bea017 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -341,8 +341,8 @@ proxy.mailboxes = { var req = ctx.req[txid]; var type = parsed[0]; var _msg = parsed[2]; - var box = req.box; if (!req) { return; } + var box = req.box; if (type === 'HISTORY_RANGE') { if (!Array.isArray(_msg)) { return; } From 8be6c84e2f5aebbf58384b5b6b440e11c12e1d64 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 8 Jul 2019 12:10:57 +0200 Subject: [PATCH 02/27] guard against null elements in the drive --- www/common/outer/userObject.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/www/common/outer/userObject.js b/www/common/outer/userObject.js index e12883eb5..3aab20a1d 100644 --- a/www/common/outer/userObject.js +++ b/www/common/outer/userObject.js @@ -506,8 +506,14 @@ define([ var fixRoot = function (elem) { if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; } var element = elem || files[ROOT]; + if (!element) { return console.error("Invalid element in root"); var nbMetadataFolders = 0; for (var el in element) { + if (element[el] === null) { + console.error('element[%s] is null', el); + delete element[el]; + continue; + } if (exp.isFolderData(element[el])) { if (nbMetadataFolders !== 0) { debug("Multiple metadata files in folder"); From 5f5cd1e04504f9b4c6b007ae97558a55046f8158 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 8 Jul 2019 12:12:42 +0200 Subject: [PATCH 03/27] oups, add a missing closing brace --- www/common/outer/userObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/outer/userObject.js b/www/common/outer/userObject.js index 3aab20a1d..4f235366a 100644 --- a/www/common/outer/userObject.js +++ b/www/common/outer/userObject.js @@ -506,7 +506,7 @@ define([ var fixRoot = function (elem) { if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; } var element = elem || files[ROOT]; - if (!element) { return console.error("Invalid element in root"); + if (!element) { return console.error("Invalid element in root"); } var nbMetadataFolders = 0; for (var el in element) { if (element[el] === null) { From 677a1594a5561e022733076beebebbdbc4ca69ee Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 10 Jul 2019 10:25:40 +0200 Subject: [PATCH 04/27] wrap long lines in the support page --- customize.dist/src/less2/include/support.less | 1 + 1 file changed, 1 insertion(+) diff --git a/customize.dist/src/less2/include/support.less b/customize.dist/src/less2/include/support.less index 56dcccd8f..0a352ec32 100644 --- a/customize.dist/src/less2/include/support.less +++ b/customize.dist/src/less2/include/support.less @@ -44,6 +44,7 @@ } pre { margin-bottom: 0; + white-space: pre-wrap; &.cp-support-message-content { margin-top: 10px; margin-bottom: 10px; From 9f2355e95b8f686bfa17b9f15ce72d6778d3ff20 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 10 Jul 2019 13:34:55 +0200 Subject: [PATCH 05/27] Fix scrollbar issue in spreadsheets --- www/common/onlyoffice/app-oo.less | 1 + 1 file changed, 1 insertion(+) diff --git a/www/common/onlyoffice/app-oo.less b/www/common/onlyoffice/app-oo.less index 60510914d..c7bd64e01 100644 --- a/www/common/onlyoffice/app-oo.less +++ b/www/common/onlyoffice/app-oo.less @@ -44,6 +44,7 @@ body.cp-app-sheet, body.cp-app-oodoc, body.cp-app-ooslide { height: 100%; background-color: lightgrey; display: flex; + min-height: 0; } #cp-app-oo-editor { flex: 1; From 44e57619d024b937f7c482b74d65029f9f6bc273 Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 10 Jul 2019 12:32:38 +0000 Subject: [PATCH 06/27] Translated using Weblate (Russian) Currently translated at 40.3% (410 of 1017 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/ru/ --- www/common/translations/messages.ru.json | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.ru.json b/www/common/translations/messages.ru.json index e8f61dfe2..98fe7eb64 100644 --- a/www/common/translations/messages.ru.json +++ b/www/common/translations/messages.ru.json @@ -389,5 +389,27 @@ "fc_empty": "Удалить корзину", "fc_prop": "Свойства", "fc_hashtag": "Теги", - "fc_sizeInKilobytes": "Размер в килобайтах" + "fc_sizeInKilobytes": "Размер в килобайтах", + "poll_title": "Приватный выбор даты", + "fm_moveNestedSF": "Нельзя помещать одну общую папку в другую. Папка {0} не была перемещена.", + "fc_color": "Изменить цвет", + "fc_expandAll": "Расширить все", + "fc_collapseAll": "Скрыть все", + "fc_remove": "Удалить из вашего CryptDrive", + "fo_moveUnsortedError": "Вы не можете переместить папку в список черновиков", + "fo_existingNameError": "Это имя уже используется в данной директории. Пожалуйста выберите другое.", + "fo_unableToRestore": "Невозможно восстановить этот файл в исходное местоположение. Вы можете попытаться переместить его в другое место.", + "login_login": "Войти", + "login_makeAPad": "Создать анонимный пэд", + "login_nologin": "Просмотреть локальные пэды", + "login_register": "Зарегистрироваться", + "logoutButton": "Выйти", + "settingsButton": "Настройки", + "login_username": "Имя пользователя", + "login_password": "Пароль", + "login_confirm": "Подтвердите ваш пароль", + "login_remember": "Запомнить меня", + "login_hashing": "Ваш пароль хэшируется, это может занять некое время.", + "login_hello": "Привет {0},", + "login_helloNoName": "Привет," } From 1143ee3974e1e0fc998b0d0c1cb7d6f6d4d871ff Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 11 Jul 2019 09:55:54 +0200 Subject: [PATCH 07/27] fix typeError when subscribing to mailboxes from the profile page --- www/profile/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/profile/inner.js b/www/profile/inner.js index 8f589107f..75f1022f8 100644 --- a/www/profile/inner.js +++ b/www/profile/inner.js @@ -559,7 +559,7 @@ define([ lm.proxy.on('ready', function () { updateValues(lm.proxy); UI.removeLoadingScreen(); - common.mailbox.subscribe({ + common.mailbox.subscribe(["notifications"], { onMessage: function () { refreshFriendRequest(lm.proxy); }, From ffd630455f404d5539d10ebda86ecde819d9b034 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 10 Jul 2019 13:34:55 +0200 Subject: [PATCH 08/27] Fix scrollbar issue in spreadsheets --- www/common/onlyoffice/app-oo.less | 1 + 1 file changed, 1 insertion(+) diff --git a/www/common/onlyoffice/app-oo.less b/www/common/onlyoffice/app-oo.less index 60510914d..c7bd64e01 100644 --- a/www/common/onlyoffice/app-oo.less +++ b/www/common/onlyoffice/app-oo.less @@ -44,6 +44,7 @@ body.cp-app-sheet, body.cp-app-oodoc, body.cp-app-ooslide { height: 100%; background-color: lightgrey; display: flex; + min-height: 0; } #cp-app-oo-editor { flex: 1; From b1f0ca366413a6e11037c8c456ef4471f67ed14a Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 11 Jul 2019 10:27:08 +0200 Subject: [PATCH 09/27] update jshint --- package-lock.json | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 30b43f03e..bb7701b84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cryptpad", - "version": "2.23.0", + "version": "2.25.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -573,16 +573,16 @@ "dev": true }, "jshint": { - "version": "2.9.7", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.7.tgz", - "integrity": "sha512-Q8XN38hGsVQhdlM+4gd1Xl7OB1VieSuCJf+fEJjpo59JH99bVJhXRXAh26qQ15wfdd1VPMuDWNeSWoNl53T4YA==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", + "integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==", "dev": true, "requires": { "cli": "~1.0.0", "console-browserify": "1.1.x", "exit": "0.1.x", "htmlparser2": "3.8.x", - "lodash": "~4.17.10", + "lodash": "~4.17.11", "minimatch": "~3.0.2", "shelljs": "0.3.x", "strip-json-comments": "1.0.x" @@ -697,9 +697,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true }, "lodash.clonedeep": { diff --git a/package.json b/package.json index 1a6462d84..585e8b8fc 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "flow-bin": "^0.59.0", - "jshint": "~2.9.1", + "jshint": "^2.10.2", "less": "2.7.1", "lesshint": "^4.5.0", "selenium-webdriver": "^3.6.0" From 8193a1997c70a6a6bf266478fdf83a7a080ff447 Mon Sep 17 00:00:00 2001 From: ansuz Date: Sat, 13 Jul 2019 10:25:22 +0200 Subject: [PATCH 10/27] handle files without extensions when importing into the code editor --- www/code/inner.js | 10 +++++++++- www/common/sframe-common-codemirror.js | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/www/code/inner.js b/www/code/inner.js index 9e4d0a207..b061e36fa 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -363,7 +363,15 @@ define([ }); framework.setFileExporter(CodeMirror.getContentExtension, CodeMirror.fileExporter); - framework.setFileImporter({}, CodeMirror.fileImporter); + framework.setFileImporter({}, function () { + /* setFileImporter currently takes a function with the following signature: + (content, file) => {} + I used 'apply' with 'arguments' to avoid breaking things if this API ever changes. + */ + var ret = CodeMirror.fileImporter.apply(null, Array.prototype.slice.call(arguments)); + previewPane.modeChange(ret.mode); + return ret; + }); framework.setNormalizer(function (c) { return { diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index ebf7d752e..8a0e2de63 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -323,7 +323,7 @@ define([ var mode; if (!mime) { var ext = /.+\.([^.]+)$/.exec(file.name); - if (ext[1]) { + if (ext && ext[1]) { mode = CMeditor.findModeByExtension(ext[1]); mode = mode && mode.mode || null; } @@ -339,7 +339,8 @@ define([ exp.setMode('text'); $toolbarContainer.find('#language-mode').val('text'); } - return { content: content }; + // return the mode so that the code editor can decide how to display the new content + return { content: content, mode: mode }; }; exp.setValueAndCursor = function (oldDoc, remoteDoc) { From 5d4fba04ddad66eb9ba1a8284bd21570cdfb3b60 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 16 Jul 2019 11:17:12 +0200 Subject: [PATCH 11/27] update lodash versions --- package-lock.json | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 30b43f03e..a5d8ef41b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cryptpad", - "version": "2.23.0", + "version": "2.25.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -697,9 +697,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true }, "lodash.clonedeep": { @@ -709,10 +709,9 @@ "dev": true }, "lodash.merge": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", - "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==", - "dev": true + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, "lodash.sortby": { "version": "4.7.0", From f5c8d8566dfe47f9f89f1ed40d0960a02a94b3ea Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 16 Jul 2019 11:24:29 +0200 Subject: [PATCH 12/27] Fix pads and files not displayed in the drive when logging in --- www/drive/inner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index f393cac3f..f69c36060 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -512,13 +512,14 @@ define([ // Tags used: display Tags category if (Object.keys(manager.getTagsList()).length) { displayedCategories.push(TAGS); } - var virtualCategories = [SEARCH, RECENT, OWNED, TAGS, SHARED_FOLDER]; + var virtualCategories = [SEARCH, RECENT, OWNED, TAGS]; if (!APP.loggedIn) { $tree.hide(); if (APP.newSharedFolder) { // ANON_SHARED_FOLDER displayedCategories = [SHARED_FOLDER]; + virtualCategories.push(SHARED_FOLDER); currentPath = [SHARED_FOLDER, ROOT]; } else { displayedCategories = [FILES_DATA]; From f111be72e6de21f1ec2ada116244e11e9f9b52c2 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 16 Jul 2019 11:58:54 +0200 Subject: [PATCH 13/27] Clean the support UI code --- www/admin/inner.js | 7 ++++--- www/support/inner.js | 11 +++++----- www/support/ui.js | 49 ++++++++++++++++++++++++++++++++------------ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/www/admin/inner.js b/www/admin/inner.js index e2edb9ad5..4c335dd12 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -199,13 +199,13 @@ define([ // A ticket has been closed by the admins... if (!$ticket.length) { return; } $ticket.addClass('cp-support-list-closed'); - $ticket.append(Support.makeCloseMessage(common, content, hash)); + $ticket.append(APP.support.makeCloseMessage(content, hash)); return; } if (msg.type !== 'TICKET') { return; } if (!$ticket.length) { - $ticket = Support.makeTicket($div, common, content, function () { + $ticket = APP.support.makeTicket($div, content, function () { var error = false; hashesById[id].forEach(function (d) { common.mailbox.dismiss(d, function (err) { @@ -218,7 +218,7 @@ define([ if (!error) { $ticket.remove(); } }); } - $ticket.append(Support.makeMessage(common, content, hash, true)); + $ticket.append(APP.support.makeMessage(content, hash)); } }); return $div; @@ -349,6 +349,7 @@ define([ APP.privateKey = privateData.supportPrivateKey; APP.origin = privateData.origin; APP.readOnly = privateData.readOnly; + APP.support = Support.create(common, true); // Content var $rightside = APP.$rightside; diff --git a/www/support/inner.js b/www/support/inner.js index 4de6fcb04..ded97b272 100644 --- a/www/support/inner.js +++ b/www/support/inner.js @@ -107,13 +107,13 @@ define([ // A ticket has been closed by the admins... if (!$ticket.length) { return; } $ticket.addClass('cp-support-list-closed'); - $ticket.append(Support.makeCloseMessage(common, content, hash)); + $ticket.append(APP.support.makeCloseMessage(content, hash)); return; } if (msg.type !== 'TICKET') { return; } if (!$ticket.length) { - $ticket = Support.makeTicket($div, common, content, function () { + $ticket = APP.support.makeTicket($div, content, function () { var error = false; hashesById[id].forEach(function (d) { common.mailbox.dismiss(d, function (err) { @@ -126,7 +126,7 @@ define([ if (!error) { $ticket.remove(); } }); } - $ticket.append(Support.makeMessage(common, content, hash, false)); + $ticket.append(APP.support.makeMessage(content, hash)); } }); return $div; @@ -137,7 +137,7 @@ define([ var key = 'form'; var $div = makeBlock(key, true); - var form = Support.makeForm(); + var form = APP.support.makeForm(); $div.find('button').before(form); @@ -147,7 +147,7 @@ define([ var metadataMgr = common.getMetadataMgr(); var privateData = metadataMgr.getPrivateData(); var user = metadataMgr.getUserData(); - var sent = Support.sendForm(common, id, form, { + var sent = APP.support.sendForm(id, form, { channel: privateData.support, curvePublic: user.curvePublic }); @@ -244,6 +244,7 @@ define([ APP.origin = privateData.origin; APP.readOnly = privateData.readOnly; + APP.support = Support.create(common, false); // Content var $rightside = APP.$rightside; diff --git a/www/support/ui.js b/www/support/ui.js index ef91c56a1..903a86167 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -8,7 +8,8 @@ define([ '/customize/messages.js', ], function ($, ApiConfig, h, UI, Hash, Util, Messages) { - var send = function (common, id, type, data, dest) { + var send = function (ctx, id, type, data, dest) { + var common = ctx.common; var supportKey = ApiConfig.supportMailbox; var supportChannel = Hash.getChannelIdFromKey(supportKey); var metadataMgr = common.getMetadataMgr(); @@ -38,7 +39,7 @@ define([ }); }; - var sendForm = function (common, id, form, dest) { + var sendForm = function (ctx, id, form, dest) { var $title = $(form).find('.cp-support-form-title'); var $content = $(form).find('.cp-support-form-msg'); @@ -53,7 +54,7 @@ define([ $content.val(''); $title.val(''); - send(common, id, 'TICKET', { + send(ctx, id, 'TICKET', { title: title, message: content, }, dest); @@ -97,7 +98,7 @@ define([ return form; }; - var makeTicket = function ($div, common, content, onHide) { + var makeTicket = function (ctx, $div, content, onHide) { var ticketTitle = content.title + ' (#' + content.id + ')'; var answer = h('button.btn.btn-primary.cp-support-answer', Messages.support_answer); var close = h('button.btn.btn-danger.cp-support-close', Messages.support_close); @@ -117,7 +118,7 @@ define([ ])); $(close).click(function () { - send(common, content.id, 'CLOSE', {}, content.sender); + send(ctx, content.id, 'CLOSE', {}, content.sender); }); $(hide).click(function () { @@ -129,7 +130,7 @@ define([ $ticket.find('.cp-support-form-container').remove(); $(actions).hide(); var form = makeForm(function () { - var sent = sendForm(common, content.id, form, content.sender); + var sent = sendForm(ctx, content.id, form, content.sender); if (sent) { $(actions).show(); $(form).remove(); @@ -142,7 +143,9 @@ define([ return $ticket; }; - var makeMessage = function (common, content, hash, isAdmin) { + var makeMessage = function (ctx, content, hash) { + var common = ctx.common; + var isAdmin = ctx.isAdmin; var metadataMgr = common.getMetadataMgr(); var privateData = metadataMgr.getPrivateData(); @@ -169,7 +172,8 @@ define([ ]); }; - var makeCloseMessage = function (common, content, hash) { + var makeCloseMessage = function (ctx, content, hash) { + var common = ctx.common; var metadataMgr = common.getMetadataMgr(); var privateData = metadataMgr.getPrivateData(); var fromMe = content.sender && content.sender.edPublic === privateData.edPublic; @@ -185,11 +189,30 @@ define([ ]); }; + var create = function (common, isAdmin) { + var ui = {}; + var ctx = { + common: common, + isAdmin: isAdmin + }; + + ui.sendForm = function (id, form, dest) { + return sendForm(ctx, id, form, dest); + }; + ui.makeForm = makeForm; + ui.makeTicket = function ($div, content, onHide) { + return makeTicket(ctx, $div, content, onHide); + }; + ui.makeMessage = function (content, hash) { + return makeMessage(ctx, content, hash); + }; + ui.makeCloseMessage = function (content, hash) { + return makeCloseMessage(ctx, content, hash); + }; + return ui; + }; + return { - sendForm: sendForm, - makeForm: makeForm, - makeTicket: makeTicket, - makeMessage: makeMessage, - makeCloseMessage: makeCloseMessage + create: create }; }); From a169b4c3b3b6e03047b37c1b5114dac381e7ad9a Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 16 Jul 2019 14:31:57 +0200 Subject: [PATCH 14/27] Display a notification when there is a new message from the support team --- www/common/notifications.js | 15 +++++++++++++++ www/common/outer/mailbox-handlers.js | 8 ++++++++ www/support/ui.js | 7 +++++++ 3 files changed, 30 insertions(+) diff --git a/www/common/notifications.js b/www/common/notifications.js index 2e4bfce62..20352876c 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -90,6 +90,21 @@ define([ } }; + // New support message from the admins + handlers['SUPPORT_MESSAGE'] = function (common, data) { + var content = data.content; + content.getFormatText = function () { + return Messages.support_notification; + }; + content.handler = function () { + common.openURL('/support/'); + defaultDismiss(common, data)(); + }; + if (!content.archived) { + content.dismissHandler = defaultDismiss(common, data); + } + }; + return { add: function (common, data) { var type = data.content.msg.type; diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index 10e61fb60..6aa919112 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -201,6 +201,14 @@ define([ } }; + // Hide duplicates when receiving a SUPPORT_MESSAGE notification + var supportMessage = false; + handlers['SUPPORT_MESSAGE'] = function (ctx, box, data, cb) { + if (supportMessage) { return void cb(true); } + supportMessage = true; + cb(); + }; + return { add: function (ctx, box, data, cb) { /** diff --git a/www/support/ui.js b/www/support/ui.js index 903a86167..8a66e7886 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -37,6 +37,13 @@ define([ channel: dest.channel, curvePublic: dest.curvePublic }); + + if (ctx.isAdmin) { + common.mailbox.sendTo('SUPPORT_MESSAGE', {}, { + channel: dest.notifications, + curvePublic: dest.curvePublic + }); + } }; var sendForm = function (ctx, id, form, dest) { From 9b45f0dd7949449ec287dc0ced7e87a62eb17103 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 16 Jul 2019 17:29:55 +0200 Subject: [PATCH 15/27] Add translation keys --- .../src/less2/include/notifications.less | 14 +++++++ www/common/notifications.js | 40 ++++++++++++++++--- www/common/outer/mailbox-handlers.js | 4 +- www/common/toolbar3.js | 10 ++++- 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/customize.dist/src/less2/include/notifications.less b/customize.dist/src/less2/include/notifications.less index b19a9c86b..e68b3a72d 100644 --- a/customize.dist/src/less2/include/notifications.less +++ b/customize.dist/src/less2/include/notifications.less @@ -1,4 +1,5 @@ @import (reference) "./colortheme-all.less"; +@import (reference) "./avatar.less"; .notifications_main() { --LessLoader_require: LessLoader_currentFile(); @@ -53,6 +54,19 @@ } } } + .cp-notifications-requestedit-verified { + display: flex; + align-items: center; + &> span.cp-avatar { + .avatar_main(50px); + } + &> span { + margin-right: 10px; + } + &> p { + margin: 0; + } + } } diff --git a/www/common/notifications.js b/www/common/notifications.js index 4a3f7ca19..7312b33f7 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -115,18 +115,48 @@ define([ // Display the notification content.getFormatText = function () { - return 'Edit access request: ' + msg.content.title + ' - ' + msg.content.user.displayName; - }; // XXX + return Messages._getKey('requestEdit_request', [msg.content.title, msg.content.displayName]); + }; // if not archived, add handlers content.handler = function () { - UI.confirm("Give edit rights?", function (yes) { + var metadataMgr = common.getMetadataMgr(); + var priv = metadataMgr.getPrivateData(); + + var link = h('a', { + href: '#' + }, Messages.requestEdit_viewPad); + var verified = h('p.cp-notifications-requestedit-verified'); + + if (priv.friends && priv.friends[msg.author]) { + var f = priv.friends[msg.author]; + var $verified = $(verified); + $verified.append(h('span.fa.fa-certificate')); + var $avatar = $(h('span.cp-avatar')).appendTo($verified); + $verified.append(h('p', Messages._getKey('requestEdit_verified', [f.displayName]))); + common.displayAvatar($avatar, f.avatar, f.displayName); + } + + var div = h('div', [ + h('p', Messages._getKey('requestEdit_confirm', [msg.content.title, msg.content.displayName])), + verified, + link + ]); + $(link).click(function (e) { + e.preventDefault(); + e.stopPropagation(); + common.openURL(msg.content.href); + }); + UI.confirm(div, function (yes) { if (!yes) { return; } common.getSframeChannel().event('EV_GIVE_ACCESS', { channel: msg.content.channel, user: msg.content.user }); defaultDismiss(common, data)(); + }, { + ok: Messages.friendRequest_accept, + cancel: Messages.friendRequest_decline }); }; @@ -146,8 +176,8 @@ define([ // Display the notification content.getFormatText = function () { - return 'Edit access received: ' + msg.content.title + ' from ' + msg.content.user.displayName; - }; // XXX + return Messages._getKey('requestEdit_accepted', [msg.content.title, msg.content.displayName]); + }; // if not archived, add handlers content.handler = function () { diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index 6bc0536be..9d383caa1 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -222,17 +222,19 @@ define([ if (!res.length) { return void cb(true); } var edPublic = ctx.store.proxy.edPublic; - var title; + var title, href; if (!res.some(function (obj) { if (obj.data && Array.isArray(obj.data.owners) && obj.data.owners.indexOf(edPublic) !== -1 && obj.data.href) { + href = obj.data.href; title = obj.data.filename || obj.data.title; return true; } })) { return void cb(true); } content.title = title; + content.href = href; cb(false); }; diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 53aa93f4f..6c262e2d1 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -585,7 +585,7 @@ MessengerUI, Messages) { var $requestBlock = $('