Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stream settings: Re-design stream settings page using tab-switchers.

m-e-l-u-h-a-ncb4797e3b7c4
diff --git a/frontend_tests/node_tests/stream_edit.js b/frontend_tests/node_tests/stream_edit.js
index 7f7866a0f08..c84ed4a489b 100644
--- a/frontend_tests/node_tests/stream_edit.js
+++ b/frontend_tests/node_tests/stream_edit.js
@@ -26,6 +26,11 @@ mock_esm("../../static/js/list_widget", {
mock_esm("../../static/js/stream_color", {
set_colorpicker_color: noop,
});
+mock_esm("../../static/js/components", {
+ toggle: () => ({
+ get: () => [],
+ }),
+});
const peer_data = zrequire("peer_data");
const people = zrequire("people");
@@ -35,6 +40,7 @@ const stream_pill = zrequire("stream_pill");
const user_groups = zrequire("user_groups");
const user_group_pill = zrequire("user_group_pill");
const user_pill = zrequire("user_pill");
+const stream_ui_updates = zrequire("stream_ui_updates");
const jill = {
@@ -282,6 +288,9 @@ test_ui("subscriber_pills", ({override, mock_template}) => {
let fake_this = $subscription_settings;
let event = {target: fake_this};
+
+ override(stream_ui_updates, "update_toggler_for_sub", noop);
+ override(stream_ui_updates, "update_add_subscriptions_elements", noop);
stream_row_handler.call(fake_this, event);
assert.ok(template_rendered);
assert.ok(input_typeahead_called);
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index dcb6ab396c9..45c813817b1 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -11,6 +11,7 @@ import render_subscription_stream_privacy_modal from "../templates/subscription_
import * as blueslip from "./blueslip";
import * as browser_history from "./browser_history";
import * as channel from "./channel";
+import * as components from "./components";
import * as confirm_dialog from "./confirm_dialog";
import * as hash_util from "./hash_util";
import {$t, $t_html} from "./i18n";
@@ -39,6 +40,8 @@ import * as user_pill from "./user_pill";
import * as util from "./util";
export let pill_widget;
+export let toggler;
+export let select_tab = "personal_settings";
function setup_subscriptions_stream_hash(sub) {
const hash = hash_util.stream_edit_uri(sub);
@@ -154,7 +157,9 @@ function set_stream_message_retention_setting_dropdown(stream) {
}
function get_stream_id(target) {
- const row = $(target).closest(".stream-row, .subscription_settings, .save-button");
+ const row = $(target).closest(
+ ".stream-row, .stream_settings_header, .subscription_settings, .save-button",
+ );
return Number.parseInt(row.attr("data-stream-id"), 10);
}
@@ -180,7 +185,7 @@ export function open_edit_panel_for_row(stream_row) {
subs.show_subs_pane.settings();
$(stream_row).addClass("active");
setup_subscriptions_stream_hash(sub);
- show_settings_for(stream_row);
+ setup_stream_settings(stream_row);
}
export function open_edit_panel_empty() {
@@ -525,7 +530,10 @@ export function show_settings_for(node) {
stream_post_policy_values: stream_data.stream_post_policy_values,
message_retention_text: get_retention_policy_text_for_subscription_type(sub),
});
- ui.get_content_element($(".subscriptions .right .settings")).html(html);
+ ui.get_content_element($("#stream_settings")).html(html);
+
+ $("#stream_settings .tab-container").prepend(toggler.get());
+ stream_ui_updates.update_toggler_for_sub(sub);
const sub_settings = settings_for_sub(sub);
@@ -537,6 +545,24 @@ export function show_settings_for(node) {
show_subscription_settings(sub);
}
+export function setup_stream_settings(node) {
+ toggler = components.toggle({
+ child_wants_focus: true,
+ values: [
+ {label: $t({defaultMessage: "General"}), key: "general_settings"},
+ {label: $t({defaultMessage: "Personal"}), key: "personal_settings"},
+ {label: $t({defaultMessage: "Subscribers"}), key: "subscriber_settings"},
+ ],
+ callback(name, key) {
+ $(".stream_section").hide();
+ $("." + key).show();
+ select_tab = key;
+ },
+ });
+
+ show_settings_for(node);
+}
+
function stream_is_muted_changed(e) {
const sub = get_sub_for_target(e.target);
if (!sub) {
diff --git a/static/js/stream_ui_updates.js b/static/js/stream_ui_updates.js
index 086c139b6be..7257606224a 100644
--- a/static/js/stream_ui_updates.js
+++ b/static/js/stream_ui_updates.js
@@ -50,6 +50,26 @@ export function initialize_cant_subscribe_popover(sub) {
);
}
+export function update_toggler_for_sub(sub) {
+ if (!stream_edit.is_sub_settings_active(sub)) {
+ return;
+ }
+ if (sub.subscribed) {
+ stream_edit.toggler.enable_tab("personal_settings");
+ stream_edit.toggler.goto(stream_edit.select_tab);
+ } else {
+ if (stream_edit.select_tab === "personal_settings") {
+ // Go to the general settings tab, if the user is not
+ // subscribed. Also preserve the previous selected tab,
+ // to render next time a stream row is selected.
+ stream_edit.toggler.goto("general_settings");
+ } else {
+ stream_edit.toggler.goto(stream_edit.select_tab);
+ }
+ stream_edit.toggler.disable_tab("personal_settings");
+ }
+}
+
export function update_settings_button_for_sub(sub) {
// This is for the Subscribe/Unsubscribe button in the right panel.
const settings_button = subs.settings_button_for_sub(sub);
diff --git a/static/js/subs.js b/static/js/subs.js
index 6018c2371a2..18eda84ec68 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -288,6 +288,7 @@ export function update_settings_for_subscribed(slim_sub) {
if (is_sub_already_present(sub)) {
update_left_panel_row(sub);
+ stream_ui_updates.update_toggler_for_sub(sub);
stream_ui_updates.update_stream_row_in_settings_tab(sub);
stream_ui_updates.update_settings_button_for_sub(sub);
stream_ui_updates.update_change_stream_privacy_settings(sub);
@@ -314,6 +315,7 @@ export function update_settings_for_unsubscribed(slim_sub) {
const sub = stream_settings_data.get_sub_for_settings(slim_sub);
update_left_panel_row(sub);
stream_ui_updates.update_subscribers_list(sub);
+ stream_ui_updates.update_toggler_for_sub(sub);
stream_ui_updates.update_settings_button_for_sub(sub);
stream_ui_updates.update_regular_sub_settings(sub);
stream_ui_updates.update_change_stream_privacy_settings(sub);
diff --git a/static/styles/subscriptions.css b/static/styles/subscriptions.css
index dbcd56d5e65..66ea17977d6 100644
--- a/static/styles/subscriptions.css
+++ b/static/styles/subscriptions.css
@@ -818,6 +818,32 @@
margin: 20px;
}
+ .stream_settings_header {
+ white-space: nowrap;
+ display: flex;
+ margin-left: 15px;
+
+ .tab-container {
+ .ind-tab {
+ padding: 3px 4px;
+ width: 80px;
+ }
+ }
+
+ .button-group {
+ padding-top: 5px;
+ margin-left: auto;
+ margin-right: 15px;
+
+ .subscribe-button,
+ #preview-stream-button,
+ .deactivate {
+ margin-right: 3px;
+ text-decoration: none;
+ }
+ }
+ }
+
.stream-header {
white-space: nowrap;
@@ -844,9 +870,6 @@
float: right;
margin-top: -5px;
- .subscribe-button,
- #preview-stream-button,
- #open_stream_info_modal,
.deactivate {
margin-right: 3px;
text-decoration: none;
@@ -925,6 +948,10 @@
height: calc(100% - 45px);
overflow-y: auto;
-webkit-overflow-scrolling: touch;
+
+ .tab-container {
+ padding-top: 5px;
+ }
}
.subscription_settings {
@@ -1048,6 +1075,10 @@
.search-container {
text-align: center;
}
+
+ #subscription_overlay .stream_settings_header {
+ flex-wrap: wrap;
+ }
}
/* Note that this block has settings_page CSS as well, and thus needs
@@ -1119,7 +1150,7 @@
@media (width < $sm_min) {
#subscription_overlay .subscription_settings .button-group {
display: block;
- float: unset;
+ float: right;
margin-top: 10px;
}
@@ -1139,6 +1170,19 @@
}
}
+@media (width <= 500px) {
+ #subscription_overlay .stream_settings_header {
+ display: block;
+ text-align: center;
+ margin-left: 0;
+ .tab-container {
+ .ind-tab {
+ width: 85px;
+ }
+ }
+ }
+}
+
#stream-creation #invites-warning-modal .modal-footer {
position: static;
}
diff --git a/static/templates/subscription_settings.hbs b/static/templates/subscription_settings.hbs
index 535fbcca563..57c6c12dc71 100644
--- a/static/templates/subscription_settings.hbs
+++ b/static/templates/subscription_settings.hbs
@@ -1,7 +1,22 @@
+<div class="stream_settings_header" data-stream-id="{{sub.stream_id}}">
+ <div class="tab-container"></div>
+ {{#with sub}}
+ <div class="button-group">
+ <div class="sub_unsub_button_wrapper inline-block">
+ <button class="button small rounded subscribe-button sub_unsub_button {{#unless subscribed }}unsubscribed{{/unless}}" type="button" name="button" {{#if should_display_subscription_button}}title="{{t 'Toggle subscription'}} (S)" {{else}}disabled="disabled"{{/if}}>
+ {{#if subscribed }}{{#tr}}Unsubscribe{{/tr}}{{else}}{{#tr}}Subscribe{{/tr}}{{/if}}</button>
+ </div>
+ <a href="{{preview_url}}" class="button small rounded" id="preview-stream-button" role="button" title="{{t 'View stream'}} (V)" {{#unless should_display_preview_button }}style="display: none"{{/unless}}><i class="fa fa-eye"></i></a>
+ {{#if is_realm_admin}}
+ <button class="button small rounded btn-danger deactivate" type="button" name="delete_button" title="{{t 'Archive stream'}}"> <i class="fa fa-trash-o" aria-hidden="true"></i></button>
+ {{/if}}
+ </div>
+ {{/with}}
+</div>
<div class="subscription_settings" data-stream-id="{{sub.stream_id}}">
<div class="inner-box">
- <div class="general_settings">
+ <div class="general_settings stream_section">
{{#with sub}}
<div class="stream-header">
{{> subscription_privacy
@@ -15,14 +30,6 @@
<button id="open_stream_info_modal" class="button rounded small btn-warning" title="{{t 'Change stream info' }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
- <div class="sub_unsub_button_wrapper inline-block">
- <button class="button small rounded subscribe-button sub_unsub_button {{#unless subscribed }}unsubscribed{{/unless}}" type="button" name="button" {{#if should_display_subscription_button}}title="{{t 'Toggle subscription'}} (S)" {{else}}disabled="disabled"{{/if}}>
- {{#if subscribed }}{{#tr}}Unsubscribe{{/tr}}{{else}}{{#tr}}Subscribe{{/tr}}{{/if}}</button>
- </div>
- <a href="{{preview_url}}" class="button small rounded" id="preview-stream-button" role="button" title="{{t 'View stream'}} (V)" {{#unless should_display_preview_button }}style="display: none"{{/unless}}><i class="fa fa-eye"></i></a>
- {{#if is_realm_admin}}
- <button class="button small rounded btn-danger deactivate" type="button" name="delete_button" title="{{t 'Archive stream for everyone'}}"> <i class="fa fa-archive" aria-hidden="true"></i></button>
- {{/if}}
</div>
</div>
<div class="stream-description">
@@ -41,7 +48,7 @@
{{/with}}
</div>
- <div class="personal_settings collapse {{#sub.subscribed}}in{{/sub.subscribed}}">
+ <div class="personal_settings stream_section collapse {{#sub.subscribed}}in{{/sub.subscribed}}">
<div id="personal_settings_label_container">
<label class="sub_settings_title inline-block">
{{t "Personal settings" }}
@@ -73,7 +80,7 @@
</div>
</div>
- <div class="subscriber_settings">
+ <div class="subscriber_settings stream_section">
<div class="stream-email-box" {{#unless sub.email_address}}style="display: none;"{{/unless}}>
<label class="sub_settings_title">
{{t "Email address" }}
diff --git a/static/templates/subscription_table_body.hbs b/static/templates/subscription_table_body.hbs
index 7fef4698f20..84aec7f3f28 100644
--- a/static/templates/subscription_table_body.hbs
+++ b/static/templates/subscription_table_body.hbs
@@ -43,7 +43,7 @@
</span>
{{/if}}
</div>
- <div class="settings" data-simplebar data-simplebar-auto-hide="false">
+ <div id="stream_settings" class="settings" data-simplebar data-simplebar-auto-hide="false">
{{!-- edit stream here --}}
</div>
{{> stream_creation_form }}