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/next/components/share/edit/edit-options.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { useState } from "react";6import { join } from "path";7import { Button, Card, Checkbox, Tooltip } from "antd";8import { Icon } from "@cocalc/frontend/components/icon";9import useCustomize from "lib/use-customize";10import OpenDirectly from "./open-directly";11import OpenAnonymously from "./open-anonymously";12import ChooseProject from "./choose-project";13import { Props } from "./index";14import InPlaceSignInOrUp from "components/auth/in-place-sign-in-or-up";15import { trunc_middle } from "@cocalc/util/misc";1617interface EditOptionsProps extends Props {18onClose: () => void;19}2021export default function EditOptions({22id,23path,24url,25relativePath,26project_id,27image,28onClose,29description,30has_site_license,31}: EditOptionsProps) {32const { isCollaborator } = useCustomize();33const [everything, setEverything] = useState<boolean>(true);34const [copied, setCopied] = useState<boolean>(false);35const { account } = useCustomize();36return (37<Card38style={{ margin: "30px 0" }}39title={40<>41<div style={{ float: "right", display: "flex" }}>42{!(!url && isCollaborator) && (43<div>44<Tooltip title="When checked, additional files may be copied to your project, which uses more spaces but ensures everything works.">45<Checkbox46disabled={copied}47checked={everything}48onChange={(e) => setEverything(e.target.checked)}49>50Copy Everything51</Checkbox>52</Tooltip>53</div>54)}55<Button56type="text"57onClick={onClose}58style={{ marginLeft: "30px" }}59>60<Icon name="times" />61</Button>62</div>63<Icon style={{ marginRight: "10px" }} name="pencil" /> Edit{" "}64<b>{trunc_middle(join(path, relativePath), 60)}</b>65</>66}67>68{account?.account_id != null && (69<SignedInOptions70id={id}71path={path}72url={url}73relativePath={relativePath}74everything={everything}75project_id={project_id}76image={image}77description={description}78isCollaborator={isCollaborator}79onCopied={() => setCopied(true)}80/>81)}82{account?.account_id == null && (83<NotSignedInOptions84path={path}85has_site_license={has_site_license}86id={id}87/>88)}89<br />90</Card>91);92}9394function SignedInOptions({95id,96path,97url,98relativePath,99project_id,100image,101description,102everything,103isCollaborator,104onCopied,105}) {106return !url && isCollaborator ? (107<OpenDirectly108id={id}109project_id={project_id}110path={path}111relativePath={relativePath}112/>113) : (114<ChooseProject115id={id}116src_project_id={project_id}117path={path}118url={url}119relativePath={relativePath}120everything={everything}121image={image}122description={description ? description : path ? path : relativePath}123onCopied={onCopied}124/>125);126}127128function NotSignedInOptions({ path, has_site_license, id }) {129const { anonymousSignup, anonymousSignupLicensedShares } = useCustomize();130return (131<div>132<InPlaceSignInOrUp133title="Choose Project"134why={`to edit in one of your own ${135has_site_license ? "licensed" : ""136} projects using a full collaborative ${137path?.endsWith("ipynb") ? "Jupyter notebook" : "editor"138}`}139publicPathId={has_site_license ? id : undefined}140/>141{anonymousSignup && <OpenAnonymously />}142{!anonymousSignup &&143anonymousSignupLicensedShares &&144has_site_license && <OpenAnonymously publicPathId={id} />}145</div>146);147}148149150