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/lib/customize.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { createContext, useContext } from "react";
7
8
import type { Customize as ServerCustomize } from "@cocalc/database/settings/customize";
9
10
interface EnabledPageBranch {
11
[key: string]: boolean | undefined | EnabledPageBranch;
12
}
13
14
interface EnabledPageTree extends EnabledPageBranch {
15
auth: {
16
try: boolean | undefined;
17
};
18
about: {
19
index: boolean | undefined;
20
events: boolean | undefined;
21
team: boolean | undefined;
22
};
23
compute: boolean | undefined;
24
contact: boolean | undefined;
25
features: boolean | undefined;
26
info: boolean | undefined;
27
legal: boolean | undefined;
28
licenses: boolean | undefined;
29
news: boolean | undefined;
30
onPrem: boolean | undefined;
31
organization: boolean | undefined;
32
policies: {
33
index: boolean | undefined;
34
imprint: boolean | undefined;
35
};
36
pricing: boolean | undefined;
37
share: boolean | undefined;
38
software: boolean | undefined;
39
store: boolean | undefined;
40
support: boolean | undefined;
41
systemActivity: boolean | undefined;
42
status: boolean | undefined;
43
termsOfService: boolean | undefined;
44
}
45
46
interface Customize extends ServerCustomize {
47
account?: {
48
account_id: string;
49
email_address?: string;
50
first_name?: string;
51
is_anonymous?: boolean;
52
last_name?: string;
53
name?: string;
54
};
55
defaultComputeImage?: string; // default compute image, e.g. used when creating new projects from a share
56
githubProjectId?: string; // proxy github urls
57
imprint?: string; // HTML/MD for an imprint page
58
imprintOrPolicies?: boolean; // is true if either of the above is more than an empty string
59
isAuthenticated?: boolean; // if true, the user has a valid authentication cookie
60
isCollaborator?: boolean; // if account_id and project_id are in the props then this gets filled in
61
noindex?: boolean; // tell search engines to not index that page
62
onCoCalcCom?: boolean; // true, if kucalc server settings flag is set to yes (i.e. for cocalc.com only!)
63
policies?: string; // HTML/MD for a policy page
64
sandboxProjectId?: string; // a sandbox project to put on landing pages...
65
serverTime?: number; // the time on the server, in milliseconds since the epoch
66
openaiEnabled?: boolean; // backend is configured to provide openai integration.
67
googleVertexaiEnabled?: boolean; // if enabled, e.g. Google Gemini is available
68
jupyterApiEnabled?: boolean; // backend configured to use a pool of projects for sandboxed ephemeral jupyter code execution
69
computeServersEnabled?: boolean; // backend configured to run on external compute servers
70
enabledPages?: EnabledPageTree; // tree structure which specifies supported routes for this install
71
support?: string; // HTML/MD to replace the generic support pages
72
}
73
74
const CustomizeContext = createContext<Partial<Customize>>({});
75
const { Provider } = CustomizeContext;
76
export const useCustomize = () => useContext(CustomizeContext) ?? {};
77
export { Provider as Customize };
78
export type { Customize as CustomizeType };
79
80