Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/lib/customize.ts
1447 views
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
liveDemo: boolean | undefined;
45
}
46
47
interface Customize extends ServerCustomize {
48
account?: {
49
account_id: string;
50
email_address?: string;
51
first_name?: string;
52
is_anonymous?: boolean;
53
last_name?: string;
54
name?: string;
55
};
56
defaultComputeImage?: string; // default compute image, e.g. used when creating new projects from a share
57
githubProjectId?: string; // proxy github urls
58
imprint?: string; // HTML/MD for an imprint page
59
imprintOrPolicies?: boolean; // is true if either of the above is more than an empty string
60
isAuthenticated?: boolean; // if true, the user has a valid authentication cookie
61
isCollaborator?: boolean; // if account_id and project_id are in the props then this gets filled in
62
noindex?: boolean; // tell search engines to not index that page
63
onCoCalcCom?: boolean; // true, if kucalc server settings flag is set to yes (i.e. for cocalc.com only!)
64
policies?: string; // HTML/MD for a policy page
65
sandboxProjectId?: string; // a sandbox project to put on landing pages...
66
serverTime?: number; // the time on the server, in milliseconds since the epoch
67
openaiEnabled?: boolean; // backend is configured to provide openai integration.
68
googleVertexaiEnabled?: boolean; // if enabled, e.g. Google Gemini is available
69
jupyterApiEnabled?: boolean; // backend configured to use a pool of projects for sandboxed ephemeral jupyter code execution
70
computeServersEnabled?: boolean; // backend configured to run on external compute servers
71
enabledPages?: EnabledPageTree; // tree structure which specifies supported routes for this install
72
support?: string; // HTML/MD to replace the generic support pages
73
supportVideoCall?: string;
74
}
75
76
const CustomizeContext = createContext<Partial<Customize>>({});
77
const { Provider } = CustomizeContext;
78
export const useCustomize = () => useContext(CustomizeContext) ?? {};
79
export { Provider as Customize };
80
export type { Customize as CustomizeType };
81
82