Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Grey out muted streams in personal settings.
Julia Bichler24673b7a6937
diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.jsindex c5d35ecffe3..302d4ab4ba4 100644--- a/frontend_tests/node_tests/stream_data.js+++ b/frontend_tests/node_tests/stream_data.js@@ -693,6 +693,52 @@ test("is_notifications_stream_muted", () => {assert.ok(stream_data.is_notifications_stream_muted());});+test("muted_stream_ids", () => {+ const denmark = {+ subscribed: true,+ color: "blue",+ name: "Denmark",+ stream_id: 1,+ is_muted: true,+ invite_only: true,+ history_public_to_subscribers: true,+ };+ const social = {+ subscribed: true,+ color: "red",+ name: "social",+ stream_id: 2,+ is_muted: false,+ invite_only: true,+ history_public_to_subscribers: false,+ stream_post_policy: stream_data.stream_post_policy_values.admins.code,+ };+ const test = {+ subscribed: true,+ color: "yellow",+ name: "test",+ stream_id: 3,+ is_muted: true,+ invite_only: false,+ };+ const web_public_stream = {+ subscribed: true,+ color: "yellow",+ name: "web_public_stream",+ stream_id: 4,+ is_muted: false,+ invite_only: false,+ history_public_to_subscribers: true,+ is_web_public: true,+ };+ stream_data.add_sub(denmark);+ stream_data.add_sub(social);+ stream_data.add_sub(test);+ stream_data.add_sub(web_public_stream);++ assert.deepEqual(stream_data.muted_stream_ids(), [1, 3]);+});+test("realm_has_notifications_stream", () => {page_params.realm_notifications_stream_id = 10;assert.ok(stream_data.realm_has_notifications_stream());diff --git a/static/js/settings_notifications.js b/static/js/settings_notifications.jsindex 43f2e2535bd..4c2926ca9fa 100644--- a/static/js/settings_notifications.js+++ b/static/js/settings_notifications.js@@ -9,8 +9,11 @@ import {page_params} from "./page_params";import * as settings_config from "./settings_config";import * as settings_org from "./settings_org";import * as settings_ui from "./settings_ui";+import * as stream_data from "./stream_data";import * as stream_edit from "./stream_edit";import * as stream_settings_data from "./stream_settings_data";+import * as stream_settings_ui from "./stream_settings_ui";+import * as sub_store from "./sub_store";import * as unread_ui from "./unread_ui";import {user_settings} from "./user_settings";@@ -28,6 +31,8 @@ function rerender_ui() {unmatched_streams_table.find(".stream-row").remove();+ const muted_stream_ids = stream_data.muted_stream_ids();+for (const stream of unmatched_streams) {unmatched_streams_table.append(render_stream_specific_notification_row({@@ -37,6 +42,7 @@ function rerender_ui() {is_disabled:settings_config.all_notifications(user_settings).show_push_notifications_tooltip,+ muted: muted_stream_ids.includes(stream.stream_id),}),);}@@ -237,9 +243,41 @@ export function update_page(settings_panel) {rerender_ui();}+export function update_muted_stream_state(sub) {+ const row = $(+ `#stream-specific-notify-table .stream-row[data-stream-id='${CSS.escape(sub.stream_id)}']`,+ );++ $(row).toggleClass("control-label-disabled", sub.is_muted);+ if (sub.is_muted) {+ $(row).find(".unmute_stream").show();+ } else {+ $(row).find(".unmute_stream").hide();+ }+ $(row).find("input").prop("disabled", sub.is_muted);+ $(row)+ .find('[name="push_notifications"]')+ .prop("disabled", !page_params.realm_push_notifications_enabled || sub.is_muted);+}+export function initialize() {user_settings_panel.container = "#user-notification-settings";user_settings_panel.settings_object = user_settings;user_settings_panel.notification_sound_elem = "#user-notification-sound-audio";user_settings_panel.for_realm_settings = false;++ // Set up click handler for unmuting streams via this UI.+ $("body").on("click", "#stream-specific-notify-table .unmute_stream", (e) => {+ e.preventDefault();+ e.stopPropagation();+ const row = $(e.currentTarget).closest(".stream-row");+ const stream_id = Number.parseInt(row.attr("data-stream-id"), 10);+ const sub = sub_store.get(stream_id);++ stream_settings_ui.set_muted(+ sub,+ !sub.is_muted,+ row.closest(".subsection-parent").find(".alert-notification"),+ );+ });}diff --git a/static/js/stream_data.js b/static/js/stream_data.jsindex 367c2fe01c6..a0443711509 100644--- a/static/js/stream_data.js+++ b/static/js/stream_data.js@@ -380,6 +380,12 @@ export function subscribed_stream_ids() {return subscribed_subs().map((sub) => sub.stream_id);}+export function muted_stream_ids() {+ return subscribed_subs()+ .filter((sub) => sub.is_muted)+ .map((sub) => sub.stream_id);+}+export function get_subscribed_streams_for_user(user_id) {// Note that we only have access to subscribers of some streams// depending on our role.diff --git a/static/js/stream_muting.js b/static/js/stream_muting.jsindex e8ae4157ef5..72bd370dbbf 100644--- a/static/js/stream_muting.js+++ b/static/js/stream_muting.js@@ -5,6 +5,7 @@ import * as message_util from "./message_util";import * as message_viewport from "./message_viewport";import * as navigate from "./navigate";import * as overlays from "./overlays";+import * as settings_notifications from "./settings_notifications";import * as stream_edit from "./stream_edit";import * as stream_list from "./stream_list";@@ -58,6 +59,7 @@ export function update_is_muted(sub, value) {}}, 0);+ settings_notifications.update_muted_stream_state(sub);stream_edit.update_muting_rendering(sub);stream_list.set_in_home_view(sub.stream_id, !sub.is_muted);}diff --git a/static/js/tippyjs.js b/static/js/tippyjs.jsindex 372032713aa..12a9c17e24c 100644--- a/static/js/tippyjs.js+++ b/static/js/tippyjs.js@@ -216,6 +216,11 @@ export function initialize() {},});+ delegate("body", {+ target: "#stream-specific-notify-table .unmute_stream",+ appendTo: () => document.body,+ });+delegate("body", {target: [".rendered_markdown .copy_codeblock",diff --git a/static/styles/dark_theme.css b/static/styles/dark_theme.cssindex 636ea122c7a..e55df7470de 100644--- a/static/styles/dark_theme.css+++ b/static/styles/dark_theme.css@@ -1205,6 +1205,12 @@ body.dark-theme {#id_realm_enable_spectator_access_label a {color: hsl(236, 33%, 90%);}++ #stream-specific-notify-table .unmute_stream {+ &:hover {+ color: hsl(0, 0%, 100%);+ }+ }}@supports (-moz-appearance: none) {diff --git a/static/styles/settings.css b/static/styles/settings.cssindex fa1bf3efadb..b19b7f23e82 100644--- a/static/styles/settings.css+++ b/static/styles/settings.css@@ -522,6 +522,16 @@ input[type="checkbox"] {}}+#stream-specific-notify-table .unmute_stream {+ position: relative;+ left: 3px;++ &:hover {+ color: hsl(0, 0%, 20%);+ cursor: pointer;+ }+}+.organization-settings-parent > div:first-of-type {margin-top: 10px;}@@ -631,6 +641,10 @@ input[type="checkbox"] {.filter-icon i {padding-right: 0;}++ label {+ cursor: default;+ }}td:first-child {diff --git a/static/templates/settings/notification_settings_checkboxes.hbs b/static/templates/settings/notification_settings_checkboxes.hbsindex 083b0c4ee41..e94906ab7ea 100644--- a/static/templates/settings/notification_settings_checkboxes.hbs+++ b/static/templates/settings/notification_settings_checkboxes.hbs@@ -1,7 +1,7 @@<td><label class="checkbox"><input type="checkbox" name="{{setting_name}}" id="{{prefix}}{{setting_name}}"- {{#if is_disabled}}disabled="disabled"{{/if}}+ {{#if (or is_muted is_disabled)}} disabled {{/if}}{{#if is_checked}}checked="checked"{{/if}} data-setting-widget-type="boolean"class="{{setting_name}}{{#unless is_disabled}} prop-element{{/unless}}"/><span></span>diff --git a/static/templates/settings/stream_specific_notification_row.hbs b/static/templates/settings/stream_specific_notification_row.hbsindex 7a308e1f999..c20f5530399 100644--- a/static/templates/settings/stream_specific_notification_row.hbs+++ b/static/templates/settings/stream_specific_notification_row.hbs@@ -1,4 +1,4 @@-<tr class="stream-row" data-stream-id="{{stream.stream_id}}">+<tr class="stream-row {{#if muted}}control-label-disabled{{/if}}" data-stream-id="{{stream.stream_id}}"><td><span id="stream_privacy_swatch_{{stream.stream_id}}" class="stream-privacy filter-icon">{{> ../stream_privacy@@ -6,12 +6,16 @@is_web_public=stream.is_web_public }}</span>{{stream.stream_name}}+ <div class="fa fa-bell-slash-o unmute_stream" data-tippy-content="{{t 'Unmute' }}"+ {{#unless muted}}style="display: none;"{{/unless}}></div></td>{{#each stream_specific_notification_settings}}{{> notification_settings_checkboxessetting_name=thisprefix=(lookup ../stream "stream_id")is_checked=(lookup ../stream this)- is_disabled=(lookup ../is_disabled this) }}+ is_disabled=(lookup ../is_disabled this)+ is_muted=../muted+ }}{{/each}}</tr>