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/custom-software/reset-bar.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Button as AntdButton, Card } from "antd";6import React from "react";7import { FormattedMessage, useIntl } from "react-intl";89import { A, Icon } from "@cocalc/frontend/components";10import { labels } from "@cocalc/frontend/i18n";11import { ProjectMap } from "@cocalc/frontend/todo-types";12import { COLORS, SITE_NAME } from "@cocalc/util/theme";1314import { Available as AvailableFeatures } from "../project_configuration";15import { ComputeImages } from "./init";16import { props2img, RESET_ICON } from "./util";1718const doc_snap = "https://doc.cocalc.com/project-files.html#snapshots";19const doc_tt = "https://doc.cocalc.com/time-travel.html";2021const title_style: React.CSSProperties = {22fontWeight: "bold" as "bold",23fontSize: "15pt",24} as const;2526const button_bar_style: React.CSSProperties = {27whiteSpace: "nowrap" as "nowrap",28} as const;2930const info_style: React.CSSProperties = {31paddingBottom: "20px",32} as const;3334interface Props {35project_id: string;36images: ComputeImages;37project_map?: ProjectMap;38actions: any;39available_features?: AvailableFeatures;40site_name?: string;41}4243export const CustomSoftwareReset: React.FC<Props> = (props: Props) => {44const { actions, site_name } = props;4546const intl = useIntl();4748function reset() {49actions.custom_software_reset();50}5152function cancel() {53actions.toggle_custom_software_reset(false);54}5556function title() {57return (58<div style={title_style}>59<Icon name={RESET_ICON} /> Reset {img.get("display", "")}60</div>61);62}6364const img = props2img(props);65if (img == null) return null;66const NAME = site_name || SITE_NAME;6768return (69<Card style={{ background: COLORS.GRAY_LLL }} title={title()}>70<div style={info_style}>71<FormattedMessage72id="custom-software.reset-bar.info"73defaultMessage={`74<p>75Clicking on "Reset" copies all accompanying files of this custom76software environment into your home directory. This was done once when77this project was created and you can repeat this action right now. If78these accompanying files hosted on {NAME} did update in the meantime,79you'll recieve the newer versions.80</p>81<p>82Note, that this will overwrite any changes you did to these83accompanying files, but does not modify or delete any other files.84However, nothing is lost: you can still access the previous version85via <A1>Snapshot Backups</A1> or <A2>TimeTravel</A2>.86</p>87<p>This action will also restart your project!</p>`}88values={{89NAME,90A1: (c) => <A href={doc_snap}>{c}</A>,91A2: (c) => <A href={doc_tt}>{c}</A>,92}}93/>94</div>95<div style={button_bar_style}>96<AntdButton onClick={reset} danger type="primary">97<Icon name={RESET_ICON} />{" "}98{intl.formatMessage({99id: "custom-software.reset-bar.reset-and-restart",100defaultMessage: "Reset and Restart",101})}102</AntdButton>{" "}103<AntdButton onClick={cancel}>104<Icon name={"times-circle"} /> {intl.formatMessage(labels.cancel)}105</AntdButton>106</div>107</Card>108);109};110111112