Split out Organization Permissions page.

This commit is contained in:
Steve Howell 2017-05-18 05:06:57 -07:00 committed by Tim Abbott
parent 3e4fb01685
commit e00f9f3dcb
10 changed files with 205 additions and 157 deletions

View File

@ -19,6 +19,11 @@ casper.waitForSelector('#settings_overlay_container.show', function () {
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, 'URL suggests we are on organization page');
});
// Test permissions setting
casper.then(function () {
casper.click("li[data-section='organization-permissions']");
});
// Test setting limiting stream creation to administrators
casper.then(function () {
casper.click('#id_realm_create_stream_by_admins_only + span');

View File

@ -79,6 +79,15 @@ casper.then(function () {
casper.click('a[href^="#organization"]');
});
casper.waitForSelector('#settings_overlay_container.show', function () {
casper.test.info('Organization page is active');
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, 'URL suggests we are on organization page');
});
casper.then(function () {
casper.click("li[data-section='organization-permissions']");
});
// deactivate "allow message editing"
casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editing"] + span', function () {
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');

View File

@ -10,6 +10,8 @@ exports.show_or_hide_menu_item = function () {
item.find("span").text(i18n.t("Organization settings"));
$(".organization-box [data-name='organization-settings']")
.find("input, textarea, button, select").attr("disabled", true);
$(".organization-box [data-name='organization-permissions']")
.find("input, textarea, button, select").attr("disabled", true);
$(".organization-box [data-name='auth-methods']")
.find("input, button, select, checked").attr("disabled", true);
$(".organization-box [data-name='default-streams-list']")

View File

@ -9,6 +9,7 @@ exports.load_admin_section = function (name) {
switch (name) {
case 'organization-settings':
case 'organization-permissions':
case 'auth-methods':
section = 'org';
break;

View File

@ -59,6 +59,7 @@ function _setup_page() {
"muted-topics": i18n.t("Muted topics"),
"zulip-labs": i18n.t("Zulip labs"),
"organization-settings": i18n.t("Organization settings"),
"organization-permissions": i18n.t("Organization permissions"),
"emoji-settings": i18n.t("Emoji settings"),
"auth-methods": i18n.t("Authorization methods"),
"user-list-admin": i18n.t("Active users"),

View File

@ -135,11 +135,8 @@ exports.set_up = function () {
});
$(".organization").on("submit", "form.admin-realm-form", function (e) {
// TODO: We actually have two forms named admin-realm-form. We really
// should break out a separate endpoint to update the realm's
// auth backends, and then we can make our code more modular by
// having two different form classes, two different click handlers,
// and a separate JS module for handling auth backends.
// TODO: We actually have three forms named admin-realm-form. We really
// should break out three separate forms.
var name_status = $("#admin-realm-name-status").expectOne();
var description_status = $("#admin-realm-description-status").expectOne();

View File

@ -5,6 +5,7 @@
{{ partial "realm-domains-modal" }}
{{ partial "organization-settings-admin" }}
{{ partial "organization-permissions-admin" }}
{{ partial "emoji-settings-admin" }}

View File

@ -0,0 +1,180 @@
<div id="organization-permissions" data-name="organization-permissions" class="settings-section">
<form class="form-horizontal admin-realm-form">
<h3 class="light">{{t "Organization permissions" }}</h3>
<div class="alert" id="admin-realm-restricted-to-domain-status"></div>
<div class="alert" id="admin-realm-invite-required-status"></div>
<div class="alert" id="admin-realm-invite-by-admins-only-status"></div>
<div class="alert" id="admin-realm-inline-image-preview-status"></div>
<div class="alert" id="admin-realm-inline-url-embed-preview-status"></div>
<div class="alert" id="admin-realm-create-stream-by-admins-only-status"></div>
<div class="alert" id="admin-realm-add-emoji-by-admins-only-status"></div>
<div class="alert" id="admin-realm-message-editing-status"></div>
<div class="alert" id="admin-realm-name-changes-disabled-status"></div>
<div class="alert" id="admin-realm-email-changes-disabled-status"></div>
<div class="m-10 inline-block organization-permissions-parent">
<div class="input-group admin-restricted-to-domain">
<label class="checkbox">
<input type="checkbox" name="realm_restricted_to_domain" id="id_realm_restricted_to_domain"
{{#if realm_restricted_to_domain}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_restricted_to_domain" id="realm_restricted_to_domains_label" class="inline-block"
title="{{#tr this}}If checked, only users with an e-mail address ending in these domains will be able to join the organization.{{/tr}}">
</label>
{{#if is_admin }}
<a data-toggle="modal" href="#realm_domains_modal">{{t "[Add or Change]" }}</a>
{{/if}}
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" name="realm_invite_required" id="id_realm_invite_required"
{{#if realm_invite_required}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_invite_required" id="realm_restricted_to_domains_label" class="inline-block"
title="{{t 'If checked, users must be invited in order to join your organization.' }}">
{{t "E-mail invitation required" }}
</label>
</div>
<div class="input-group disableable {{#unless realm_invite_required}}control-label-disabled{{/unless}}">
<label class="checkbox">
<input type="checkbox" name="realm_invite_by_admins_only" id="id_realm_invite_by_admins_only"
{{#unless realm_invite_required}}disabled="disabled"{{/unless}}
{{#if realm_invite_by_admins_only}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_invite_by_admins_only" id="id_realm_invite_by_admins_only_label" class="inline-block"
title="{{t 'If checked, only administrators may invite new users.' }}">
{{t "Only admins may invite" }}
</label>
</div>
{{#if server_inline_image_preview}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_inline_image_preview" name="realm_inline_image_preview"
{{#if realm_inline_image_preview}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_inline_image_preview" id="id_realm_inline_image_preview_label" class="inline-block"
title="{{t 'If checked, image previews will be shown.' }}">
{{t "Show previews of uploaded and linked images" }}
</label>
</div>
{{/if}}
{{#if server_inline_url_embed_preview}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_inline_url_embed_preview" name="realm_inline_url_embed_preview"
{{#if realm_inline_url_embed_preview}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_inline_url_embed_preview" id="id_realm_inline_url_embed_preview_label" class="inline-block"
title="{{t 'If checked, previews of linked websites will be shown.' }}">
{{t "Show previews of linked websites" }}
</label>
</div>
{{/if}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_create_stream_by_admins_only" name="realm_create_stream_by_admins_only"
{{#if realm_create_stream_by_admins_only}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_create_stream_by_admins_only" id="id_realm_create_stream_by_admins_only_label" class="inline-block"
title="{{t 'If checked, only administrators may create new streams.' }}">
{{t "Only admins may create streams" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_name_changes_disabled" name="realm_name_changes_disabled"
{{#if realm_name_changes_disabled}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_name_changes_disabled" id="id_realm_name_changes_disabled_label" class="inline-block"
title="{{t 'If checked, users will be unable to change their name.' }}">
{{t "Prevent users from changing their name" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_email_changes_disabled" name="realm_email_changes_disabled"
{{#if realm_email_changes_disabled}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_email_changes_disabled" id="id_realm_email_changes_disabled_label" class="inline-block"
title="{{t 'If checked, users will be unable to change their email address.' }}">
{{t "Prevent users from changing their email address" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_add_emoji_by_admins_only" name="realm_add_emoji_by_admins_only"
{{#if realm_add_emoji_by_admins_only}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_add_emoji_by_admins_only" id="id_realm_add_emoji_by_admins_only_label" class="inline-block"
title="{{t 'If checked, only administrators may add new emoji.'}}">
{{t "Only admins may add emoji" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_allow_message_editing" name="realm_allow_message_editing"
{{#if realm_allow_message_editing}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_allow_message_editing" class="inline-block"
title="{{t 'If checked, users can edit the content and topics of their old messages.' }}">
{{t "Users can edit old messages" }}
</label>
</div>
<div class="input-group disableable {{#unless realm_allow_message_editing}}control-label-disabled{{/unless}}">
<label for="realm_message_content_edit_limit_minutes"
id="id_realm_message_content_edit_limit_minutes_label"
title="{{t 'If non-zero, users can edit their message for this many minutes after it is sent. If zero, users can edit all their past messages.' }}">
{{t 'Message edit limit in minutes (0 for no limit)' }}
</label>
<input type="text" id="id_realm_message_content_edit_limit_minutes"
name="realm_message_content_edit_limit_minutes"
class="admin-realm-message-content-edit-limit-minutes"
value="{{ realm_message_content_edit_limit_minutes }}"
{{#unless realm_allow_message_editing}}disabled="disabled"{{/unless}} />
</div>
{{#if false}}
<div class="input-group">
<label for="realm_message_retention_days"
id="id_realm_message_retention_days_label"
title="{{t 'Messages older than the configured number of days will be automatically deleted' }}">
{{t 'Messages retention period in days (blank means messages are retained forever)' }}
</label>
<input type="text" id="id_realm_message_retention_days"
name="realm_message_retention_days"
class="admin-realm-message-retention-days"
value="{{ realm_message_retention_days }}"/>
</div>
{{/if}}
{{#if is_admin }}
<div class="input-group organization-submission">
<button type="submit" class="button white rounded sea-green">
{{t 'Save changes' }}
</button>
</div>
{{/if}}
</div>
</form>
</div>

View File

@ -4,18 +4,8 @@
<div class="alert" id="admin-realm-name-status"></div>
<div class="alert" id="admin-realm-description-status"></div>
<div class="alert" id="admin-realm-restricted-to-domain-status"></div>
<div class="alert" id="admin-realm-invite-required-status"></div>
<div class="alert" id="admin-realm-invite-by-admins-only-status"></div>
<div class="alert" id="admin-realm-inline-image-preview-status"></div>
<div class="alert" id="admin-realm-inline-url-embed-preview-status"></div>
<div class="alert" id="admin-realm-create-stream-by-admins-only-status"></div>
<div class="alert" id="admin-realm-add-emoji-by-admins-only-status"></div>
<div class="alert" id="admin-realm-message-editing-status"></div>
<div class="alert" id="admin-realm-default-language-status"></div>
<div class="alert" id="admin-realm-waiting_period_threshold_status"></div>
<div class="alert" id="admin-realm-name-changes-disabled-status"></div>
<div class="alert" id="admin-realm-email-changes-disabled-status"></div>
<div class="m-10 inline-block organization-settings-parent">
<div class="input-group admin-realm">
@ -28,148 +18,6 @@
<textarea id="id_realm_description" name="realm_description" class="admin-realm-description"
maxlength="1000">{{ realm_description }}</textarea>
</div>
<div class="input-group admin-restricted-to-domain">
<label class="checkbox">
<input type="checkbox" name="realm_restricted_to_domain" id="id_realm_restricted_to_domain"
{{#if realm_restricted_to_domain}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_restricted_to_domain" id="realm_restricted_to_domains_label" class="inline-block"
title="{{#tr this}}If checked, only users with an e-mail address ending in these domains will be able to join the organization.{{/tr}}">
</label>
{{#if is_admin }}
<a data-toggle="modal" href="#realm_domains_modal">{{t "[Add or Change]" }}</a>
{{/if}}
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" name="realm_invite_required" id="id_realm_invite_required"
{{#if realm_invite_required}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_invite_required" id="realm_restricted_to_domains_label" class="inline-block"
title="{{t 'If checked, users must be invited in order to join your organization.' }}">
{{t "E-mail invitation required" }}
</label>
</div>
<div class="input-group disableable {{#unless realm_invite_required}}control-label-disabled{{/unless}}">
<label class="checkbox">
<input type="checkbox" name="realm_invite_by_admins_only" id="id_realm_invite_by_admins_only"
{{#unless realm_invite_required}}disabled="disabled"{{/unless}}
{{#if realm_invite_by_admins_only}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_invite_by_admins_only" id="id_realm_invite_by_admins_only_label" class="inline-block"
title="{{t 'If checked, only administrators may invite new users.' }}">
{{t "Only admins may invite" }}
</label>
</div>
{{#if server_inline_image_preview}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_inline_image_preview" name="realm_inline_image_preview"
{{#if realm_inline_image_preview}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_inline_image_preview" id="id_realm_inline_image_preview_label" class="inline-block"
title="{{t 'If checked, image previews will be shown.' }}">
{{t "Show previews of uploaded and linked images" }}
</label>
</div>
{{/if}}
{{#if server_inline_url_embed_preview}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_inline_url_embed_preview" name="realm_inline_url_embed_preview"
{{#if realm_inline_url_embed_preview}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_inline_url_embed_preview" id="id_realm_inline_url_embed_preview_label" class="inline-block"
title="{{t 'If checked, previews of linked websites will be shown.' }}">
{{t "Show previews of linked websites" }}
</label>
</div>
{{/if}}
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_create_stream_by_admins_only" name="realm_create_stream_by_admins_only"
{{#if realm_create_stream_by_admins_only}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_create_stream_by_admins_only" id="id_realm_create_stream_by_admins_only_label" class="inline-block"
title="{{t 'If checked, only administrators may create new streams.' }}">
{{t "Only admins may create streams" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_name_changes_disabled" name="realm_name_changes_disabled"
{{#if realm_name_changes_disabled}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_name_changes_disabled" id="id_realm_name_changes_disabled_label" class="inline-block"
title="{{t 'If checked, users will be unable to change their name.' }}">
{{t "Prevent users from changing their name" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_email_changes_disabled" name="realm_email_changes_disabled"
{{#if realm_email_changes_disabled}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_email_changes_disabled" id="id_realm_email_changes_disabled_label" class="inline-block"
title="{{t 'If checked, users will be unable to change their email address.' }}">
{{t "Prevent users from changing their email address" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_add_emoji_by_admins_only" name="realm_add_emoji_by_admins_only"
{{#if realm_add_emoji_by_admins_only}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_add_emoji_by_admins_only" id="id_realm_add_emoji_by_admins_only_label" class="inline-block"
title="{{t 'If checked, only administrators may add new emoji.'}}">
{{t "Only admins may add emoji" }}
</label>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_allow_message_editing" name="realm_allow_message_editing"
{{#if realm_allow_message_editing}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_allow_message_editing" class="inline-block"
title="{{t 'If checked, users can edit the content and topics of their old messages.' }}">
{{t "Users can edit old messages" }}
</label>
</div>
<div class="input-group disableable {{#unless realm_allow_message_editing}}control-label-disabled{{/unless}}">
<label for="realm_message_content_edit_limit_minutes"
id="id_realm_message_content_edit_limit_minutes_label"
title="{{t 'If non-zero, users can edit their message for this many minutes after it is sent. If zero, users can edit all their past messages.' }}">
{{t 'Message edit limit in minutes (0 for no limit)' }}
</label>
<input type="text" id="id_realm_message_content_edit_limit_minutes"
name="realm_message_content_edit_limit_minutes"
class="admin-realm-message-content-edit-limit-minutes"
value="{{ realm_message_content_edit_limit_minutes }}"
{{#unless realm_allow_message_editing}}disabled="disabled"{{/unless}} />
</div>
{{#if false}}
<div class="input-group">
<label for="realm_message_retention_days"
id="id_realm_message_retention_days_label"
title="{{t 'Messages older than the configured number of days will be automatically deleted' }}">
{{t 'Messages retention period in days (blank means messages are retained forever)' }}
</label>
<input type="text" id="id_realm_message_retention_days"
name="realm_message_retention_days"
class="admin-realm-message-retention-days"
value="{{ realm_message_retention_days }}"/>
</div>
{{/if}}
<div class="input-group">
<label for="realm_default_language">{{t "Default language" }}:</label>
<select name="realm_default_language" id="id_realm_default_language">

View File

@ -48,6 +48,10 @@
<i class="icon icon-vector-beaker"></i>
<div class="text">{{ _('Organization settings') }}</div>
</li>
<li class="admin" tabindex="1" data-section="organization-permissions">
<i class="icon icon-vector-lock"></i>
<div class="text">{{ _('Organization permissions') }}</div>
</li>
<li class="admin" tabindex="1" data-section="emoji-settings">
<i class="icon icon-vector-smile"></i>
<div class="text">{{ _('Custom emoji') }}</div>