From 7c336cd00afbe0487cbacb05d8fe22a2349ea0c1 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 16 Aug 2017 17:46:20 +0100 Subject: [PATCH 01/12] Implement TextualEvent tiles for im.vector.modular.widgets E.g. "Bob added a Acme widget", "Susan removed a Giraffe widget" --- src/TextForEvent.js | 21 +++++++++++++++++++++ src/components/views/rooms/EventTile.js | 2 ++ src/i18n/strings/en_EN.json | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index de12cec502..ed06cc2199 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -248,6 +248,25 @@ function textForPowerEvent(event) { }); } +function textForWidgetEvent(event) { + const senderName = event.sender ? event.sender.name : event.getSender(); + const prevWidgetName = event.getPrevContent() ? event.getPrevContent().name : null; + let widgetName = event.getContent() ? event.getContent().name : prevWidgetName; + + // Apply sentence case + widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : ''; + + if (event.getContent().url) { + return _t('%(senderName)s added a %(widgetName)swidget', { + senderName, widgetName, + }); + } else { + return _t('%(senderName)s removed a %(widgetName)swidget', { + senderName, widgetName, + }); + } +} + var handlers = { 'm.room.message': textForMessageEvent, 'm.room.name': textForRoomNameEvent, @@ -260,6 +279,8 @@ var handlers = { 'm.room.history_visibility': textForHistoryVisibilityEvent, 'm.room.encryption': textForEncryptionEvent, 'm.room.power_levels': textForPowerEvent, + + 'im.vector.modular.widgets': textForWidgetEvent, }; module.exports = { diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 776d8a264b..a6f8ed5542 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -44,6 +44,8 @@ var eventTileTypes = { 'm.room.history_visibility' : 'messages.TextualEvent', 'm.room.encryption' : 'messages.TextualEvent', 'm.room.power_levels' : 'messages.TextualEvent', + + 'im.vector.modular.widgets': 'messages.TextualEvent', }; var MAX_READ_AVATARS = 5; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 83be31de4b..0cd463fe8b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -969,5 +969,7 @@ "Automatically replace plain text Emoji": "Automatically replace plain text Emoji", "Failed to upload image": "Failed to upload image", "Failed to update group": "Failed to update group", - "Hide avatars in user and room mentions": "Hide avatars in user and room mentions" + "Hide avatars in user and room mentions": "Hide avatars in user and room mentions", + "%(senderName)s added a %(widgetName)swidget": "%(senderName)s added a %(widgetName)swidget", + "%(senderName)s removed a %(widgetName)swidget": "%(senderName)s removed a %(widgetName)swidget" } From fceccfc503393a198440a88ae29e0f532ef0c471 Mon Sep 17 00:00:00 2001 From: MTRNord Date: Wed, 16 Aug 2017 23:54:36 +0200 Subject: [PATCH 02/12] Add missing Robot string to translation --- src/components/views/login/CaptchaForm.js | 6 +++++- src/i18n/strings/en_EN.json | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/views/login/CaptchaForm.js b/src/components/views/login/CaptchaForm.js index f154cc4f1d..367b1ea590 100644 --- a/src/components/views/login/CaptchaForm.js +++ b/src/components/views/login/CaptchaForm.js @@ -66,7 +66,11 @@ module.exports = React.createClass({ // * jumping straight to a hosted captcha page (but we don't support that yet) // * embedding the captcha in an iframe (if that works) // * using a better captcha lib - warning.innerHTML = "Robot check is currently unavailable on desktop - please use a web browser."; + warning.innerHTML = _tJsx( + "Robot check is currently unavailable on desktop - please use a web browser", + /(.*?)<\/a>/, + (sub) => { return "{ sub }"; } + ); this.refs.recaptchaContainer.appendChild(warning); } else { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 83be31de4b..bacac0ebca 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -969,5 +969,6 @@ "Automatically replace plain text Emoji": "Automatically replace plain text Emoji", "Failed to upload image": "Failed to upload image", "Failed to update group": "Failed to update group", - "Hide avatars in user and room mentions": "Hide avatars in user and room mentions" + "Hide avatars in user and room mentions": "Hide avatars in user and room mentions", + "Robot check is currently unavailable on desktop - please use a web browser": "Robot check is currently unavailable on desktop - please use a web browser" } From 59815359f8331840f86a417b2ed8b5ac63c9ac99 Mon Sep 17 00:00:00 2001 From: MTRNord Date: Wed, 16 Aug 2017 23:55:43 +0200 Subject: [PATCH 03/12] Add misiing _tJsx import --- src/components/views/login/CaptchaForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/login/CaptchaForm.js b/src/components/views/login/CaptchaForm.js index 367b1ea590..8f9c0391ae 100644 --- a/src/components/views/login/CaptchaForm.js +++ b/src/components/views/login/CaptchaForm.js @@ -17,7 +17,7 @@ limitations under the License. 'use strict'; import React from 'react'; -import { _t } from '../../../languageHandler'; +import { _t, _tJsx } from '../../../languageHandler'; var DIV_ID = 'mx_recaptcha'; From 766c188a1ee7745daadf2c11ce2b63fce288cfcd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 17 Aug 2017 17:15:18 +0100 Subject: [PATCH 04/12] hotfix bad fn signature regression Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/settings/DevicesPanelEntry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/settings/DevicesPanelEntry.js b/src/components/views/settings/DevicesPanelEntry.js index 69534f09b1..aa5a4f88a3 100644 --- a/src/components/views/settings/DevicesPanelEntry.js +++ b/src/components/views/settings/DevicesPanelEntry.js @@ -71,7 +71,7 @@ export default class DevicesPanelEntry extends React.Component { // pop up an interactive auth dialog var InteractiveAuthDialog = sdk.getComponent("dialogs.InteractiveAuthDialog"); - Modal.createTrackedDialog('Delete Device Dialog', InteractiveAuthDialog, { + Modal.createTrackedDialog('Delete Device Dialog', '', InteractiveAuthDialog, { title: _t("Authentication"), matrixClient: MatrixClientPeg.get(), authData: error.data, From 7c04a6671d5e2a15ec0028716d62d97cfceeda68 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 17 Aug 2017 19:06:19 +0100 Subject: [PATCH 05/12] expand auxPanel when showing apps --- src/components/views/rooms/AuxPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/AuxPanel.js b/src/components/views/rooms/AuxPanel.js index a50743a25d..8fa805d3cf 100644 --- a/src/components/views/rooms/AuxPanel.js +++ b/src/components/views/rooms/AuxPanel.js @@ -137,7 +137,7 @@ module.exports = React.createClass({ } return ( -
+
{ appsDrawer } { fileDropTarget } { callView } From bb0845954d5eeee5562d418174c8f43fa29f1460 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 17 Aug 2017 19:10:45 +0100 Subject: [PATCH 06/12] improve wording for directory listings --- src/components/views/rooms/RoomSettings.js | 2 +- src/i18n/strings/en_EN.json | 2 +- src/i18n/strings/en_US.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 58473f1fb3..85301ab54e 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -871,7 +871,7 @@ module.exports = React.createClass({ - {_t("List this room in %(domain)s's room directory?", { domain: MatrixClientPeg.get().getDomain() })} + {_t("Publish this room to the public in %(domain)s's room directory?", { domain: MatrixClientPeg.get().getDomain() })}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index bacac0ebca..be1f9e994d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -392,7 +392,7 @@ "left": "left", "%(targetName)s left the room.": "%(targetName)s left the room.", "Level:": "Level:", - "List this room in %(domain)s's room directory?": "List this room in %(domain)s's room directory?", + "Publish this room to the public in %(domain)s's room directory?": "Publish this room to the public in %(domain)s's room directory?", "Local addresses for this room:": "Local addresses for this room:", "Logged in as:": "Logged in as:", "Login as guest": "Login as guest", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 0f58eef325..a68ce5d982 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -359,7 +359,7 @@ "left": "left", "%(targetName)s left the room.": "%(targetName)s left the room.", "Level": "Level", - "List this room in %(domain)s's room directory?": "List this room in %(domain)s's room directory?", + "Publish this room to the public in %(domain)s's room directory?": "Publish this room to the public in %(domain)s's room directory?", "Local addresses for this room:": "Local addresses for this room:", "Logged in as:": "Logged in as:", "Login as guest": "Login as guest", From 42d9e3bc8a484a8e1e4027c459c9962bfcf5dc97 Mon Sep 17 00:00:00 2001 From: Krombel Date: Thu, 17 Aug 2017 20:26:34 +0200 Subject: [PATCH 07/12] remove unused strings introduced by string change in bb084595 --- src/i18n/strings/de_DE.json | 2 +- src/i18n/strings/el.json | 1 - src/i18n/strings/es.json | 1 - src/i18n/strings/eu.json | 1 - src/i18n/strings/fr.json | 1 - src/i18n/strings/hu.json | 1 - src/i18n/strings/ja.json | 1 - src/i18n/strings/ko.json | 1 - src/i18n/strings/lv.json | 1 - src/i18n/strings/nl.json | 1 - src/i18n/strings/pt.json | 1 - src/i18n/strings/pt_BR.json | 1 - src/i18n/strings/ru.json | 1 - src/i18n/strings/sv.json | 1 - src/i18n/strings/th.json | 1 - src/i18n/strings/tr.json | 1 - src/i18n/strings/zh_Hant.json | 1 - 17 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/i18n/strings/de_DE.json b/src/i18n/strings/de_DE.json index 8cd9498880..671ea5d09d 100644 --- a/src/i18n/strings/de_DE.json +++ b/src/i18n/strings/de_DE.json @@ -853,7 +853,7 @@ "device id: ": "Geräte-ID: ", "Device key:": "Geräte-Schlüssel:", "Email address (optional)": "E-Mail-Adresse (optional)", - "List this room in %(domain)s's room directory?": "Diesen Raum zum Raum-Verzeichnis von %(domain)s hinzufügen?", + "Publish this room to the public in %(domain)s's room directory?": "Diesen Raum mittels Raum-Verzeichnis von %(domain)s veröffentlichen?", "Mobile phone number (optional)": "Mobilfunknummer (optional)", "Password:": "Passwort:", "Register": "Registrieren", diff --git a/src/i18n/strings/el.json b/src/i18n/strings/el.json index 562318e354..3ea83a322c 100644 --- a/src/i18n/strings/el.json +++ b/src/i18n/strings/el.json @@ -297,7 +297,6 @@ "left": "έφυγε", "%(targetName)s left the room.": "Ο χρήστης %(targetName)s έφυγε από το δωμάτιο.", "Level": "Επίπεδο", - "List this room in %(domain)s's room directory?": "Να εμφανίζεται το δωμάτιο στο γενικό ευρετήριο του διακομιστή %(domain)s;", "Local addresses for this room:": "Τοπική διεύθυνση για το δωμάτιο:", "Logged in as:": "Συνδεθήκατε ως:", "Login as guest": "Σύνδεση ως επισκέπτης", diff --git a/src/i18n/strings/es.json b/src/i18n/strings/es.json index 1f6b26403c..035c570792 100644 --- a/src/i18n/strings/es.json +++ b/src/i18n/strings/es.json @@ -500,7 +500,6 @@ "Drop File Here": "Deje el fichero aquí", "Guest access is disabled on this Home Server.": "El acceso de invitados está desactivado en este servidor.", "Join as voice or video.": "Conecte con voz o vídeo.", - "List this room in %(domain)s's room directory?": "¿Mostrar esta sala en el directorio de %(domain)s?", "Manage Integrations": "Gestionar integraciones", "Markdown is disabled": "Markdown está desactivado", "Markdown is enabled": "Markdown está activado", diff --git a/src/i18n/strings/eu.json b/src/i18n/strings/eu.json index 664af7ba4c..308fa36900 100644 --- a/src/i18n/strings/eu.json +++ b/src/i18n/strings/eu.json @@ -464,7 +464,6 @@ "left": "atera da", "%(targetName)s left the room.": "%(targetName)s erabiltzailea gelatik atera da.", "Level:": "Maila:", - "List this room in %(domain)s's room directory?": "Gela hau %(domain)s's domeinuko gelen direktorioan zerrendatu?", "Local addresses for this room:": "Gela honen tokiko helbideak:", "Logged in as:": "Saioa hasteko erabiltzailea:", "Login as guest": "Hasi saioa bisitari gisa", diff --git a/src/i18n/strings/fr.json b/src/i18n/strings/fr.json index 9b5ff58d9e..52f003eb95 100644 --- a/src/i18n/strings/fr.json +++ b/src/i18n/strings/fr.json @@ -813,7 +813,6 @@ "device id: ": "Identifiant appareil : ", "Device key:": "Clé de l’appareil :", "Email address (optional)": "Adresse e-mail (facultatif)", - "List this room in %(domain)s's room directory?": "Lister ce salon dans le répertoire de %(domain)s ?", "Mobile phone number (optional)": "Numéro de téléphone (facultatif)", "Password:": "Mot de passe :", "Register": "S'inscrire", diff --git a/src/i18n/strings/hu.json b/src/i18n/strings/hu.json index acad67ada0..48df5dabbc 100644 --- a/src/i18n/strings/hu.json +++ b/src/i18n/strings/hu.json @@ -404,7 +404,6 @@ "left": "kilépett", "%(targetName)s left the room.": "%(targetName)s elhagyta a szobát.", "Level:": "Szint:", - "List this room in %(domain)s's room directory?": "%(domain)s szobát feltüntessük a szobák listájában?", "Local addresses for this room:": "A szoba helyi címe:", "Logged in as:": "Bejelentkezve mint:", "Login as guest": "Belépés vendégként", diff --git a/src/i18n/strings/ja.json b/src/i18n/strings/ja.json index 9e8b23c680..04a7c8877c 100644 --- a/src/i18n/strings/ja.json +++ b/src/i18n/strings/ja.json @@ -48,7 +48,6 @@ "%(count)s new messages.other": "新しい発言 %(count)s", "Don't send typing notifications": "文字入力中であることを公表しない", "Filter room members": "参加者検索", - "List this room in %(domain)s's room directory?": "この部屋を %(domain)s サーバの部屋一覧に公開する?", "Send a message (unencrypted)": "ここに送信文を入力 (暗号化なし)", "Send an encrypted message": "暗号文を送る", "Show timestamps in 12 hour format (e.g. 2:30pm)": "発言時刻を12時間形式で表示 (例 2:30PM)", diff --git a/src/i18n/strings/ko.json b/src/i18n/strings/ko.json index 74fc0f5094..411d1ccfe1 100644 --- a/src/i18n/strings/ko.json +++ b/src/i18n/strings/ko.json @@ -405,7 +405,6 @@ "left": "떠났음", "%(targetName)s left the room.": "%(targetName)s님이 방을 떠나셨어요.", "Level:": "등급:", - "List this room in %(domain)s's room directory?": "%(domain)s's 방 목록에 이 방을 놓으시겠어요?", "Local addresses for this room:": "이 방의 로컬 주소:", "Logged in as:": "로그인:", "Login as guest": "손님으로 로그인", diff --git a/src/i18n/strings/lv.json b/src/i18n/strings/lv.json index cdba89e157..c2a55b3fc2 100644 --- a/src/i18n/strings/lv.json +++ b/src/i18n/strings/lv.json @@ -380,7 +380,6 @@ "left": "atstāja", "%(targetName)s left the room.": "%(targetName)s atstāja istabu.", "Level:": "Līmenis:", - "List this room in %(domain)s's room directory?": "Rādīt šo istabu %(domain)s kataloga sarakstā?", "Local addresses for this room:": "Šīs istabas lokālās adreses:", "Logged in as:": "Pierakstījās kā:", "Login as guest": "Pierakstīties kā viesis", diff --git a/src/i18n/strings/nl.json b/src/i18n/strings/nl.json index 3a25deabd1..234fc8c03a 100644 --- a/src/i18n/strings/nl.json +++ b/src/i18n/strings/nl.json @@ -480,7 +480,6 @@ "left": "verlaten", "%(targetName)s left the room.": "%(targetName)s heeft de ruimte verlaten.", "Level:": "Niveau:", - "List this room in %(domain)s's room directory?": "Deze ruimte in %(domain)s's ruimte catalogus vermelden?", "Local addresses for this room:": "Lokale adressen voor deze ruimte:", "Logged in as:": "Ingelogd als:", "Login as guest": "Als gast inloggen", diff --git a/src/i18n/strings/pt.json b/src/i18n/strings/pt.json index 16ffc1f107..827efeb16a 100644 --- a/src/i18n/strings/pt.json +++ b/src/i18n/strings/pt.json @@ -862,7 +862,6 @@ "device id: ": "id do dispositivo: ", "Device key:": "Chave do dispositivo:", "Email address (optional)": "Endereço de e-mail (opcional)", - "List this room in %(domain)s's room directory?": "Deseja listar esta sala na lista pública de salas de %(domain)s?", "Mobile phone number (optional)": "Número de telefone celular (opcional)", "Password:": "Senha:", "Register": "Registre-se", diff --git a/src/i18n/strings/pt_BR.json b/src/i18n/strings/pt_BR.json index 5ad721188a..7e7ca123b9 100644 --- a/src/i18n/strings/pt_BR.json +++ b/src/i18n/strings/pt_BR.json @@ -863,7 +863,6 @@ "device id: ": "id do dispositivo: ", "Device key:": "Chave do dispositivo:", "Email address (optional)": "Endereço de e-mail (opcional)", - "List this room in %(domain)s's room directory?": "Deseja listar esta sala na lista pública de salas de %(domain)s?", "Mobile phone number (optional)": "Número de telefone celular (opcional)", "Password:": "Senha:", "Register": "Registre-se", diff --git a/src/i18n/strings/ru.json b/src/i18n/strings/ru.json index 51fbeee0fd..e3129eb257 100644 --- a/src/i18n/strings/ru.json +++ b/src/i18n/strings/ru.json @@ -702,7 +702,6 @@ "Invalid file%(extra)s": "Недопустимый файл%(extra)s", "Invited": "Приглашен", "Jump to first unread message.": "Перейти к первому непрочитанному сообщению.", - "List this room in %(domain)s's room directory?": "Показывать эту комнату в каталоге комнат %(domain)s?", "Message not sent due to unknown devices being present": "Сообщение не отправлено из-за присутствия неизвестных устройств", "Mobile phone number (optional)": "Номер мобильного телефона (не обязательно)", "Once you've followed the link it contains, click below": "После перехода по ссылке, нажмите на кнопку ниже", diff --git a/src/i18n/strings/sv.json b/src/i18n/strings/sv.json index 1c4d63c808..d3b512900c 100644 --- a/src/i18n/strings/sv.json +++ b/src/i18n/strings/sv.json @@ -385,7 +385,6 @@ "left": "lämnade", "%(targetName)s left the room.": "%(targetName)s lämnade rummet.", "Level:": "Nivå:", - "List this room in %(domain)s's room directory?": "Visa det här rummet i katalogen på %(domain)s?", "Local addresses for this room:": "Lokala adresser för rummet:", "Logged in as:": "Inloggad som:", "Login as guest": "Logga in som gäst", diff --git a/src/i18n/strings/th.json b/src/i18n/strings/th.json index 619f081e3a..01ffa729d7 100644 --- a/src/i18n/strings/th.json +++ b/src/i18n/strings/th.json @@ -231,7 +231,6 @@ "left and rejoined": "ออกแล้วกลับเข้าร่วมอีกครั้ง", "left": "ออกไปแล้ว", "%(targetName)s left the room.": "%(targetName)s ออกจากห้องแล้ว", - "List this room in %(domain)s's room directory?": "แสดงห้องนี้ในไดเรกทอรีห้องของ %(domain)s?", "Logged in as:": "เข้าสู่ระบบในชื่อ:", "Login as guest": "เข้าสู่ระบบในฐานะแขก", "Logout": "ออกจากระบบ", diff --git a/src/i18n/strings/tr.json b/src/i18n/strings/tr.json index effc426464..2933e2433b 100644 --- a/src/i18n/strings/tr.json +++ b/src/i18n/strings/tr.json @@ -380,7 +380,6 @@ "left": "ayrıldı", "%(targetName)s left the room.": "%(targetName)s odadan ayrıldı.", "Level:": "Seviye :", - "List this room in %(domain)s's room directory?": "Bu oda %(domain)s' in oda dizininde listelensin mi ?", "Local addresses for this room:": "Bu oda için yerel adresler :", "Logged in as:": "Olarak giriş yaptı :", "Login as guest": "Misafir olarak giriş yaptı", diff --git a/src/i18n/strings/zh_Hant.json b/src/i18n/strings/zh_Hant.json index 78d7b39782..93ac57330a 100644 --- a/src/i18n/strings/zh_Hant.json +++ b/src/i18n/strings/zh_Hant.json @@ -517,7 +517,6 @@ "left and rejoined": "離開並重新加入", "left": "離開", "Level:": "等級:", - "List this room in %(domain)s's room directory?": "在 %(domain)s 的房間目錄中列出此房間嗎?", "Local addresses for this room:": "此房間的本機地址:", "Logged in as:": "登入為:", "Logout": "登出", From acc54b97f1c5e98bcaa0cd0dc481824b5bd998e7 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 16 Aug 2017 17:46:20 +0100 Subject: [PATCH 08/12] Implement TextualEvent tiles for im.vector.modular.widgets E.g. "Bob added a Acme widget", "Susan removed a Giraffe widget" The name is calculated by taking the `name` in the event content, falling back on the `type`, falling back on the previous content `type`. This is then capitalised. --- src/TextForEvent.js | 22 ++++++++++++++++++++++ src/components/views/rooms/EventTile.js | 2 ++ src/i18n/strings/en_EN.json | 4 +++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index de12cec502..d55e7f95c2 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -248,6 +248,26 @@ function textForPowerEvent(event) { }); } +function textForWidgetEvent(event) { + const senderName = event.sender ? event.sender.name : event.getSender(); + const previousContent = event.getPrevContent() ? event.getPrevContent() : {}; + const {name, type} = event.getContent() ? event.getContent() : {}; + let widgetName = widgetName || name || type || previousContent.type || ''; + + // Apply sentence case + widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : ''; + + if (event.getContent().url) { + return _t('%(senderName)s added a %(widgetName)swidget', { + senderName, widgetName, + }); + } else { + return _t('%(senderName)s removed a %(widgetName)swidget', { + senderName, widgetName, + }); + } +} + var handlers = { 'm.room.message': textForMessageEvent, 'm.room.name': textForRoomNameEvent, @@ -260,6 +280,8 @@ var handlers = { 'm.room.history_visibility': textForHistoryVisibilityEvent, 'm.room.encryption': textForEncryptionEvent, 'm.room.power_levels': textForPowerEvent, + + 'im.vector.modular.widgets': textForWidgetEvent, }; module.exports = { diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 776d8a264b..a6f8ed5542 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -44,6 +44,8 @@ var eventTileTypes = { 'm.room.history_visibility' : 'messages.TextualEvent', 'm.room.encryption' : 'messages.TextualEvent', 'm.room.power_levels' : 'messages.TextualEvent', + + 'im.vector.modular.widgets': 'messages.TextualEvent', }; var MAX_READ_AVATARS = 5; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 83be31de4b..0cd463fe8b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -969,5 +969,7 @@ "Automatically replace plain text Emoji": "Automatically replace plain text Emoji", "Failed to upload image": "Failed to upload image", "Failed to update group": "Failed to update group", - "Hide avatars in user and room mentions": "Hide avatars in user and room mentions" + "Hide avatars in user and room mentions": "Hide avatars in user and room mentions", + "%(senderName)s added a %(widgetName)swidget": "%(senderName)s added a %(widgetName)swidget", + "%(senderName)s removed a %(widgetName)swidget": "%(senderName)s removed a %(widgetName)swidget" } From 20a0ec35aff3fefaef52ba6babafec107b7f8b03 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 18 Aug 2017 10:45:43 +0100 Subject: [PATCH 09/12] Use short form to get event URL --- src/TextForEvent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index d55e7f95c2..8d6ef41180 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -251,13 +251,13 @@ function textForPowerEvent(event) { function textForWidgetEvent(event) { const senderName = event.sender ? event.sender.name : event.getSender(); const previousContent = event.getPrevContent() ? event.getPrevContent() : {}; - const {name, type} = event.getContent() ? event.getContent() : {}; + const {name, type, url} = event.getContent() ? event.getContent() : {}; let widgetName = widgetName || name || type || previousContent.type || ''; // Apply sentence case widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : ''; - if (event.getContent().url) { + if (url) { return _t('%(senderName)s added a %(widgetName)swidget', { senderName, widgetName, }); From 4b5cdac032d22935c6b29ece9b4461cea0531be9 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 18 Aug 2017 11:41:27 +0100 Subject: [PATCH 10/12] Don't show widget security warning to the person who added it to the room. --- src/components/views/elements/AppTile.js | 7 ++++++- src/components/views/rooms/AppsDrawer.js | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index a78b802ad7..a5ce3628e3 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -44,6 +44,10 @@ export default React.createClass({ // Specifying 'fullWidth' as true will render the app tile to fill the width of the app drawer continer. // This should be set to true when there is only one widget in the app drawer, otherwise it should be false. fullWidth: React.PropTypes.bool, + // UserId of the current user + userId: React.PropTypes.string.isRequired, + // UserId of the entity that added / modified the widget + creatorUserId: React.PropTypes.string, }, getDefaultProps: function() { @@ -59,7 +63,8 @@ export default React.createClass({ loading: false, widgetUrl: this.props.url, widgetPermissionId: widgetPermissionId, - hasPermissionToLoad: Boolean(hasPermissionToLoad === 'true'), + // Assume that widget has permission to load if we are the user who added it to the room, or if explicitly granted by the user + hasPermissionToLoad: hasPermissionToLoad === 'true' || this.props.userId === this.props.creatorUserId, error: null, deleting: false, }; diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 4bc98abb6f..514a6ebf96 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -93,7 +93,7 @@ module.exports = React.createClass({ return pathTemplate; }, - _initAppConfig: function(appId, app) { + _initAppConfig: function(appId, app, sender) { const user = MatrixClientPeg.get().getUser(this.props.userId); const params = { '$matrix_user_id': this.props.userId, @@ -111,6 +111,7 @@ module.exports = React.createClass({ app.id = appId; app.name = app.name || app.type; app.url = this.encodeUri(app.url, params); + app.creatorUserId = (sender && sender.userId) ? sender.userId : null; return app; }, @@ -131,7 +132,7 @@ module.exports = React.createClass({ return appsStateEvents.filter((ev) => { return ev.getContent().type && ev.getContent().url; }).map((ev) => { - return this._initAppConfig(ev.getStateKey(), ev.getContent()); + return this._initAppConfig(ev.getStateKey(), ev.getContent(), ev.sender); }); }, @@ -183,6 +184,7 @@ module.exports = React.createClass({ fullWidth={arr.length<2 ? true : false} room={this.props.room} userId={this.props.userId} + creatorUserId={app.creatorUserId} />); }); From 6c37a9a3aff74bc59646fe20c1f372c3e8892940 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 18 Aug 2017 12:03:29 +0100 Subject: [PATCH 11/12] Simplify getting of content, prev content for widget event --- src/TextForEvent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index 8d6ef41180..d75ef34c1c 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -250,8 +250,8 @@ function textForPowerEvent(event) { function textForWidgetEvent(event) { const senderName = event.sender ? event.sender.name : event.getSender(); - const previousContent = event.getPrevContent() ? event.getPrevContent() : {}; - const {name, type, url} = event.getContent() ? event.getContent() : {}; + const previousContent = event.getPrevContent() || {}; + const {name, type, url} = event.getContent() || {}; let widgetName = widgetName || name || type || previousContent.type || ''; // Apply sentence case From 1bba1f0fa61034804e7a6052c0c383c5c87fdb28 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 18 Aug 2017 12:04:34 +0100 Subject: [PATCH 12/12] Add comment --- src/TextForEvent.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index d75ef34c1c..f99cf7bde5 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -257,6 +257,8 @@ function textForWidgetEvent(event) { // Apply sentence case widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : ''; + // If the widget was removed, its content should be {}, but this is sufficiently + // equivalent to that condition. if (url) { return _t('%(senderName)s added a %(widgetName)swidget', { senderName, widgetName,