CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/share/path-contents.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { FileInfo } from "lib/share/get-contents";
7
import DirectoryListing from "./directory-listing";
8
import FileContents from "./file-contents";
9
import Loading from "./loading";
10
11
interface Props {
12
id: string;
13
isdir?: boolean;
14
listing?: FileInfo[];
15
content?: string;
16
relativePath: string;
17
path: string;
18
truncated?: string;
19
jupyter_api?: boolean;
20
}
21
22
export default function PathContents({
23
id,
24
isdir,
25
listing,
26
content,
27
relativePath,
28
path,
29
truncated,
30
jupyter_api,
31
}: Props) {
32
if (isdir) {
33
if (listing == null) return <Loading style={{ fontSize: "30px" }} />;
34
return (
35
<>
36
<Truncated truncated={truncated} />
37
<DirectoryListing
38
id={id}
39
listing={listing}
40
relativePath={relativePath}
41
/>
42
</>
43
);
44
} else {
45
return (
46
<div
47
style={{
48
padding: "20px 0",
49
}}
50
>
51
<Truncated truncated={truncated} />
52
<FileContents
53
id={id}
54
content={content}
55
path={path}
56
relativePath={relativePath}
57
jupyter_api={jupyter_api}
58
/>
59
</div>
60
);
61
}
62
}
63
64
const Truncated = ({ truncated }) =>
65
truncated == null ? null : <h3>{truncated}</h3>;
66
67