Path: blob/master/src/packages/next/lib/customize.ts
1447 views
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { createContext, useContext } from "react";67import type { Customize as ServerCustomize } from "@cocalc/database/settings/customize";89interface EnabledPageBranch {10[key: string]: boolean | undefined | EnabledPageBranch;11}1213interface EnabledPageTree extends EnabledPageBranch {14auth: {15try: boolean | undefined;16};17about: {18index: boolean | undefined;19events: boolean | undefined;20team: boolean | undefined;21};22compute: boolean | undefined;23contact: boolean | undefined;24features: boolean | undefined;25info: boolean | undefined;26legal: boolean | undefined;27licenses: boolean | undefined;28news: boolean | undefined;29onPrem: boolean | undefined;30organization: boolean | undefined;31policies: {32index: boolean | undefined;33imprint: boolean | undefined;34};35pricing: boolean | undefined;36share: boolean | undefined;37software: boolean | undefined;38store: boolean | undefined;39support: boolean | undefined;40systemActivity: boolean | undefined;41status: boolean | undefined;42termsOfService: boolean | undefined;43liveDemo: boolean | undefined;44}4546interface Customize extends ServerCustomize {47account?: {48account_id: string;49email_address?: string;50first_name?: string;51is_anonymous?: boolean;52last_name?: string;53name?: string;54};55defaultComputeImage?: string; // default compute image, e.g. used when creating new projects from a share56githubProjectId?: string; // proxy github urls57imprint?: string; // HTML/MD for an imprint page58imprintOrPolicies?: boolean; // is true if either of the above is more than an empty string59isAuthenticated?: boolean; // if true, the user has a valid authentication cookie60isCollaborator?: boolean; // if account_id and project_id are in the props then this gets filled in61noindex?: boolean; // tell search engines to not index that page62onCoCalcCom?: boolean; // true, if kucalc server settings flag is set to yes (i.e. for cocalc.com only!)63policies?: string; // HTML/MD for a policy page64sandboxProjectId?: string; // a sandbox project to put on landing pages...65serverTime?: number; // the time on the server, in milliseconds since the epoch66openaiEnabled?: boolean; // backend is configured to provide openai integration.67googleVertexaiEnabled?: boolean; // if enabled, e.g. Google Gemini is available68jupyterApiEnabled?: boolean; // backend configured to use a pool of projects for sandboxed ephemeral jupyter code execution69computeServersEnabled?: boolean; // backend configured to run on external compute servers70enabledPages?: EnabledPageTree; // tree structure which specifies supported routes for this install71support?: string; // HTML/MD to replace the generic support pages72supportVideoCall?: string;73}7475const CustomizeContext = createContext<Partial<Customize>>({});76const { Provider } = CustomizeContext;77export const useCustomize = () => useContext(CustomizeContext) ?? {};78export { Provider as Customize };79export type { Customize as CustomizeType };808182