Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
right_sidebar: Migrate to handlebars.
aryanshridhar13399833b02a
diff --git a/static/js/ui_init.js b/static/js/ui_init.jsindex 9c4e41d12b8..508d6daf5bd 100644--- a/static/js/ui_init.js+++ b/static/js/ui_init.js@@ -7,6 +7,7 @@ import * as emoji from "../shared/js/emoji";import * as fenced_code from "../shared/js/fenced_code";import render_edit_content_button from "../templates/edit_content_button.hbs";import render_left_sidebar from "../templates/left_sidebar.hbs";+import render_right_sidebar from "../templates/right_sidebar.hbs";import * as about_zulip from "./about_zulip";import * as activity from "./activity";@@ -63,6 +64,7 @@ import * as search from "./search";import * as search_pill_widget from "./search_pill_widget";import * as sent_messages from "./sent_messages";import * as server_events from "./server_events";+import * as settings_data from "./settings_data";import * as settings_display from "./settings_display";import * as settings_panel_menu from "./settings_panel_menu";import * as settings_sections from "./settings_sections";@@ -139,6 +141,14 @@ function initialize_left_sidebar() {$("#left-sidebar-container").html(rendered_sidebar);}+function initialize_right_sidebar() {+ const rendered_sidebar = render_right_sidebar({+ can_invite_others_to_realm: settings_data.user_can_invite_others_to_realm(),+ });++ $("#right-sidebar-container").html(rendered_sidebar);+}+export function initialize_kitchen_sink_stuff() {// TODO:// This function is a historical dumping ground@@ -483,6 +493,7 @@ export function initialize_everything() {// expect DOM elements to always exist (As that did before these// modules were migrated from Django templates to handlebars).initialize_left_sidebar();+ initialize_right_sidebar();compose.initialize();message_lists.initialize();diff --git a/templates/zerver/app/right_sidebar.html b/static/templates/right_sidebar.hbssimilarity index 71%rename from templates/zerver/app/right_sidebar.htmlrename to static/templates/right_sidebar.hbsindex 268b9aec58b..6dc6ad071f2 100644--- a/templates/zerver/app/right_sidebar.html+++ b/static/templates/right_sidebar.hbs@@ -3,14 +3,14 @@<div id="user-list"><div id="userlist-header"><h4 class='sidebar-title tippy-zulip-tooltip'- id='userlist-title' data-tippy-content="{{ _('Search people') }} (w)">{{ _('USERS') }}</h4>+ id='userlist-title' data-tippy-content="{{t 'Search people' }} (w)">{{t 'USERS' }}</h4><i id="user_filter_icon" class="fa fa-search tippy-zulip-tooltip"- aria-hidden="true" aria-label="{{ _('Search people') }}"- data-tippy-content="{{ _('Search people') }} (w)">+ aria-hidden="true" aria-label="{{t 'Search people' }}"+ data-tippy-content="{{t 'Search people' }} (w)"></i></div><div class="input-append notdisplayed" id="user_search_section">- <input class="user-list-filter home-page-input" type="text" autocomplete="off" placeholder="{{ _('Search people') }}" />+ <input class="user-list-filter home-page-input" type="text" autocomplete="off" placeholder="{{t 'Search people' }}" /><button type="button" class="btn clear_search_button" id="clear_search_people_button"><i class="fa fa-remove" aria-hidden="true"></i></button>@@ -21,11 +21,11 @@</div></div><div class="right-sidebar-shortcuts">- {% if show_invites %}- <a id="invite-user-link" href="#invite"><i class="fa fa-user-plus" aria-hidden="true"></i>{{ _('Invite more users') }}</a>- {% endif %}+ {{#if can_invite_others_to_realm}}+ <a id="invite-user-link" href="#invite"><i class="fa fa-user-plus" aria-hidden="true"></i>{{t 'Invite more users' }}</a>+ {{/if}}<a id="sidebar-keyboard-shortcuts" data-overlay-trigger="keyboard-shortcuts">- <i class="fa fa-keyboard-o fa-2x tippy-zulip-tooltip" id="keyboard-icon" data-tippy-allowHtml="true" data-tippy-content="{{ _('Keyboard shortcuts') }} <span class='hotkey-hint'>(?)</span>"></i>+ <i class="fa fa-keyboard-o fa-2x tippy-zulip-tooltip" id="keyboard-icon" data-tippy-allowHtml="true" data-tippy-content="{{t 'Keyboard shortcuts' }} <span class='hotkey-hint'>(?)</span>"></i></a></div></div>diff --git a/templates/zerver/app/index.html b/templates/zerver/app/index.htmlindex 51450832533..b41707d7ded 100644--- a/templates/zerver/app/index.html+++ b/templates/zerver/app/index.html@@ -129,8 +129,7 @@</div></div><!--/tab-content--></div>- <div class="column-right">- {% include "zerver/app/right_sidebar.html" %}+ <div class="column-right" id="right-sidebar-container"></div><!--/right sidebar--></div><!--/row--><div class="informational-overlays overlay new-style" data-overlay="informationalOverlays" aria-hidden="true">diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.pyindex 4d1f73c6536..fd4fcd34ae8 100644--- a/zerver/tests/test_home.py+++ b/zerver/tests/test_home.py@@ -246,7 +246,6 @@ class HomeTest(ZulipTestCase):# Keep this list sorted!!!html_bits = ["start the conversation",- "Keyboard shortcuts","Loading...",# Verify that the app styles get included"app-stubentry.js",@@ -396,12 +395,6 @@ class HomeTest(ZulipTestCase):result = self.client_get("/", dict(**kwargs))return result- def assertInHomePage(self, string: str) -> bool:- return self.assertIn(string, self._get_home_page().content.decode("utf-8"))-- def assertNotInHomePage(self, string: str) -> bool:- return self.assertNotIn(string, self._get_home_page().content.decode("utf-8"))-def _sanity_check(self, result: HttpResponse) -> None:"""Use this for tests that are geared toward specific edge cases, but@@ -687,33 +680,6 @@ class HomeTest(ZulipTestCase):self.assertEqual(page_params["narrow"], [dict(operator="stream", operand=stream_name)])self.assertEqual(page_params["max_message_id"], -1)- def test_invites_by_admins_only(self) -> None:- user_profile = self.example_user("hamlet")-- realm = user_profile.realm- realm.invite_to_realm_policy = Realm.POLICY_ADMINS_ONLY- realm.save()-- self.login_user(user_profile)- self.assertFalse(user_profile.is_realm_admin)- self.assertNotInHomePage("Invite more users")-- user_profile.role = UserProfile.ROLE_REALM_ADMINISTRATOR- user_profile.save()- self.assertInHomePage("Invite more users")-- def test_show_invites_for_guest_users(self) -> None:- user_profile = self.example_user("polonius")-- realm = user_profile.realm- realm.invite_to_realm_policy = Realm.POLICY_MEMBERS_ONLY- realm.save()-- self.login_user(user_profile)- self.assertFalse(user_profile.is_realm_admin)- self.assertEqual(get_realm("zulip").invite_to_realm_policy, Realm.POLICY_MEMBERS_ONLY)- self.assertNotInHomePage("Invite more users")-def test_get_billing_info(self) -> None:user = self.example_user("desdemona")user.role = UserProfile.ROLE_REALM_OWNERdiff --git a/zerver/views/home.py b/zerver/views/home.pyindex 6b1dab4981e..087775bc409 100644--- a/zerver/views/home.py+++ b/zerver/views/home.py@@ -16,7 +16,6 @@ from zerver.lib.compatibility import is_outdated_desktop_app, is_unsupported_brofrom zerver.lib.home import build_page_params_for_home_page_load, get_user_permission_infofrom zerver.lib.streams import access_stream_by_namefrom zerver.lib.subdomains import get_subdomain-from zerver.lib.users import compute_show_invitesfrom zerver.lib.utils import statsdfrom zerver.models import PreregistrationUser, Realm, Stream, UserProfilefrom zerver.views.portico import hello_view@@ -190,8 +189,6 @@ def home_real(request: HttpRequest) -> HttpResponse:needs_tutorial=needs_tutorial,)- show_invites = compute_show_invites(user_profile)-request._log_data["extra"] = "[{}]".format(queue_id)csp_nonce = secrets.token_hex(24)@@ -206,7 +203,6 @@ def home_real(request: HttpRequest) -> HttpResponse:"page_params": page_params,"csp_nonce": csp_nonce,"search_pills_enabled": settings.SEARCH_PILLS_ENABLED,- "show_invites": show_invites,"is_owner": user_permission_info.is_realm_owner,"is_admin": user_permission_info.is_realm_admin,"is_guest": user_permission_info.is_guest,