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/project/project.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6Page for a given project78Show all the public paths in a given project, and maybe other information about the project?9*/1011import { useEffect } from "react";12import { useRouter } from "next/router";13import PublicPaths from "components/share/public-paths";14import Collaborators from "components/share/collaborators";15import Loading from "components/share/loading";16import { Layout } from "components/share/layout";17import A from "components/misc/A";18import { Customize } from "lib/share/customize";19import { ProjectCollaborator } from "lib/api/schema/projects/collaborators/list";20import Edit from "./edit";21import editURL from "lib/share/edit-url";22import Markdown from "@cocalc/frontend/editors/slate/static-markdown";23import { Avatar } from "antd";2425export default function Project({26project_id,27publicPaths,28collaborators,29title,30description,31name,32customize,33avatar_image_full,34redirect,35}) {36const router = useRouter();37useEffect(() => {38if (redirect) {39router.push(redirect);40}41}, [redirect]);4243if (publicPaths == null || collaborators == null || title == null) {44return <Loading style={{ fontSize: "30px" }} />;45}4647const collab = isCollaborator(customize.account, collaborators);48return (49<Customize value={customize}>50<Layout title={title}>51<h1>52{avatar_image_full && (53<Avatar54icon={<img src={avatar_image_full} />}55size={160}56shape="square"57style={{ float: "right" }}58/>59)}60Project:{" "}61{collab ? (62<A href={editURL({ project_id, type: "collaborator" })} external>63{title}64</A>65) : (66title67)}68</h1>69<div style={{ color: "#666" }}>70<Markdown value={description} />71</div>72{collab && (73<Edit74project_id={project_id}75title={title}76description={description}77name={name}78/>79)}80{collaborators != null && collaborators.length > 0 && (81<>82<h2>Collaborators</h2>83<Collaborators collaborators={collaborators} />84<br /> <br />85</>86)}87<h2>Public Paths</h2>88{collab && (89<div style={{ marginBottom: "15px" }}>90You are a collaborator on this project, so unlisted and disabled91public paths are also listed here, so you can more easily edit them.92</div>93)}94{publicPaths != null && publicPaths.length == 0 ? (95<div>No public paths.</div>96) : (97<PublicPaths publicPaths={publicPaths} />98)}99</Layout>100</Customize>101);102}103104function isCollaborator(105account: undefined | { account_id: string },106collaborators: ProjectCollaborator[],107): boolean {108const account_id = account?.account_id;109if (account_id == null) return false;110for (const user of collaborators) {111if (user.account_id == account_id) return true;112}113return false;114}115116117