Skip to content

Commit d70a3a9

Browse files
committed
Merge branch 'next-custom-support' into next-support-help_email
2 parents e43ce26 + 26d7651 commit d70a3a9

File tree

21 files changed

+225
-103
lines changed

21 files changed

+225
-103
lines changed

src/packages/database/settings/customize.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
44
*/
55

6+
import getStrategies from "@cocalc/database/settings/get-sso-strategies";
67
import {
7-
KucalcValues,
88
KUCALC_COCALC_COM,
9+
KucalcValues,
910
} from "@cocalc/util/db-schema/site-defaults";
1011
import { Strategy } from "@cocalc/util/types/sso";
11-
import getStrategies from "@cocalc/database/settings/get-sso-strategies";
12-
import { getServerSettings, ServerSettings } from "./server-settings";
12+
import { ServerSettings, getServerSettings } from "./server-settings";
1313
import siteURL from "./site-url";
1414

1515
export interface Customize {
@@ -29,6 +29,7 @@ export interface Customize {
2929
logoRectangularURL?: string;
3030
splashImage?: string;
3131
indexInfo?: string;
32+
indexTagline?: string;
3233
imprint?: string;
3334
policies?: string;
3435
shareServer?: boolean;
@@ -42,7 +43,6 @@ export interface Customize {
4243
accountCreationInstructions?: string;
4344
zendesk?: boolean; // true if zendesk support is configured.
4445
stripePublishableKey?: string;
45-
index_info_html?: string;
4646
imprint_html?: string;
4747
policies_html?: string;
4848
reCaptchaKey?: string;
@@ -59,6 +59,7 @@ export interface Customize {
5959
jupyterApiEnabled?: boolean;
6060
computeServersEnabled?: boolean;
6161
githubProjectId?: string;
62+
support?: string;
6263
}
6364

6465
const fallback = (a?: string, b?: string): string =>
@@ -122,8 +123,10 @@ export default async function getCustomize(): Promise<Customize> {
122123
googleAnalytics: settings.google_analytics,
123124

124125
indexInfo: settings.index_info_html,
126+
indexTagline: settings.index_tagline,
125127
imprint: settings.imprint,
126128
policies: settings.policies,
129+
support: settings.support,
127130

128131
// Is important for invite emails, password reset, etc. (e.g., so we can construct a url to our site).
129132
// This *can* start with http:// to explicitly use http instead of https, and can end

src/packages/frontend/editors/slate/elements/link/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
44
*/
55

6-
import { CSSProperties } from "react";
76
import { Text } from "slate";
8-
import { register, SlateElement } from "../register";
9-
import { dict } from "@cocalc/util/misc";
7+
8+
import { CSS } from "@cocalc/frontend/app-framework";
109
import { useFileContext } from "@cocalc/frontend/lib/file-context";
10+
import { dict } from "@cocalc/util/misc";
11+
import { register, SlateElement } from "../register";
1112

12-
export const LINK_STYLE = {
13+
export const LINK_STYLE: CSS = {
1314
backgroundColor: "white",
1415
padding: "1px",
1516
margin: "-1px", // so the position isn't changed; important when background is white so doesn't look weird.
1617
borderRadius: "2px",
17-
} as CSSProperties;
18+
} as const;
1819

1920
export interface Link extends SlateElement {
2021
type: "link";
@@ -29,14 +30,15 @@ register({
2930
StaticElement: ({ attributes, children, element }) => {
3031
const node = element as Link;
3132
let { url, title } = node;
32-
const { AnchorTagComponent, urlTransform } = useFileContext();
33+
const { AnchorTagComponent, urlTransform, anchorStyle } = useFileContext();
34+
const style: CSS = { ...LINK_STYLE, ...anchorStyle };
3335
if (AnchorTagComponent != null) {
3436
return (
3537
<AnchorTagComponent
3638
{...attributes}
3739
href={url}
3840
title={title}
39-
style={LINK_STYLE}
41+
style={style}
4042
>
4143
{children}
4244
</AnchorTagComponent>
@@ -52,7 +54,7 @@ register({
5254
};
5355
}
5456
return (
55-
<a {...attributes} {...props} title={title} style={LINK_STYLE}>
57+
<a {...attributes} {...props} title={title} style={style}>
5658
{children}
5759
{isBlank(element) && <span contentEditable={false}>(blank link)</span>}
5860
</a>

src/packages/frontend/editors/slate/static-markdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ application.
1010
*/
1111

1212
import { CSSProperties, useEffect, useState } from "react";
13+
1314
import "./elements/init-ssr";
1415
import { getStaticRender } from "./elements/register";
15-
import { markdown_to_slate as markdownToSlate } from "./markdown-to-slate";
1616
import Leaf from "./leaf";
17+
import { markdown_to_slate as markdownToSlate } from "./markdown-to-slate";
1718
import { ChangeContext } from "./use-change";
1819

1920
interface Props {

src/packages/frontend/lib/file-context.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import React, {
1414
ReactNode,
1515
} from "react";
1616

17-
interface IFileContext {
17+
export interface IFileContext {
1818
// allow customizing anchor tags that get generated by various components, e.g., Markdown via slate.
1919
AnchorTagComponent?: React.FC<{
2020
href?: string;
@@ -41,6 +41,7 @@ interface IFileContext {
4141
// If given, then when an anchor (A) tag is clicked
4242
// on, the given function is called.
4343
anchorTagAction?: (url: string) => void;
44+
anchorStyle?: CSSProperties;
4445

4546
// If given, then all href and src attributes in all
4647
// tags are transformed by urlTransform, except anchor

src/packages/next/components/landing/cocalc-com-features.tsx

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function CoCalcComFeatures() {
3737
sandboxProjectId,
3838
jupyterApiEnabled,
3939
shareServer = false,
40+
onCoCalcCom,
4041
} = useCustomize();
4142
const width = Grid.useBreakpoint();
4243

@@ -515,7 +516,7 @@ export function CoCalcComFeatures() {
515516
}
516517

517518
function renderChatGPT() {
518-
if (!openaiEnabled) return;
519+
if (!openaiEnabled || !onCoCalcCom) return;
519520
return (
520521
<Info
521522
level={LANDING_HEADER_LEVEL}
@@ -576,28 +577,3 @@ export function CoCalcComFeatures() {
576577
</>
577578
);
578579
}
579-
580-
export function Hero() {
581-
return (
582-
<Info.Heading
583-
level={2}
584-
textStyle={{ color: "white" }}
585-
style={{
586-
backgroundColor: COLORS.BLUE_D,
587-
paddingBottom: "30px",
588-
marginTop: "30px",
589-
paddingTop: "30px",
590-
}}
591-
>
592-
Realtime collaborative{" "}
593-
<A href="/features/jupyter-notebook" style={{ color: "white" }}>
594-
Jupyter notebooks
595-
</A>
596-
,{" "}
597-
<A href="/features/latex-editor" style={{ color: "white" }}>
598-
LaTeX
599-
</A>
600-
, Markdown, and Linux with GPUs
601-
</Info.Heading>
602-
);
603-
}

src/packages/next/components/landing/header.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ export default function Header(props: Props) {
144144
</a>
145145
)}
146146
{enabledPages?.store && (
147-
<A
148-
href="/store"
149-
style={page == "store" ? SelectedStyle : LinkStyle}
150-
>
147+
<A href="/store" style={page == "store" ? SelectedStyle : LinkStyle}>
151148
Store
152149
</A>
153150
)}
@@ -255,6 +252,7 @@ export default function Header(props: Props) {
255252
</Layout.Header>
256253
<SubNav page={page} subPage={subPage} softwareEnv={softwareEnv} />
257254
{openaiEnabled &&
255+
onCoCalcCom &&
258256
page === "features" &&
259257
typeof subPage === "string" &&
260258
SHOW_AI_CHAT.includes(subPage) ? (
@@ -266,9 +264,9 @@ export default function Header(props: Props) {
266264
/>
267265
</div>
268266
) : undefined}
269-
{jupyterApiEnabled && onCoCalcCom && runnableTag && (
267+
{jupyterApiEnabled && onCoCalcCom && runnableTag ? (
270268
<DemoCell tag={runnableTag} />
271-
)}
269+
) : undefined}
272270
</>
273271
);
274272
}

src/packages/next/components/landing/index-list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Image, { StaticImageData } from "components/landing/image";
1212
import { Paragraph, Title } from "components/misc";
1313
import A from "components/misc/A";
1414
import { MAX_WIDTH } from "lib/config";
15-
import useCustomize from "lib/use-customize";
15+
import useCustomize, { CustomizeType } from "lib/use-customize";
1616

1717
export interface Item {
1818
link: string;
@@ -25,7 +25,7 @@ export interface Item {
2525
description: ReactNode;
2626
shareServer?: boolean; // only show if the share server is enabled
2727
landingPages?: boolean; // only show if landing pages are enabled.
28-
hide?: (CustomizeType) => boolean; // if returns true, then this item will be hidden.
28+
hide?: (customize: CustomizeType) => boolean; // if returns true, then this item will be hidden.
2929
}
3030

3131
export type DataSource = Item[];

src/packages/next/components/landing/sub-nav.tsx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Logo from "components/logo";
1919
import { CSS } from "components/misc";
2020
import A from "components/misc/A";
2121
import { MAX_WIDTH_LANDING } from "lib/config";
22-
import { useCustomize } from "lib/customize";
22+
import { CustomizeType, useCustomize } from "lib/customize";
2323

2424
const BASE_STYLE: CSS = {
2525
backgroundColor: "white",
@@ -124,10 +124,34 @@ const support = {
124124
community: { label: "Community" },
125125
new: { label: "New Ticket", hide: (customize) => !customize.zendesk },
126126
tickets: { label: "Tickets", hide: (customize) => !customize.zendesk },
127-
chatgpt: { label: "ChatGPT", hide: (customize) => !customize.openaiEnabled },
127+
chatgpt: {
128+
label: "ChatGPT",
129+
hide: (customize) => !customize.openaiEnabled || !customize.onCoCalcCom,
130+
},
128131
} as const;
129132

130-
const PAGES = {
133+
type PageKey =
134+
| "about"
135+
| "features"
136+
| "software"
137+
| "pricing"
138+
| "policies"
139+
| "share"
140+
| "info"
141+
| "sign-up"
142+
| "sign-in"
143+
| "try"
144+
| "support"
145+
| "news"
146+
| "store";
147+
148+
const PAGES: {
149+
[top in PageKey]:
150+
| {
151+
[page: string]: { label: string; hide?: (c: CustomizeType) => boolean };
152+
}
153+
| { index: {} };
154+
} = {
131155
about,
132156
features,
133157
software,
@@ -143,7 +167,7 @@ const PAGES = {
143167
store: {},
144168
} as const;
145169

146-
export type Page = keyof typeof PAGES | "account";
170+
export type Page = PageKey | "account";
147171
export type SubPage =
148172
| keyof typeof software
149173
| keyof typeof features
@@ -181,6 +205,10 @@ export default function SubNav(props: Props) {
181205
}, [subnavRef]);
182206

183207
if (page == null) return null;
208+
209+
// if we define a custom support page, render it instead – and hide the sub menu
210+
if (customize.support && !customize.onCoCalcCom) return null;
211+
184212
const tabs: JSX.Element[] = [];
185213
const p = PAGES[page];
186214
if (p == null || isEmpty(p)) return null;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.
3+
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
4+
*/
5+
6+
import { COLORS } from "@cocalc/util/theme";
7+
import Info from "components/landing/info";
8+
import { CSS } from "components/misc";
9+
import A from "components/misc/A";
10+
import SanitizedMarkdown from "components/misc/sanitized-markdown";
11+
12+
const A_STYLE: CSS = {
13+
color: "white",
14+
backgroundColor: "transparent",
15+
} as const;
16+
17+
export function Tagline({ value }: { value?: string }) {
18+
function renderContent() {
19+
if (value) {
20+
return <SanitizedMarkdown value={value} anchorStyle={A_STYLE} />;
21+
} else {
22+
return (
23+
<>
24+
Realtime collaborative{" "}
25+
<A href="/features/jupyter-notebook" style={A_STYLE}>
26+
Jupyter notebooks
27+
</A>
28+
,{" "}
29+
<A href="/features/latex-editor" style={A_STYLE}>
30+
LaTeX
31+
</A>
32+
, Markdown, and Linux with GPUs
33+
</>
34+
);
35+
}
36+
}
37+
38+
return (
39+
<Info.Heading
40+
level={2}
41+
textStyle={{ color: "white" }}
42+
style={{
43+
backgroundColor: COLORS.BLUE_D,
44+
paddingBottom: "30px",
45+
marginTop: "30px",
46+
paddingTop: "30px",
47+
}}
48+
>
49+
{renderContent()}
50+
</Info.Heading>
51+
);
52+
}

src/packages/next/components/misc/A.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55

66
import Link from "next/link";
7-
import basePath from "lib/base-path";
87
import { join } from "path";
98

9+
import basePath from "lib/base-path";
10+
1011
export default function A(props: any) {
1112
const { href } = props;
1213
if (href == null) {

0 commit comments

Comments
 (0)