Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
frontend: Add `org_type` to realm settings updates and events.
Lauryn Menard129233853706
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.jsindex 7cc834aa1ad..792759a79ba 100644--- a/frontend_tests/node_tests/dispatch.js+++ b/frontend_tests/node_tests/dispatch.js@@ -392,6 +392,10 @@ run_test("realm settings", ({override}) => {});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;test_realm_boolean(event, "realm_emails_restricted_to_domains");diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.jsindex a5d412033d1..4168509c8a3 100644--- a/frontend_tests/node_tests/lib/events.js+++ b/frontend_tests/node_tests/lib/events.js@@ -342,6 +342,13 @@ exports.fixtures = {value: 42,},+ realm__update__org_type: {+ type: "realm",+ op: "update",+ property: "org_type",+ value: 50,+ },+realm__update__signup_notifications_stream_id: {type: "realm",op: "update",diff --git a/static/js/admin.js b/static/js/admin.jsindex d3774bee497..5e1dd389d6d 100644--- a/static/js/admin.js+++ b/static/js/admin.js@@ -80,6 +80,7 @@ export function build_page() {const options = {custom_profile_field_types: page_params.custom_profile_field_types,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,giphy_rating_options: page_params.giphy_rating_options,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,can_sort_by_email: settings_data.show_email(),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") {diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.jsindex bbb316fca4c..5ff2601852b 100644--- a/static/js/server_events_dispatch.js+++ b/static/js/server_events_dispatch.js@@ -214,6 +214,7 @@ export function dispatch_normal_event(event) {name: notifications.redraw_title,name_changes_disabled: settings_account.update_name_change_display,notifications_stream_id: noop,+ org_type: noop,private_message_policy: noop,send_welcome_emails: noop,message_content_allowed_in_email_notifications: noop,diff --git a/static/js/settings_config.ts b/static/js/settings_config.tsindex cd0d69f4b2d..37438c8e258 100644--- a/static/js/settings_config.ts+++ b/static/js/settings_config.ts@@ -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 = {// Backend support for this configuration is not available yet.// hour: {diff --git a/static/js/settings_org.js b/static/js/settings_org.jsindex 592db4e12bc..19b7ad8b9f1 100644--- a/static/js/settings_org.js+++ b/static/js/settings_org.js@@ -116,6 +116,14 @@ export function get_organization_settings_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) {let val = (page_params[property] / 60).toFixed(1);if (Number.parseFloat(val, 10) === Number.parseInt(val, 10)) {@@ -238,6 +246,7 @@ const simple_dropdown_properties = ["realm_wildcard_mention_policy","realm_move_messages_between_streams_policy","realm_edit_topic_policy",+ "realm_org_type",];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,);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:if (property_value !== undefined) {set_input_element_value($elem, property_value);diff --git a/static/templates/settings/organization_profile_admin.hbs b/static/templates/settings/organization_profile_admin.hbsindex 1f38de4977d..66c141925bb 100644--- a/static/templates/settings/organization_profile_admin.hbs+++ b/static/templates/settings/organization_profile_admin.hbs@@ -17,6 +17,14 @@autocomplete="off" data-setting-widget-type="string"value="{{ realm_name }}" maxlength="40" /></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"><label for="realm_description">{{t "Organization description" }}</label><textarea id="id_realm_description" name="realm_description" class="admin-realm-description setting-widget prop-element"diff --git a/templates/zerver/help/include/edit-organization-profile.md b/templates/zerver/help/include/edit-organization-profile.mdindex efa4fc25fbd..690b77e9480 100644--- a/templates/zerver/help/include/edit-organization-profile.md+++ b/templates/zerver/help/include/edit-organization-profile.md@@ -7,8 +7,10 @@{settings_tab|organization-profile}-1. Edit your organization **name**, **description**, and **profile picture**.-1. Click **Save changes**.+1. Edit your organization **name**, **type**, **description**, and+**profile picture**.++{!save-changes.md!}{end_tabs}diff --git a/templates/zerver/help/include/sidebar_index.md b/templates/zerver/help/include/sidebar_index.mdindex aa775fcfadb..7640e43a43e 100755--- a/templates/zerver/help/include/sidebar_index.md+++ b/templates/zerver/help/include/sidebar_index.md@@ -128,6 +128,7 @@## Organization basics* [Review your organization's settings](/help/review-your-organization-settings)+* [Organization type](/help/organization-type)* [Import from Mattermost](/help/import-from-mattermost)* [Import from Slack](/help/import-from-slack)* [Import from Gitter](/help/import-from-gitter)diff --git a/templates/zerver/help/organization-type.md b/templates/zerver/help/organization-type.mdnew file mode 100644index 00000000000..4f8c6ddf521--- /dev/null+++ b/templates/zerver/help/organization-type.md@@ -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)diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex b7ec0ca814d..9a6d1fdadb8 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -3932,7 +3932,8 @@ paths:org_type:type: integerdescription: |- The type of the organization.+ The [organization type](/help/organization-type)+ for the realm.- 0 = Unspecified- 10 = Business@@ -11488,7 +11489,10 @@ paths:description: |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- 10 = Business