mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	streams: Add create and edit ui for is_announcement_only.
The user can now specify the value while creating a stream. An admin can later change it via `Change stream permissions` modal. Add is_announcement_only to subscription type text.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							518764b843
						
					
				
				
					commit
					214ce1ccca
				
			@@ -1259,6 +1259,9 @@ run_test('handlebars_bug', () => {
 | 
			
		||||
    assert.equal(other_options[1].value, 'invite-only-public-history');
 | 
			
		||||
    assert.equal(other_options[2].value, 'invite-only');
 | 
			
		||||
 | 
			
		||||
    var is_announcement_only = $(html).find("input[name=is-announcement-only]");
 | 
			
		||||
    assert.equal(is_announcement_only.prop('checked'), false);
 | 
			
		||||
 | 
			
		||||
    var button = $(html).find("#change-stream-privacy-button");
 | 
			
		||||
    assert(button.hasClass("btn-danger"));
 | 
			
		||||
    assert.equal(button.text().trim(), "translated: Save changes");
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ var stream_name_error = (function () {
 | 
			
		||||
}());
 | 
			
		||||
 | 
			
		||||
function ajaxSubscribeForCreation(stream_name, description, principals, invite_only,
 | 
			
		||||
                                  announce, history_public_to_subscribers) {
 | 
			
		||||
                                  is_announcement_only, announce, history_public_to_subscribers) {
 | 
			
		||||
    // Subscribe yourself and possible other people to a new stream.
 | 
			
		||||
    return channel.post({
 | 
			
		||||
        url: "/json/users/me/subscriptions",
 | 
			
		||||
@@ -106,6 +106,7 @@ function ajaxSubscribeForCreation(stream_name, description, principals, invite_o
 | 
			
		||||
                                               description: description}]),
 | 
			
		||||
               principals: JSON.stringify(principals),
 | 
			
		||||
               invite_only: JSON.stringify(invite_only),
 | 
			
		||||
               is_announcement_only: JSON.stringify(is_announcement_only),
 | 
			
		||||
               announce: JSON.stringify(announce),
 | 
			
		||||
               history_public_to_subscribers: JSON.stringify(history_public_to_subscribers),
 | 
			
		||||
        },
 | 
			
		||||
@@ -171,6 +172,7 @@ function create_stream() {
 | 
			
		||||
    var stream_name = $.trim($("#create_stream_name").val());
 | 
			
		||||
    var description = $.trim($("#create_stream_description").val());
 | 
			
		||||
    var privacy_setting = $('#stream_creation_form input[name=privacy]:checked').val();
 | 
			
		||||
    var is_announcement_only = $('#stream_creation_form input[name=is-announcement-only]').prop('checked');
 | 
			
		||||
    var principals = get_principals();
 | 
			
		||||
 | 
			
		||||
    var invite_only;
 | 
			
		||||
@@ -199,6 +201,7 @@ function create_stream() {
 | 
			
		||||
        description,
 | 
			
		||||
        principals,
 | 
			
		||||
        invite_only,
 | 
			
		||||
        is_announcement_only,
 | 
			
		||||
        announce,
 | 
			
		||||
        history_public_to_subscribers
 | 
			
		||||
    );
 | 
			
		||||
 
 | 
			
		||||
@@ -344,6 +344,7 @@ function change_stream_privacy(e) {
 | 
			
		||||
    var sub = stream_data.get_sub_by_id(stream_id);
 | 
			
		||||
 | 
			
		||||
    var privacy_setting = $('#stream_privacy_modal input[name=privacy]:checked').val();
 | 
			
		||||
    var is_announcement_only = $('#stream_privacy_modal input[name=is-announcement-only]').prop('checked');
 | 
			
		||||
 | 
			
		||||
    var invite_only;
 | 
			
		||||
    var history_public_to_subscribers;
 | 
			
		||||
@@ -364,6 +365,7 @@ function change_stream_privacy(e) {
 | 
			
		||||
        stream_name: sub.name,
 | 
			
		||||
        // toggle the privacy setting
 | 
			
		||||
        is_private: JSON.stringify(invite_only),
 | 
			
		||||
        is_announcement_only: JSON.stringify(is_announcement_only),
 | 
			
		||||
        history_public_to_subscribers: JSON.stringify(history_public_to_subscribers),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@@ -376,6 +378,7 @@ function change_stream_privacy(e) {
 | 
			
		||||
 | 
			
		||||
            // save new privacy settings.
 | 
			
		||||
            sub.invite_only = invite_only;
 | 
			
		||||
            sub.is_announcement_only = is_announcement_only;
 | 
			
		||||
            sub.history_public_to_subscribers = history_public_to_subscribers;
 | 
			
		||||
 | 
			
		||||
            redraw_privacy_related_stuff(sub_row, sub);
 | 
			
		||||
@@ -508,6 +511,7 @@ exports.initialize = function () {
 | 
			
		||||
        var template_data = {
 | 
			
		||||
            stream_id: stream_id,
 | 
			
		||||
            stream_name: stream.name,
 | 
			
		||||
            is_announcement_only: stream.is_announcement_only,
 | 
			
		||||
            is_public: !stream.invite_only,
 | 
			
		||||
            is_private: stream.invite_only && !stream.history_public_to_subscribers,
 | 
			
		||||
            is_private_with_public_history: (stream.invite_only &&
 | 
			
		||||
 
 | 
			
		||||
@@ -589,6 +589,10 @@ form#add_new_subscription {
 | 
			
		||||
    margin: 5px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.stream-creation-body #make-invite-only .grey-box .checkbox {
 | 
			
		||||
    margin: 5px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#announce-new-stream {
 | 
			
		||||
    margin-top: 10px;
 | 
			
		||||
}
 | 
			
		||||
@@ -962,7 +966,10 @@ form#add_new_subscription {
 | 
			
		||||
    padding: 5px 0px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#stream_privacy_modal ul.grey-box li input[type=checkbox],
 | 
			
		||||
#stream_privacy_modal ul.grey-box li input[type=checkbox] {
 | 
			
		||||
    margin-top: 4px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#subscription_overlay ul.grey-box li input[type=checkbox] {
 | 
			
		||||
    margin-top: 0px;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,4 +23,11 @@
 | 
			
		||||
            {{/tr}}
 | 
			
		||||
        </label>
 | 
			
		||||
    </li>
 | 
			
		||||
    <li>
 | 
			
		||||
        <label class="checkbox">
 | 
			
		||||
            <input type="checkbox" name="is-announcement-only" value="is-announcement-only" {{#if is_announcement_only}}checked{{/if}}/>
 | 
			
		||||
            <span></span>
 | 
			
		||||
            {{#tr this}}Restrict posting to organization administrators{{/tr}}
 | 
			
		||||
        </label>
 | 
			
		||||
    </li>
 | 
			
		||||
</ul>
 | 
			
		||||
 
 | 
			
		||||
@@ -6,3 +6,6 @@
 | 
			
		||||
{{else}}
 | 
			
		||||
    {{t 'This is a <span class="icon-vector-globe"></span> <b>public stream</b>. Anybody in your organization can join.' }}
 | 
			
		||||
{{/if}}
 | 
			
		||||
{{#if is_announcement_only}}
 | 
			
		||||
{{t 'Only organization administrators can post.'}}
 | 
			
		||||
{{/if}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1620,7 +1620,7 @@ def create_stream_if_needed(realm: Realm,
 | 
			
		||||
                            stream_name: str,
 | 
			
		||||
                            *,
 | 
			
		||||
                            invite_only: bool=False,
 | 
			
		||||
                            is_announcement_only: Optional[bool]=False,
 | 
			
		||||
                            is_announcement_only: bool=False,
 | 
			
		||||
                            history_public_to_subscribers: Optional[bool]=None,
 | 
			
		||||
                            stream_description: str="") -> Tuple[Stream, bool]:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user