Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/app/warnings.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { React, redux, TypedMap } from "@cocalc/frontend/app-framework";6import { Gap, Icon } from "@cocalc/frontend/components";7import { SiteName } from "@cocalc/frontend/customize";8import { get_browser } from "@cocalc/frontend/feature";9import { webapp_client } from "@cocalc/frontend/webapp-client";1011interface VersionWarningProps {12new_version: TypedMap<{ min_version: number; version: number }>;13}1415const VERSION_WARNING_STYLE: React.CSSProperties = {16fontSize: "12pt",17position: "fixed",18left: 12,19backgroundColor: "#fcf8e3",20color: "#8a6d3b",21top: 20,22borderRadius: 4,23padding: "15px",24zIndex: 900,25boxShadow: "8px 8px 4px #888",26width: "70%",27marginTop: "1em",28} as const;2930export const VersionWarning: React.FC<VersionWarningProps> = React.memo(31({ new_version }) => {32function render_critical() {33if (new_version.get("min_version") <= webapp_client.version()) {34return;35}36return (37<div>38<br />39THIS IS A CRITICAL UPDATE. YOU MUST <Gap />40<a41onClick={() => window.location.reload()}42style={{43cursor: "pointer",44color: "white",45fontWeight: "bold",46textDecoration: "underline",47}}48>49RELOAD THIS PAGE50</a>51<Gap /> IMMEDIATELY OR YOU WILL BE DISCONNECTED. Sorry for the52inconvenience.53</div>54);55}5657function render_close() {58if (new_version.get("min_version") <= webapp_client.version()) {59return (60<Icon61name="times"62className="pull-right"63style={{ cursor: "pointer" }}64onClick={() => redux.getActions("page").set_new_version(undefined)}65/>66);67}68}6970let style: React.CSSProperties = VERSION_WARNING_STYLE;71if (new_version.get("min_version") > webapp_client.version()) {72style = { ...style, ...{ backgroundColor: "red", color: "#fff" } };73}7475return (76<div style={style}>77<Icon name={"refresh"} /> New Version Available: upgrade by <Gap />78<a79onClick={() => window.location.reload()}80style={{81cursor: "pointer",82fontWeight: "bold",83color: style.color,84textDecoration: "underline",85}}86>87reloading this page88</a>89.{render_close()}90{render_critical()}91</div>92);93},94);9596const WARNING_STYLE: React.CSSProperties = {97position: "fixed",98left: 12,99backgroundColor: "red",100color: "#fff",101top: 20,102opacity: 0.9,103borderRadius: 4,104padding: 5,105marginTop: "1em",106zIndex: 100000,107boxShadow: "8px 8px 4px #888",108width: "70%",109} as const;110111export const CookieWarning: React.FC = React.memo(() => {112return (113<div style={WARNING_STYLE}>114<Icon name="warning" /> You <em>must</em> enable cookies to use{" "}115<SiteName />.116</div>117);118});119120const STORAGE_WARNING_STYLE: React.CSSProperties = {121...WARNING_STYLE,122top: 55,123};124125export const LocalStorageWarning: React.FC = React.memo(() => {126return (127<div style={STORAGE_WARNING_STYLE}>128<Icon name="warning" /> You <em>must</em> enable local storage to use{" "}129<SiteName />130{get_browser() === "safari"131? " (on Safari you must disable private browsing mode)"132: undefined}133.134</div>135);136});137138139