mirror of
https://github.com/zulip/zulip.git
synced 2025-10-27 01:53:59 +00:00
frontend: Add org_type to realm settings updates and events.
Adds a drop-down menu for updating the organization type in the `organization_profile_admin` page. Implements front end for this setting to work / update like other organization profile, notification and permissions settings. One special note about this dropdown is that the listed options should change once an organization has successfully set a type other than 'unspecified' in the database. To accomplish this the initial settings overlay build checks the realm_org_type value in the page_params to select the correct options list, and when the dropdown value is reset, either for update events or for discarding changes, the page_params value is again used to check for whether the 'unspecified' value should be present as an option in the dropdown menu. Adds basic node test for the `server_events_dispatch`. Also adds a new help center documentation article for this organization setting that is linked to in the UI. Fixes #21692.
This commit is contained in:
committed by
Tim Abbott
parent
d2207d4ad5
commit
1292338537
@@ -392,6 +392,10 @@ run_test("realm settings", ({override}) => {
|
|||||||
});
|
});
|
||||||
assert_same(page_params.realm_name, "new_realm_name");
|
assert_same(page_params.realm_name, "new_realm_name");
|
||||||
|
|
||||||
|
event = event_fixtures.realm__update__org_type;
|
||||||
|
dispatch(event);
|
||||||
|
assert_same(page_params.realm_org_type, 50);
|
||||||
|
|
||||||
event = event_fixtures.realm__update__emails_restricted_to_domains;
|
event = event_fixtures.realm__update__emails_restricted_to_domains;
|
||||||
test_realm_boolean(event, "realm_emails_restricted_to_domains");
|
test_realm_boolean(event, "realm_emails_restricted_to_domains");
|
||||||
|
|
||||||
|
|||||||
@@ -342,6 +342,13 @@ exports.fixtures = {
|
|||||||
value: 42,
|
value: 42,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
realm__update__org_type: {
|
||||||
|
type: "realm",
|
||||||
|
op: "update",
|
||||||
|
property: "org_type",
|
||||||
|
value: 50,
|
||||||
|
},
|
||||||
|
|
||||||
realm__update__signup_notifications_stream_id: {
|
realm__update__signup_notifications_stream_id: {
|
||||||
type: "realm",
|
type: "realm",
|
||||||
op: "update",
|
op: "update",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ export function build_page() {
|
|||||||
const options = {
|
const options = {
|
||||||
custom_profile_field_types: page_params.custom_profile_field_types,
|
custom_profile_field_types: page_params.custom_profile_field_types,
|
||||||
realm_name: page_params.realm_name,
|
realm_name: page_params.realm_name,
|
||||||
|
realm_org_type: page_params.realm_org_type,
|
||||||
realm_available_video_chat_providers: page_params.realm_available_video_chat_providers,
|
realm_available_video_chat_providers: page_params.realm_available_video_chat_providers,
|
||||||
giphy_rating_options: page_params.giphy_rating_options,
|
giphy_rating_options: page_params.giphy_rating_options,
|
||||||
giphy_api_key_empty: page_params.giphy_api_key === "",
|
giphy_api_key_empty: page_params.giphy_api_key === "",
|
||||||
@@ -162,6 +163,7 @@ export function build_page() {
|
|||||||
disable_enable_spectator_access_setting: !page_params.server_web_public_streams_enabled,
|
disable_enable_spectator_access_setting: !page_params.server_web_public_streams_enabled,
|
||||||
can_sort_by_email: settings_data.show_email(),
|
can_sort_by_email: settings_data.show_email(),
|
||||||
realm_push_notifications_enabled: page_params.realm_push_notifications_enabled,
|
realm_push_notifications_enabled: page_params.realm_push_notifications_enabled,
|
||||||
|
realm_org_type_values: settings_org.get_org_type_dropdown_options(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") {
|
if (options.realm_logo_source !== "D" && options.realm_night_logo_source === "D") {
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ export function dispatch_normal_event(event) {
|
|||||||
name: notifications.redraw_title,
|
name: notifications.redraw_title,
|
||||||
name_changes_disabled: settings_account.update_name_change_display,
|
name_changes_disabled: settings_account.update_name_change_display,
|
||||||
notifications_stream_id: noop,
|
notifications_stream_id: noop,
|
||||||
|
org_type: noop,
|
||||||
private_message_policy: noop,
|
private_message_policy: noop,
|
||||||
send_welcome_emails: noop,
|
send_welcome_emails: noop,
|
||||||
message_content_allowed_in_email_notifications: noop,
|
message_content_allowed_in_email_notifications: noop,
|
||||||
|
|||||||
@@ -441,6 +441,71 @@ export const user_role_values = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const all_org_type_values = {
|
||||||
|
// When org_type was added to the database model, 'unspecified'
|
||||||
|
// was the default for existing organizations. To discourage
|
||||||
|
// organizations keeping (or selecting) it as an option, we
|
||||||
|
// use an empty string for its description.
|
||||||
|
unspecified: {
|
||||||
|
code: 0,
|
||||||
|
description: "",
|
||||||
|
},
|
||||||
|
business: {
|
||||||
|
code: 10,
|
||||||
|
description: $t({defaultMessage: "Business"}),
|
||||||
|
},
|
||||||
|
opensource: {
|
||||||
|
code: 20,
|
||||||
|
description: $t({defaultMessage: "Open-source project"}),
|
||||||
|
},
|
||||||
|
education_nonprofit: {
|
||||||
|
code: 30,
|
||||||
|
description: $t({defaultMessage: "Education (non-profit)"}),
|
||||||
|
},
|
||||||
|
education: {
|
||||||
|
code: 35,
|
||||||
|
description: $t({defaultMessage: "Education (for-profit)"}),
|
||||||
|
},
|
||||||
|
research: {
|
||||||
|
code: 40,
|
||||||
|
description: $t({defaultMessage: "Research"}),
|
||||||
|
},
|
||||||
|
event: {
|
||||||
|
code: 50,
|
||||||
|
description: $t({defaultMessage: "Event or conference"}),
|
||||||
|
},
|
||||||
|
nonprofit: {
|
||||||
|
code: 60,
|
||||||
|
description: $t({defaultMessage: "Non-profit (registered)"}),
|
||||||
|
},
|
||||||
|
government: {
|
||||||
|
code: 70,
|
||||||
|
description: $t({defaultMessage: "Government"}),
|
||||||
|
},
|
||||||
|
political_group: {
|
||||||
|
code: 80,
|
||||||
|
description: $t({defaultMessage: "Political group"}),
|
||||||
|
},
|
||||||
|
community: {
|
||||||
|
code: 90,
|
||||||
|
description: $t({defaultMessage: "Community"}),
|
||||||
|
},
|
||||||
|
personal: {
|
||||||
|
code: 100,
|
||||||
|
description: $t({defaultMessage: "Personal"}),
|
||||||
|
},
|
||||||
|
other: {
|
||||||
|
code: 1000,
|
||||||
|
description: $t({defaultMessage: "Other"}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Remove the 'unspecified' org_type for dropdown menu options
|
||||||
|
// when an org_type other than 'unspecified' has been selected.
|
||||||
|
export const defined_org_type_values = Object.fromEntries(
|
||||||
|
Object.entries(all_org_type_values).slice(1),
|
||||||
|
);
|
||||||
|
|
||||||
export const expires_in_values = {
|
export const expires_in_values = {
|
||||||
// Backend support for this configuration is not available yet.
|
// Backend support for this configuration is not available yet.
|
||||||
// hour: {
|
// hour: {
|
||||||
|
|||||||
@@ -116,6 +116,14 @@ export function get_organization_settings_options() {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function get_org_type_dropdown_options() {
|
||||||
|
const current_org_type = page_params.realm_org_type;
|
||||||
|
if (current_org_type !== 0) {
|
||||||
|
return settings_config.defined_org_type_values;
|
||||||
|
}
|
||||||
|
return settings_config.all_org_type_values;
|
||||||
|
}
|
||||||
|
|
||||||
export function get_realm_time_limits_in_minutes(property) {
|
export function get_realm_time_limits_in_minutes(property) {
|
||||||
let val = (page_params[property] / 60).toFixed(1);
|
let val = (page_params[property] / 60).toFixed(1);
|
||||||
if (Number.parseFloat(val, 10) === Number.parseInt(val, 10)) {
|
if (Number.parseFloat(val, 10) === Number.parseInt(val, 10)) {
|
||||||
@@ -238,6 +246,7 @@ const simple_dropdown_properties = [
|
|||||||
"realm_wildcard_mention_policy",
|
"realm_wildcard_mention_policy",
|
||||||
"realm_move_messages_between_streams_policy",
|
"realm_move_messages_between_streams_policy",
|
||||||
"realm_edit_topic_policy",
|
"realm_edit_topic_policy",
|
||||||
|
"realm_org_type",
|
||||||
];
|
];
|
||||||
|
|
||||||
function set_property_dropdown_value(property_name) {
|
function set_property_dropdown_value(property_name) {
|
||||||
@@ -507,6 +516,15 @@ function discard_property_element_changes(elem, for_realm_default_settings) {
|
|||||||
realm_user_settings_defaults.email_notifications_batching_period_seconds,
|
realm_user_settings_defaults.email_notifications_batching_period_seconds,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case "realm_org_type":
|
||||||
|
set_input_element_value($elem, property_value);
|
||||||
|
// Remove 'unspecified' option (value=0) from realm_org_type
|
||||||
|
// dropdown menu options whenever page_params.realm_org_type
|
||||||
|
// returns another value.
|
||||||
|
if (property_value !== 0) {
|
||||||
|
$("#id_realm_org_type option[value=0]").remove();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (property_value !== undefined) {
|
if (property_value !== undefined) {
|
||||||
set_input_element_value($elem, property_value);
|
set_input_element_value($elem, property_value);
|
||||||
|
|||||||
@@ -17,6 +17,14 @@
|
|||||||
autocomplete="off" data-setting-widget-type="string"
|
autocomplete="off" data-setting-widget-type="string"
|
||||||
value="{{ realm_name }}" maxlength="40" />
|
value="{{ realm_name }}" maxlength="40" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-group admin-realm">
|
||||||
|
<label for="realm_org_type" class="dropdown-title">{{t "Organization type" }}
|
||||||
|
{{> ../help_link_widget link="/help/organization-type" }}
|
||||||
|
</label>
|
||||||
|
<select name="realm_org_type" class="setting-widget prop-element" id="id_realm_org_type" data-setting-widget-type="number">
|
||||||
|
{{> dropdown_options_widget option_values=realm_org_type_values}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="input-group admin-realm">
|
<div class="input-group admin-realm">
|
||||||
<label for="realm_description">{{t "Organization description" }}</label>
|
<label for="realm_description">{{t "Organization description" }}</label>
|
||||||
<textarea id="id_realm_description" name="realm_description" class="admin-realm-description setting-widget prop-element"
|
<textarea id="id_realm_description" name="realm_description" class="admin-realm-description setting-widget prop-element"
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
{settings_tab|organization-profile}
|
{settings_tab|organization-profile}
|
||||||
|
|
||||||
1. Edit your organization **name**, **description**, and **profile picture**.
|
1. Edit your organization **name**, **type**, **description**, and
|
||||||
1. Click **Save changes**.
|
**profile picture**.
|
||||||
|
|
||||||
|
{!save-changes.md!}
|
||||||
|
|
||||||
{end_tabs}
|
{end_tabs}
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,7 @@
|
|||||||
|
|
||||||
## Organization basics
|
## Organization basics
|
||||||
* [Review your organization's settings](/help/review-your-organization-settings)
|
* [Review your organization's settings](/help/review-your-organization-settings)
|
||||||
|
* [Organization type](/help/organization-type)
|
||||||
* [Import from Mattermost](/help/import-from-mattermost)
|
* [Import from Mattermost](/help/import-from-mattermost)
|
||||||
* [Import from Slack](/help/import-from-slack)
|
* [Import from Slack](/help/import-from-slack)
|
||||||
* [Import from Gitter](/help/import-from-gitter)
|
* [Import from Gitter](/help/import-from-gitter)
|
||||||
|
|||||||
24
templates/zerver/help/organization-type.md
Normal file
24
templates/zerver/help/organization-type.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Organization type
|
||||||
|
|
||||||
|
An organization's type is used to customize the experience for users
|
||||||
|
in your organization, including initial organization settings and
|
||||||
|
Welcome Bot messages received by new users.
|
||||||
|
|
||||||
|
## Set organization type
|
||||||
|
|
||||||
|
{!admin-only.md!}
|
||||||
|
|
||||||
|
{start_tabs}
|
||||||
|
|
||||||
|
{settings_tab|organization-profile}
|
||||||
|
|
||||||
|
1. Under **Organization type**, select the option that best fits
|
||||||
|
your organization.
|
||||||
|
|
||||||
|
{!save-changes.md!}
|
||||||
|
|
||||||
|
{end_tabs}
|
||||||
|
|
||||||
|
## Related articles
|
||||||
|
|
||||||
|
* [Configure default new user settings](/help/configure-default-new-user-settings)
|
||||||
@@ -3932,7 +3932,8 @@ paths:
|
|||||||
org_type:
|
org_type:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
The type of the organization.
|
The [organization type](/help/organization-type)
|
||||||
|
for the realm.
|
||||||
|
|
||||||
- 0 = Unspecified
|
- 0 = Unspecified
|
||||||
- 10 = Business
|
- 10 = Business
|
||||||
@@ -11488,7 +11489,10 @@ paths:
|
|||||||
description: |
|
description: |
|
||||||
Present if `realm` is present in `fetch_event_types`.
|
Present if `realm` is present in `fetch_event_types`.
|
||||||
|
|
||||||
The type of the organization.
|
The [organization type](/help/organization-type) for the realm.
|
||||||
|
Useful only to clients supporting changing this setting for the
|
||||||
|
organization, or clients implementing onboarding content or
|
||||||
|
other features that varies with organization type.
|
||||||
|
|
||||||
- 0 = Unspecified
|
- 0 = Unspecified
|
||||||
- 10 = Business
|
- 10 = Business
|
||||||
|
|||||||
Reference in New Issue
Block a user