mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
left_sidebar: Hide new topic button on restricted compose permission.
Earlier, in left stream sidebar, new topic button was shown for all stream rows irrespective of compose permission of the user for individual streams. This commit changes the behaviour by hiding the new topic button if user doesn't have appropriate compose permission for individual streams. Fixes: zulip#31800.
This commit is contained in:
committed by
Karl Stolley
parent
d8cf3ff2e9
commit
34ff1de338
@@ -445,6 +445,7 @@ export function set_in_home_view(stream_id: number, in_home: boolean): void {
|
|||||||
function build_stream_sidebar_li(sub: StreamSubscription): JQuery {
|
function build_stream_sidebar_li(sub: StreamSubscription): JQuery {
|
||||||
const name = sub.name;
|
const name = sub.name;
|
||||||
const is_muted = stream_data.is_muted(sub.stream_id);
|
const is_muted = stream_data.is_muted(sub.stream_id);
|
||||||
|
const can_post_messages = stream_data.can_post_messages_in_stream(sub);
|
||||||
const args = {
|
const args = {
|
||||||
name,
|
name,
|
||||||
id: sub.stream_id,
|
id: sub.stream_id,
|
||||||
@@ -455,6 +456,7 @@ function build_stream_sidebar_li(sub: StreamSubscription): JQuery {
|
|||||||
color: sub.color,
|
color: sub.color,
|
||||||
pin_to_top: sub.pin_to_top,
|
pin_to_top: sub.pin_to_top,
|
||||||
hide_unread_count: settings_data.should_mask_unread_count(is_muted),
|
hide_unread_count: settings_data.should_mask_unread_count(is_muted),
|
||||||
|
can_post_messages,
|
||||||
};
|
};
|
||||||
const $list_item = $(render_stream_sidebar_row(args));
|
const $list_item = $(render_stream_sidebar_row(args));
|
||||||
return $list_item;
|
return $list_item;
|
||||||
|
@@ -11,9 +11,11 @@
|
|||||||
<a href="{{url}}" title="{{name}}" class="stream-name">{{name}}</a>
|
<a href="{{url}}" title="{{name}}" class="stream-name">{{name}}</a>
|
||||||
|
|
||||||
<div class="left-sidebar-controls">
|
<div class="left-sidebar-controls">
|
||||||
|
{{#if can_post_messages}}
|
||||||
<div class="channel-new-topic-button tippy-zulip-tooltip hidden-for-spectators" data-tippy-content="{{t 'New topic'}}" data-stream-id="{{id}}">
|
<div class="channel-new-topic-button tippy-zulip-tooltip hidden-for-spectators" data-tippy-content="{{t 'New topic'}}" data-stream-id="{{id}}">
|
||||||
<i class="channel-new-topic-icon zulip-icon zulip-icon-square-plus" aria-hidden="true"></i>
|
<i class="channel-new-topic-icon zulip-icon zulip-icon-square-plus" aria-hidden="true"></i>
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="stream-markers-and-unreads">
|
<div class="stream-markers-and-unreads">
|
||||||
|
@@ -7,9 +7,14 @@ const {run_test, noop} = require("./lib/test");
|
|||||||
const $ = require("./lib/zjquery");
|
const $ = require("./lib/zjquery");
|
||||||
const {page_params} = require("./lib/zpage_params");
|
const {page_params} = require("./lib/zpage_params");
|
||||||
|
|
||||||
|
const people = zrequire("people");
|
||||||
|
const {set_current_user} = zrequire("state_data");
|
||||||
|
|
||||||
set_global("document", "document-stub");
|
set_global("document", "document-stub");
|
||||||
|
|
||||||
page_params.realm_users = [];
|
page_params.realm_users = [];
|
||||||
|
const current_user = {};
|
||||||
|
set_current_user(current_user);
|
||||||
|
|
||||||
// We use this with override.
|
// We use this with override.
|
||||||
let unread_unmuted_count;
|
let unread_unmuted_count;
|
||||||
@@ -39,6 +44,16 @@ const {initialize_user_settings} = zrequire("user_settings");
|
|||||||
const user_settings = {};
|
const user_settings = {};
|
||||||
initialize_user_settings({user_settings});
|
initialize_user_settings({user_settings});
|
||||||
|
|
||||||
|
const me = {
|
||||||
|
email: "me@example.com",
|
||||||
|
user_id: 30,
|
||||||
|
full_name: "Me Myself",
|
||||||
|
date_joined: new Date(),
|
||||||
|
};
|
||||||
|
|
||||||
|
people.add_active_user(me);
|
||||||
|
people.initialize_current_user(me.user_id);
|
||||||
|
|
||||||
const devel = {
|
const devel = {
|
||||||
name: "devel",
|
name: "devel",
|
||||||
stream_id: 100,
|
stream_id: 100,
|
||||||
@@ -673,6 +688,7 @@ test_ui("rename_stream", ({mock_template, override}) => {
|
|||||||
color: payload.color,
|
color: payload.color,
|
||||||
pin_to_top: true,
|
pin_to_top: true,
|
||||||
hide_unread_count: true,
|
hide_unread_count: true,
|
||||||
|
can_post_messages: true,
|
||||||
});
|
});
|
||||||
return {to_$: () => $li_stub};
|
return {to_$: () => $li_stub};
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user