mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
create stream: Don't allow creating stream with zero subscribers.
Restrict users(even realm admins) from creating stream with zero subscribers only in UI. In backend, if subscribers are zero, we automatically subscribe current user to stream.
This commit is contained in:
@@ -16,6 +16,22 @@ exports.get_name = function () {
|
||||
return created_stream;
|
||||
};
|
||||
|
||||
var stream_subscription_error = (function () {
|
||||
var self = {};
|
||||
|
||||
self.report_no_subs_to_stream = function () {
|
||||
$("#stream_subscription_error").text(i18n.t("You cannot create a stream with no subscribers!"));
|
||||
$("#stream_subscription_error").show();
|
||||
};
|
||||
|
||||
self.clear_errors = function () {
|
||||
$("#stream_subscription_error").hide();
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
}());
|
||||
|
||||
var stream_name_error = (function () {
|
||||
var self = {};
|
||||
|
||||
@@ -224,6 +240,7 @@ exports.show_new_stream_modal = function () {
|
||||
|
||||
stream_name_error.clear_errors();
|
||||
$(".stream_create_info").hide();
|
||||
stream_subscription_error.clear_errors();
|
||||
|
||||
$("#stream-checkboxes label.checkbox").on('change', function (e) {
|
||||
var elem = $(this);
|
||||
@@ -326,6 +343,11 @@ $(function () {
|
||||
}
|
||||
|
||||
var principals = get_principals();
|
||||
if (principals.length === 0) {
|
||||
stream_subscription_error.report_no_subs_to_stream();
|
||||
return;
|
||||
}
|
||||
|
||||
if (principals.length >= 50) {
|
||||
var invites_warning_modal = templates.render('subscription_invites_warning_modal',
|
||||
{stream_name: stream_name,
|
||||
|
||||
@@ -241,7 +241,7 @@ form#add_new_subscription {
|
||||
width: calc(100% - 15px);
|
||||
}
|
||||
|
||||
#stream_name_error {
|
||||
.stream_creation_error {
|
||||
display: none;
|
||||
margin-left: 2px;
|
||||
color: hsl(0, 100%, 50%);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<input type="text" name="stream_name" id="create_stream_name"
|
||||
placeholder="{{t 'Stream name' }}" value="" autocomplete="off" />
|
||||
<div id="stream_name_error"></div>
|
||||
<div id="stream_name_error" class="stream_creation_error"></div>
|
||||
</section>
|
||||
<section class="block">
|
||||
<div class="stream-title">
|
||||
@@ -60,6 +60,7 @@
|
||||
<label class="stream-title" for="people_to_add">
|
||||
{{t "People to add" }}
|
||||
</label>
|
||||
<div id="stream_subscription_error" class="stream_creation_error"></div>
|
||||
<div class="controls" id="people_to_add"></div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user