Path: blob/master/src/packages/next/components/share/path-actions.tsx
1449 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Icon } from "@cocalc/frontend/components/icon";6import Link from "next/link";7// import ExternalLink from "./external-link";8// import rawURL from "lib/share/raw-url";9import downloadURL from "lib/share/download-url";10import { r_join } from "@cocalc/frontend/components/r_join";11import SiteName from "./site-name";12import Edit from "./edit";1314import type { JSX } from "react";1516interface Props {17id: string;18path: string;19url?: string;20relativePath: string;21isDir?: boolean;22exclude?: Set<string>;23project_id: string;24image?: string;25description?: string;26has_site_license?: boolean;27}2829export default function PathActions({30id,31path,32url,33relativePath,34isDir,35exclude,36project_id,37image,38description,39has_site_license,40}: Props) {41const include = (action: string) => !exclude?.has(action);42const v: JSX.Element[] = [];43if (include("edit")) {44if (url && isDir) {45// TODO!46// have to implement git clone...47} else {48v.push(49<Edit50key="edit"51id={id}52path={path}53url={url}54relativePath={relativePath}55image={image}56project_id={project_id}57description={description}58has_site_license={has_site_license}59/>,60);61}62}63if (!url && include("hosted")) {64v.push(65<Link66key="hosted"67href={`/share/public_paths/${id}`}68style={{ marginTop: "5px" }}69>70Hosted by <SiteName />71</Link>,72);73}74if (!url && !isDir && include("download")) {75v.push(76<a77key="download"78href={downloadURL(id, path, relativePath)}79style={{ marginTop: "5px" }}80>81<Icon name="cloud-download" /> Download82</a>,83);84}85/*86if (!url && include("raw")) {87v.push(88<ExternalLink key="raw" href={rawURL({ id, path, relativePath })}>89Raw90</ExternalLink>,91);92}93if (!url && include("embed")) {94v.push(95<Link96key="embed"97href={`/share/public_paths/embed/${id}${98relativePath ? "/" + relativePath : ""99}`}100>101Embed102</Link>,103);104}105*/106107return (108<div style={{ display: "flex" }}>109{r_join(v, <div style={{ width: "10px" }} />)}110</div>111);112}113114115