stream_settings: Disable stream-privacy choices according to org settings.

The public and private stream choices in stream creation form are disabled
according to create_public_stream_policy and create_private_stream_policy
settings. It is not needed to disable them in stream privacy modal since
only admins can change the privacy of stream and they are allowed to
create public and private streams always irrespective of the setting.
This commit is contained in:
Sahil Batra 2021-11-22 23:31:40 +05:30 committed by Tim Abbott
parent 25ba96488d
commit 5607712794
1 changed files with 22 additions and 0 deletions

View File

@ -1009,6 +1009,28 @@ export function hide_or_disable_stream_privacy_options_if_required(container) {
}
}
}
if (!settings_data.user_can_create_public_streams()) {
const public_stream_elem = container.find(
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.public.code)}']`,
);
public_stream_elem.prop("disabled", true);
}
if (!settings_data.user_can_create_private_streams()) {
// Disable both "Private, shared history" and "Private, protected history" options.
const private_stream_elem = container.find(
`input[value='${CSS.escape(stream_data.stream_privacy_policy_values.private.code)}']`,
);
const private_with_public_history_elem = container.find(
`input[value='${CSS.escape(
stream_data.stream_privacy_policy_values.private_with_public_history.code,
)}']`,
);
private_stream_elem.prop("disabled", true);
private_with_public_history_elem.prop("disabled", true);
}
}
export function initialize() {