mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
stream: Allow non-admins to create channel without subscribing to it.
Fixes #33125. We now add a creator pill on the channel create screen. For the rule to not allow non admins to create a channel without subscribing to it, the rule was most probably introduced to prevent creating a private channel that you can't access and creating a public channel and then not being able to find it. Those concerns aren't valid anymore with the new group permissions system and UX changes respectively. See https://chat.zulip.org/#narrow/channel/101-design/topic/Rework.20UX.20for.20adding.20everyone.20to.20a.20channel.20or.20group.20.2333127/near/2064926 for more details.
This commit is contained in:
committed by
Tim Abbott
parent
274fdc5908
commit
41c68fad2c
@@ -12,7 +12,6 @@ import {$t, $t_html} from "./i18n.ts";
|
||||
import * as keydown_util from "./keydown_util.ts";
|
||||
import * as loading from "./loading.ts";
|
||||
import * as onboarding_steps from "./onboarding_steps.ts";
|
||||
import * as people from "./people.ts";
|
||||
import * as settings_components from "./settings_components.ts";
|
||||
import * as settings_data from "./settings_data.ts";
|
||||
import {current_user, realm} from "./state_data.ts";
|
||||
@@ -84,16 +83,6 @@ class StreamSubscriptionError {
|
||||
$("#stream_subscription_error").show();
|
||||
}
|
||||
|
||||
cant_create_stream_without_subscribing(): void {
|
||||
$("#stream_subscription_error").text(
|
||||
$t({
|
||||
defaultMessage:
|
||||
"You must be an organization administrator to create a channel without subscribing.",
|
||||
}),
|
||||
);
|
||||
$("#stream_subscription_error").show();
|
||||
}
|
||||
|
||||
clear_errors(): void {
|
||||
$("#stream_subscription_error").hide();
|
||||
}
|
||||
@@ -596,11 +585,6 @@ export function set_up_handlers(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!principals.includes(people.my_current_user_id()) && !current_user.is_admin) {
|
||||
stream_subscription_error.cant_create_stream_without_subscribing();
|
||||
return;
|
||||
}
|
||||
|
||||
if (principals.length >= 50) {
|
||||
const html_body = render_subscription_invites_warning_modal({
|
||||
channel_name: stream_name,
|
||||
|
@@ -11,6 +11,7 @@ import {current_user} from "./state_data.ts";
|
||||
import * as stream_create_subscribers_data from "./stream_create_subscribers_data.ts";
|
||||
import type {CombinedPillContainer} from "./typeahead_helper.ts";
|
||||
import * as user_groups from "./user_groups.ts";
|
||||
import * as user_pill from "./user_pill.ts";
|
||||
import * as user_sort from "./user_sort.ts";
|
||||
|
||||
export let pill_widget: CombinedPillContainer;
|
||||
@@ -113,7 +114,6 @@ export function build_widgets(): void {
|
||||
user_id: user.user_id,
|
||||
full_name: user.full_name,
|
||||
is_current_user: user.user_id === current_user_id,
|
||||
disabled: stream_create_subscribers_data.must_be_subscribed(user.user_id),
|
||||
img_src: people.small_avatar_url_for_person(user),
|
||||
soft_removed: stream_create_subscribers_data.user_id_in_soft_remove_list(
|
||||
user.user_id,
|
||||
@@ -137,6 +137,8 @@ export function build_widgets(): void {
|
||||
return $(`#${CSS.escape("user_checkbox_" + user.user_id)}`);
|
||||
},
|
||||
});
|
||||
const current_person = people.get_by_user_id(current_user.user_id);
|
||||
user_pill.append_user(current_person, pill_widget);
|
||||
}
|
||||
|
||||
export function add_user_id_to_new_stream(user_id: number): void {
|
||||
|
@@ -35,11 +35,6 @@ export function get_potential_subscribers(): User[] {
|
||||
const potential_subscribers = people.get_realm_users();
|
||||
return potential_subscribers.filter((user) => !user_id_set.has(user.user_id));
|
||||
}
|
||||
|
||||
export function must_be_subscribed(user_id: number): boolean {
|
||||
return !current_user.is_admin && user_id === current_user.user_id;
|
||||
}
|
||||
|
||||
export function add_user_ids(user_ids: number[]): void {
|
||||
for (const user_id of user_ids) {
|
||||
if (!user_id_set.has(user_id)) {
|
||||
@@ -62,12 +57,6 @@ export function remove_user_ids(user_ids: number[]): void {
|
||||
}
|
||||
|
||||
export function sync_user_ids(user_ids: number[]): void {
|
||||
// Current user does not have their pill in their input
|
||||
// box, so we need to make sure that we don't delete
|
||||
// it unnecessarily while syncing.
|
||||
if (user_id_set.has(current_user.user_id)) {
|
||||
user_ids.push(current_user.user_id);
|
||||
}
|
||||
user_id_set = new Set(user_ids);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
{{#if soft_removed}}
|
||||
<button data-user-id="{{user_id}}" class="undo_soft_removed_potential_subscriber button small rounded white">{{t 'Add' }}</button>
|
||||
{{else}}
|
||||
<button {{#if disabled}} disabled="disabled"{{/if}} data-user-id="{{user_id}}" class="remove_potential_subscriber button small rounded white">{{t 'Remove' }}</button>
|
||||
<button data-user-id="{{user_id}}" class="remove_potential_subscriber button small rounded white">{{t 'Remove' }}</button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
|
@@ -68,33 +68,11 @@ test("basics", () => {
|
||||
test_user101,
|
||||
test_user103,
|
||||
]);
|
||||
|
||||
assert.ok(stream_create_subscribers_data.must_be_subscribed(me.user_id));
|
||||
assert.ok(!stream_create_subscribers_data.must_be_subscribed(test_user101.user_id));
|
||||
});
|
||||
|
||||
test("must_be_subscribed", ({override}) => {
|
||||
override(current_user, "is_admin", false);
|
||||
assert.ok(stream_create_subscribers_data.must_be_subscribed(me.user_id));
|
||||
assert.ok(!stream_create_subscribers_data.must_be_subscribed(test_user101.user_id));
|
||||
override(current_user, "is_admin", true);
|
||||
assert.ok(!stream_create_subscribers_data.must_be_subscribed(me.user_id));
|
||||
assert.ok(!stream_create_subscribers_data.must_be_subscribed(test_user101.user_id));
|
||||
});
|
||||
|
||||
test("sync_user_ids", () => {
|
||||
// sync_user_ids should not remove current user if already present.
|
||||
stream_create_subscribers_data.initialize_with_current_user();
|
||||
stream_create_subscribers_data.sync_user_ids([test_user101.user_id, test_user102.user_id]);
|
||||
assert.deepEqual(stream_create_subscribers_data.sorted_user_ids(), [
|
||||
me.user_id,
|
||||
test_user101.user_id,
|
||||
test_user102.user_id,
|
||||
]);
|
||||
|
||||
// sync_user_ids should not add current user if already not present.
|
||||
stream_create_subscribers_data.remove_user_ids([me.user_id]);
|
||||
stream_create_subscribers_data.sync_user_ids([test_user101.user_id, test_user102.user_id]);
|
||||
assert.deepEqual(stream_create_subscribers_data.sorted_user_ids(), [
|
||||
test_user101.user_id,
|
||||
test_user102.user_id,
|
||||
|
Reference in New Issue
Block a user