diff --git a/src/components/views/settings/Notifications.js b/src/components/views/settings/Notifications.js index faca5c49..a551ba10 100644 --- a/src/components/views/settings/Notifications.js +++ b/src/components/views/settings/Notifications.js @@ -55,6 +55,7 @@ module.exports = React.createClass({ vectorState: PushRuleVectorState.ON, rules: [] }, + externalPushRules: [], // Push rules (except content rule) that have been defined outside Vector UI externalContentRules: [] // Keyword push rules that have been defined outside Vector UI }; }, @@ -378,19 +379,24 @@ module.exports = React.createClass({ MatrixClientPeg.get().getPushRules().done(function(rulesets) { MatrixClientPeg.get().pushRules = rulesets; - // Get homeserver default rules expected by Vector + // Get homeserver default rules and triage them by categories var rule_categories = { + // The master rule (all notifications disabling) '.m.rule.master': 'master', + // The rules displayed by Vector UI + // XXX: .m.rule.contains_user_name is not managed (not a fancy rule for Vector?) '.m.rule.contains_display_name': 'vector', '.m.rule.room_one_to_one': 'vector', '.m.rule.invite_for_me': 'vector', '.m.rule.member_event': 'vector', - '.m.rule.call': 'vector', + '.m.rule.call': 'vector' + + // Others go to others }; // HS default rules - var defaultRules = {master: [], vector: {}, additional: [], fallthrough: [], suppression: []}; + var defaultRules = {master: [], vector: {}, others: []}; // Content/keyword rules var contentRules = {on: [], on_but_disabled:[], loud: [], loud_but_disabled: [], other: []}; @@ -401,16 +407,15 @@ module.exports = React.createClass({ r.kind = kind; if (r.rule_id[0] === '.') { if (cat) { - if (cat === 'vector') - { + if (cat === 'vector') { defaultRules.vector[r.rule_id] = r; } - else - { + else { defaultRules[cat].push(r); } - } else { - defaultRules.additional.push(r); + } + else { + defaultRules['others'].push(r); } } else if (kind === 'content') { @@ -558,6 +563,25 @@ module.exports = React.createClass({ "disabled": PushRuleVectorState.ON }); + // Build the rules not managed by Vector UI + var otherRulesDescriptions = { + '.m.rule.suppress_notices': "Suppress notifications from bots", + '.m.rule.message': "Notify for all other messages/rooms", + '.m.rule.fallback': "Notify me for anything else" + }; + + self.state.externalPushRules = []; + for (var i in defaultRules.others) { + var rule = defaultRules.others[i]; + var ruleDescription = otherRulesDescriptions[rule.rule_id]; + + // Show enabled default rules that was modified by the user + if (ruleDescription && rule.enabled && !rule.default) { + rule.description = ruleDescription; + self.state.externalPushRules.push(rule); + } + } + self.setState({ phase: self.phases.DISPLAY }); @@ -672,6 +696,7 @@ module.exports = React.createClass({ } // When enabled, the master rule inhibits all existing rules + // So do not show all notification settings if (this.state.masterPushRule.enabled) { return (
@@ -684,17 +709,37 @@ module.exports = React.createClass({ ); } - // Build the list of keywords rules that have been defined outside Vector UI + // Build external push rules + var externalRules = []; + for (var i in this.state.externalPushRules) { + var rule = this.state.externalPushRules[i]; + externalRules.push(
  • { rule.description }
  • ); + } + + // Show keywords not displayed by the vector UI as a single external push rule var externalKeyWords = []; for (var i in this.state.externalContentRules) { var rule = this.state.externalContentRules[i]; externalKeyWords.push(rule.pattern); } - if (externalKeyWords.length) { externalKeyWords = externalKeyWords.join(", "); + externalRules.push(
  • Notifications on the following keywords follow rules which can’t be displayed here: { externalKeyWords }
  • ); } - + + var advancedSettings; + if (externalRules.length) { + advancedSettings = ( +
    +

    Advanced notifications settings

    + There are advanced rules which are not shown here. You might have configured them in another client than Vector. You cannot tune them in Vector but they still apply. + +
    + ); + } + return (
    @@ -737,12 +782,8 @@ module.exports = React.createClass({
    -
    - -
    -

    - Warning: Push rules on the following keywords has been defined:
    - { externalKeyWords } + { advancedSettings } +
    diff --git a/src/skins/vector/css/vector-web/views/settings/Notifications.css b/src/skins/vector/css/vector-web/views/settings/Notifications.css index 76cae467..f0446e43 100644 --- a/src/skins/vector/css/vector-web/views/settings/Notifications.css +++ b/src/skins/vector/css/vector-web/views/settings/Notifications.css @@ -33,6 +33,10 @@ limitations under the License. display: table-cell; } +.mx_UserNotifSettings_pushRulesTableWrapper { + padding-bottom: 21px; +} + .mx_UserNotifSettings_pushRulesTable { width: 100%; table-layout: fixed;