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/index.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6When you want to edit an existing public share, here's the flow of what happens.78- If you are a collaborator on the project with the shared document it shows a button to "Open the file in my project" (or something).9- If you are NOT a collaborator on the project there are various states:10- If you are NOT signed in it gives you the option to:11- Sign in, then start this flowchart over12- Sign up, then start this over13- Create a new anonymous project and anonymously edit this content.14- If you are signed in, it gives you these options:15- Create a new project and copy this content to that project (and it opens the project in a new tab).16- Copy this content to one of your existing projects.17- If you select this, then a select an existing projects, and maybe a directory in that project.18- Project starts and content gets copied19- Maybe when done get a link and can open that.20- In all cases above, if share comes with a license (i.e., the CUP situation), then that license gets applied to the relevant project... temporarily (?).2122*/2324import { Icon } from "@cocalc/frontend/components/icon";25import { Button } from "antd";26import { useRouter } from "next/router";27import { useEffect, useState } from "react";28import EditOptions from "./edit-options";2930export interface Props {31id: string;32path: string;33url?: string;34relativePath: string;35project_id: string;36image?: string;37description?: string;38has_site_license?: boolean;39}4041export default function Edit({42id,43path,44url,45relativePath,46project_id,47image,48description,49has_site_license,50}: Props) {51const router = useRouter();52const [expanded, setExpanded] = useState<boolean>(!!router.query.edit);53useEffect(() => {54setExpanded(!!router.query.edit);55}, [id, path, url, relativePath]);5657return (58<span>59<Button60type="primary"61disabled={expanded}62onClick={(e) => {63e.preventDefault();64setExpanded(true);65}}66key="edit"67>68<Icon name="pencil" /> Edit your own copy...69</Button>70{expanded && (71<EditOptions72id={id}73path={path}74url={url}75relativePath={relativePath}76project_id={project_id}77image={image}78description={description}79has_site_license={has_site_license}80onClose={() => {81setExpanded(false);82}}83/>84)}85</span>86);87}888990