stream settings: Display edit icon only if user is allowed to edit.

Only show edit option for stream name and description if user is admin and
either stream is public or stream is private and admin is subscribed to
private stream.
As per backend restrictions for editing stream name/description.
This commit is contained in:
YJDave 2018-01-03 21:09:02 +05:30 committed by Steve Howell
parent 335bed15ee
commit 690e82e624
2 changed files with 6 additions and 2 deletions

View File

@ -166,6 +166,10 @@ exports.render_stream_description = function (sub) {
exports.update_calculated_fields = function (sub) {
sub.is_admin = page_params.is_admin;
// Admin can change stream name/description either stream is public or
// stream is private and admin is subscribed to private stream.
sub.can_change_name_description = page_params.is_admin &&
(!sub.invite_only || (sub.invite_only && sub.subscribed));
sub.can_make_public = page_params.is_admin && sub.invite_only && sub.subscribed;
sub.can_make_private = page_params.is_admin && !sub.invite_only;
sub.preview_url = narrow.by_stream_uri(sub.name);

View File

@ -12,7 +12,7 @@
{{/if}}
<div class="stream-name">
<span class="stream-name-editable editable-section">{{name}}</span>
{{#if is_admin}}
{{#if can_change_name_description}}
<span class="editable" data-make-editable=".stream-name-editable"></span>
<span class="checkmark" data-finish-editing=".stream-name-editable">✓</span>
{{/if}}
@ -25,7 +25,7 @@
</div>
<div class="stream-description" data-no-description="{{t 'No description.' }}">
<span class="stream-description-editable editable-section">{{{rendered_description}}}</span>
{{#if is_admin}}
{{#if can_change_name_description}}
<span class="editable" data-make-editable=".stream-description-editable"></span>
<span class="checkmark" data-finish-editing=".stream-description-editable">✓</span>
{{/if}}