Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
spectators: Move build_login_link out of hash_util.ts.
Tim Abbott1aea88fac1d4
diff --git a/web/src/hash_util.ts b/web/src/hash_util.tsindex 822f1039d30..1188393a090 100644--- a/web/src/hash_util.ts+++ b/web/src/hash_util.ts@@ -1,6 +1,5 @@import * as internal_url from "../shared/src/internal_url";-import {page_params} from "./page_params";import * as people from "./people";import * as stream_data from "./stream_data";import * as sub_store from "./sub_store";@@ -299,15 +298,3 @@ export function is_spectator_compatible(hash: string): boolean {return web_public_allowed_hashes.includes(main_hash);}--export function current_hash_as_next(): string {- return `next=/${encodeURIComponent(window.location.hash)}`;-}--export function build_login_link(): string {- let login_link = "/login/?" + current_hash_as_next();- if (page_params.development_environment) {- login_link = "/devlogin/?" + current_hash_as_next();- }- return login_link;-}diff --git a/web/src/sidebar_ui.js b/web/src/sidebar_ui.jsindex f31c5517c01..2ed9e882797 100644--- a/web/src/sidebar_ui.js+++ b/web/src/sidebar_ui.js@@ -1,9 +1,9 @@import $ from "jquery";import {media_breakpoints_num} from "./css_variables";-import * as hash_util from "./hash_util";import * as popovers from "./popovers";import * as resize from "./resize";+import * as spectators from "./spectators";export function hide_userlist_sidebar() {$(".app-main .column-right").removeClass("expanded");@@ -35,7 +35,7 @@ export function initialize() {$("body").on("click", ".login_button", (e) => {e.preventDefault();e.stopPropagation();- window.location.href = hash_util.build_login_link();+ window.location.href = spectators.build_login_link();});$("#userlist-toggle-button").on("click", (e) => {diff --git a/web/src/spectators.ts b/web/src/spectators.tsindex 40b6079ce34..75a1e0178ac 100644--- a/web/src/spectators.ts+++ b/web/src/spectators.ts@@ -10,14 +10,25 @@ import $ from "jquery";import render_login_to_access_modal from "../templates/login_to_access.hbs";import * as browser_history from "./browser_history";-import * as hash_util from "./hash_util";import * as overlays from "./overlays";import {page_params} from "./page_params";+export function current_hash_as_next(): string {+ return `next=/${encodeURIComponent(window.location.hash)}`;+}++export function build_login_link(): string {+ let login_link = "/login/?" + current_hash_as_next();+ if (page_params.development_environment) {+ login_link = "/devlogin/?" + current_hash_as_next();+ }+ return login_link;+}+export function login_to_access(empty_narrow?: boolean): void {// Hide all overlays, popover and go back to the previous hash if the// hash has changed.- const login_link = hash_util.build_login_link();+ const login_link = build_login_link();const realm_name = page_params.realm_name;$("body").append(diff --git a/web/tests/hash_util.test.js b/web/tests/hash_util.test.jsindex 103f109a17a..6e7a04cdb50 100644--- a/web/tests/hash_util.test.js+++ b/web/tests/hash_util.test.js@@ -8,6 +8,7 @@ const {run_test} = require("./lib/test");const hash_util = zrequire("hash_util");const stream_data = zrequire("stream_data");const people = zrequire("people");+const spectators = zrequire("spectators");const hamlet = {user_id: 15,@@ -191,5 +192,5 @@ run_test("test_search_public_streams_notice_url", () => {run_test("test_current_hash_as_next", () => {window.location.hash = "#foo";- assert.equal(hash_util.current_hash_as_next(), "next=/%23foo");+ assert.equal(spectators.current_hash_as_next(), "next=/%23foo");});