login_to_access: Modal which blocks access for spectator.

We will use this modal for any narrow / hash or other UI element that
requires an actual account to use, to provide something reasonable to
occur when a user clicks on those things.
This commit is contained in:
Aman Agrawal
2020-10-05 19:39:25 +05:30
committed by Tim Abbott
parent 9399b95fec
commit 045cdb4ed0
7 changed files with 130 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
// Module for displaying the modal asking spectators to login when
// attempting to do things that are not possible as a specatator (like
// add an emoji reaction, star a message, etc.). While in many cases,
// we will prefer to hide menu options that don't make sense for
// spectators, this modal is useful for everything that doesn't make
// sense to remove from a design perspective.
import $ from "jquery";
import render_login_to_access_modal from "../templates/login_to_access.hbs";
import {page_params} from "./page_params";
export function show() {
// Hide all overlays, popover and go back to the previous hash if the
// hash has changed.
let login_link;
if (page_params.development_environment) {
login_link = "/devlogin";
} else {
login_link = "/login";
}
$("#login-to-access-modal-holder").html(
render_login_to_access_modal({
signup_link: "/register",
login_link,
}),
);
$("#login_to_access_modal").modal("show");
}