Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

organization_profile: Render realm description for non-admins.

PieterCKad45bcc8353c
diff --git a/web/src/admin.ts b/web/src/admin.ts
index 5731e088f36..926f8a71173 100644
--- a/web/src/admin.ts
+++ b/web/src/admin.ts
@@ -10,6 +10,7 @@ import {$t, language_list} from "./i18n.ts";
import * as information_density from "./information_density.ts";
import {page_params} from "./page_params.ts";
import * as people from "./people.ts";
+import {postprocess_content} from "./postprocess_content.ts";
import {realm_user_settings_defaults} from "./realm_user_settings_defaults.ts";
import * as settings from "./settings.ts";
import * as settings_bots from "./settings_bots.ts";
@@ -153,6 +154,7 @@ export function build_page(): void {
gif_rating_options: realm.gif_rating_options,
gif_api_key_empty: realm.giphy_api_key === "" && realm.tenor_api_key === "",
realm_description: realm.realm_description,
+ realm_description_html: postprocess_content(page_params.realm_rendered_description),
realm_inline_image_preview: realm.realm_inline_image_preview,
server_inline_image_preview: realm.server_inline_image_preview,
realm_inline_url_embed_preview: realm.realm_inline_url_embed_preview,
diff --git a/web/src/base_page_params.ts b/web/src/base_page_params.ts
index 892324b053a..74e77897f5b 100644
--- a/web/src/base_page_params.ts
+++ b/web/src/base_page_params.ts
@@ -44,10 +44,7 @@ const home_params_schema = z.looseObject({
narrow_topic: z.optional(z.string()),
presence_history_limit_days_for_web_app: z.number(),
promote_sponsoring_zulip: z.boolean(),
- // `realm_rendered_description` is only sent for spectators, because
- // it isn't displayed for logged-in users and requires markdown
- // processor time to compute.
- realm_rendered_description: z.optional(z.string()),
+ realm_rendered_description: z.string(),
show_try_zulip_modal: z.boolean(),
state_data: z.nullable(state_data_schema),
translation_data: z.record(z.string(), z.string()),
diff --git a/web/styles/settings.css b/web/styles/settings.css
index 8bfa7f39b2c..cd89b3e76ef 100644
--- a/web/styles/settings.css
+++ b/web/styles/settings.css
@@ -147,6 +147,23 @@ h3,
box-sizing: border-box;
}
+.admin-realm-description.rendered_markdown {
+ /* 5px at 16px and 10px at 16px */
+ padding: 0.3125em 0.625em;
+ width: fit-content;
+ /* 500px at 16px */
+ max-width: 31.25em;
+ min-width: 0;
+
+ & > p:first-child {
+ padding-top: 0;
+ }
+
+ & > p:last-child {
+ margin-bottom: 0;
+ }
+}
+
.admin-realm-welcome-message-custom-text {
margin-bottom: 10px;
}
diff --git a/web/templates/settings/organization_profile_admin.hbs b/web/templates/settings/organization_profile_admin.hbs
index 2a3799c453b..8cc03e98dda 100644
--- a/web/templates/settings/organization_profile_admin.hbs
+++ b/web/templates/settings/organization_profile_admin.hbs
@@ -32,11 +32,7 @@
is_disabled=disable_want_advertise_in_communities_directory
label=admin_settings_label.realm_want_advertise_in_communities_directory
help_link="/help/communities-directory"}}
- <div class="input-group admin-realm">
- <label for="id_realm_description" class="settings-field-label">{{t "Organization description" }}</label>
- <textarea id="id_realm_description" name="realm_description" class="admin-realm-description setting-widget prop-element settings-textarea"
- maxlength="1000" data-setting-widget-type="string">{{ realm_description }}</textarea>
- </div>
+ {{> realm_description . }}
</div>
</div>
diff --git a/web/templates/settings/realm_description.hbs b/web/templates/settings/realm_description.hbs
new file mode 100644
index 00000000000..dd074360673
--- /dev/null
+++ b/web/templates/settings/realm_description.hbs
@@ -0,0 +1,14 @@
+<div class="input-group admin-realm">
+ <label for="id_realm_description" class="settings-field-label">
+ {{t "Organization description" }}
+ </label>
+ {{#if is_admin}}
+ <textarea id="id_realm_description" name="realm_description"
+ class="admin-realm-description setting-widget prop-element settings-textarea"
+ maxlength="1000" data-setting-widget-type="string">{{ realm_description_text }}</textarea>
+ {{else}}
+ <div class="admin-realm-description settings-highlight-box rendered_markdown">
+ {{rendered_markdown realm_description_html}}
+ </div>
+ {{/if}}
+</div>
diff --git a/zerver/lib/home.py b/zerver/lib/home.py
index 82ef7311c3f..80f1df33b37 100644
--- a/zerver/lib/home.py
+++ b/zerver/lib/home.py
@@ -205,10 +205,11 @@ def build_page_params_for_home_page_load(
page_params["translation_data"] = get_language_translation_data(request_language)
+ # This is used by `admin.ts` to display realm description for non-administrator
+ # logged-in users.
+ page_params["realm_rendered_description"] = get_realm_rendered_description(realm)
+
if user_profile is None:
- # Get rendered version of realm description which is displayed in right
- # sidebar for spectator.
- page_params["realm_rendered_description"] = get_realm_rendered_description(realm)
page_params["language_cookie_name"] = settings.LANGUAGE_COOKIE_NAME
return queue_id, page_params
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index d4e04c4057d..c641ccfecfc 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -57,6 +57,7 @@ class HomeTest(ZulipTestCase):
"page_type",
"presence_history_limit_days_for_web_app",
"promote_sponsoring_zulip",
+ "realm_rendered_description",
"request_language",
"show_try_zulip_modal",
"state_data",
@@ -303,7 +304,7 @@ class HomeTest(ZulipTestCase):
set(result["Cache-Control"].split(", ")), {"must-revalidate", "no-store", "no-cache"}
)
- self.assert_length(cache_mock.call_args_list, 6)
+ self.assert_length(cache_mock.call_args_list, 7)
html = result.content.decode()
@@ -606,7 +607,7 @@ class HomeTest(ZulipTestCase):
):
result = self._get_home_page()
self.check_rendered_logged_in_app(result)
- self.assert_length(cache_mock.call_args_list, 7)
+ self.assert_length(cache_mock.call_args_list, 8)
def test_num_queries_with_streams(self) -> None:
main_user = self.example_user("hamlet")