From b420fd675857d6c3e212caafa1c56d2ddc4a16da Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 31 Oct 2019 16:00:31 -0600 Subject: [PATCH] Add a view rules dialog --- .../tabs/user/MjolnirUserSettingsTab.js | 29 ++++++++++++++++++- src/i18n/strings/en_EN.json | 6 +++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/tabs/user/MjolnirUserSettingsTab.js b/src/components/views/settings/tabs/user/MjolnirUserSettingsTab.js index 4e05b57567..a02ca2c570 100644 --- a/src/components/views/settings/tabs/user/MjolnirUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/MjolnirUserSettingsTab.js @@ -129,7 +129,34 @@ export default class MjolnirUserSettingsTab extends React.Component { } _viewListRules(list: BanList) { - // TODO + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + + const room = MatrixClientPeg.get().getRoom(list.roomId); + const name = room ? room.name : list.roomId; + + const renderRules = (rules: ListRule[]) => { + if (rules.length === 0) return {_t("None")}; + + const tiles = []; + for (const rule of rules) { + tiles.push(
  • {rule.entity}
  • ); + } + return ; + }; + + Modal.createTrackedDialog('View Mjolnir list rules', '', QuestionDialog, { + title: _t("Ban list rules - %(roomName)s", {roomName: name}), + description: ( +
    +

    {_t("Server rules")}

    + {renderRules(list.serverRules)} +

    {_t("User rules")}

    + {renderRules(list.userRules)} +
    + ), + button: _t("Close"), + hasCancelButton: false, + }); } _renderPersonalBanListRules() { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 561dbc4da9..58fa564250 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -648,6 +648,11 @@ "Error removing ignored user/server": "Error removing ignored user/server", "Error unsubscribing from list": "Error unsubscribing from list", "Please try again or view your console for hints.": "Please try again or view your console for hints.", + "None": "None", + "Ban list rules - %(roomName)s": "Ban list rules - %(roomName)s", + "Server rules": "Server rules", + "User rules": "User rules", + "Close": "Close", "You have not ignored anyone.": "You have not ignored anyone.", "Remove": "Remove", "You are currently ignoring:": "You are currently ignoring:", @@ -874,7 +879,6 @@ "Revoke Moderator": "Revoke Moderator", "Make Moderator": "Make Moderator", "Admin Tools": "Admin Tools", - "Close": "Close", "and %(count)s others...|other": "and %(count)s others...", "and %(count)s others...|one": "and one other...", "Invite to this room": "Invite to this room",