Skip to content

Commit b69dbdf

Browse files
committed
Merge remote-tracking branch 'origin/master' into sagews-soft-deprecation
2 parents bc260c8 + c53885f commit b69dbdf

File tree

8 files changed

+189
-93
lines changed

8 files changed

+189
-93
lines changed

src/packages/frontend/project/explorer/action-bar.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import React from "react";
77
import * as immutable from "immutable";
8-
import { HiddenSM, Icon, Gap } from "../../components";
8+
import { FormattedMessage } from "react-intl";
9+
10+
import { HiddenSM, Icon, Gap } from "@cocalc/frontend/components";
911
import { COLORS } from "@cocalc/util/theme";
1012
import { ComputeImages } from "@cocalc/frontend/custom-software/init";
1113
import { ProjectActions } from "@cocalc/frontend/project_store";
@@ -15,10 +17,10 @@ import {
1517
ButtonGroup,
1618
ButtonToolbar,
1719
} from "@cocalc/frontend/antd-bootstrap";
18-
1920
import { CustomSoftwareInfo } from "@cocalc/frontend/custom-software/info-bar";
2021
import * as misc from "@cocalc/util/misc";
2122
import { file_actions } from "@cocalc/frontend/project_store";
23+
import { useStudentProjectFunctionality } from "@cocalc/frontend/course";
2224

2325
const ROW_INFO_STYLE = {
2426
color: COLORS.GRAY,
@@ -41,8 +43,6 @@ interface Props {
4143
project_is_running?: boolean;
4244
}
4345

44-
import { useStudentProjectFunctionality } from "@cocalc/frontend/course";
45-
4646
export const ActionBar: React.FC<Props> = (props: Props) => {
4747
const [select_entire_directory, set_select_entire_directory] = React.useState<
4848
"hidden" | "check" | "clear"
@@ -166,7 +166,13 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
166166
<span>{`${total} ${misc.plural(total, "item")}`}</span>
167167
<div style={{ display: "inline" }}>
168168
{" "}
169-
&mdash; Click checkbox to the left of a file to copy, download, etc.
169+
&mdash;{" "}
170+
<FormattedMessage
171+
id="project.explorer.action-bar.currently_selected.info"
172+
defaultMessage={
173+
"Click checkbox to the left of a file to copy, download, etc."
174+
}
175+
/>
170176
</div>
171177
</div>
172178
);

src/packages/frontend/project/explorer/misc-side-buttons.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { join } from "path";
77
import React from "react";
8-
import { useIntl } from "react-intl";
8+
import { defineMessage, useIntl } from "react-intl";
99

1010
import {
1111
Button,
@@ -23,6 +23,11 @@ import { KUCALC_COCALC_COM } from "@cocalc/util/db-schema/site-defaults";
2323
import { serverURL, SPEC } from "../named-server-panel";
2424
import TourButton from "./tour/button";
2525

26+
const OPEN_MSG = defineMessage({
27+
id: "project.explorer.misc-side-buttons.open_dir.tooltip",
28+
defaultMessage: `Opens the current directory in a {name} server instance, running inside this project.`,
29+
});
30+
2631
interface Props {
2732
actions: ProjectActions;
2833
available_features?: Available;
@@ -143,12 +148,12 @@ export const MiscSideButtons: React.FC<Props> = (props) => {
143148
const abspath = join(homeDirectory, current_path ?? "");
144149
// setting ?folder= tells VS Code to open that directory
145150
const url = `${serverURL(project_id, "code")}?folder=${abspath}`;
151+
const values = { name: SPEC.code.longName };
152+
const tooltip = intl.formatMessage(OPEN_MSG, values);
153+
const description = intl.formatMessage(SPEC.code.description, values);
146154
return (
147155
<LinkRetry href={url} mode="button">
148-
<Tip
149-
title={`Opens the current directory in a Visual Studio Code IDE server instance, running inside this project. ${SPEC.code.description}`}
150-
placement="bottom"
151-
>
156+
<Tip title={`${tooltip} ${description}`} placement="bottom">
152157
<Icon name={SPEC.code.icon} /> <VisibleLG>VS Code</VisibleLG>
153158
</Tip>
154159
</LinkRetry>
@@ -163,12 +168,12 @@ export const MiscSideButtons: React.FC<Props> = (props) => {
163168
// we make sure the url ends wiht a slash, without messing up the full URL
164169
const s = base.slice(base.length - 1) === "/" ? "" : "/";
165170
const url = `${base}${s}${current_path ? "lab/tree/" + current_path : ""}`;
171+
const values = { name: SPEC.code.longName };
172+
const tooltip = intl.formatMessage(OPEN_MSG, values);
173+
const description = intl.formatMessage(SPEC.jupyterlab.description, values);
166174
return (
167175
<LinkRetry href={url} mode="button">
168-
<Tip
169-
title={`Opens the current directory in a JupyterLab server instance, running inside this project. ${SPEC.jupyterlab.description}`}
170-
placement="bottom"
171-
>
176+
<Tip title={`${tooltip} ${description}`} placement="bottom">
172177
<Icon name={SPEC.jupyterlab.icon} /> <VisibleLG>JupyterLab</VisibleLG>
173178
</Tip>
174179
</LinkRetry>

src/packages/frontend/project/named-server-panel.tsx

Lines changed: 76 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ Jupyter notebook server is running, then pops it up in a new tab.
99
*/
1010

1111
import { join } from "path";
12-
import React from "react";
12+
import { defineMessage, FormattedMessage, useIntl } from "react-intl";
1313

14+
import { CSS } from "@cocalc/frontend/app-framework";
1415
import {
1516
Icon,
1617
IconName,
@@ -20,16 +21,23 @@ import {
2021
import LinkRetry from "@cocalc/frontend/components/link-retry";
2122
import { useStudentProjectFunctionality } from "@cocalc/frontend/course";
2223
import { appBasePath } from "@cocalc/frontend/customize/app-base-path";
24+
import { IntlMessage } from "@cocalc/frontend/i18n";
2325
import track from "@cocalc/frontend/user-tracking";
2426
import { R_IDE } from "@cocalc/util/consts/ui";
2527
import { capitalize } from "@cocalc/util/misc";
2628
import { COLORS } from "@cocalc/util/theme";
2729
import { NamedServerName } from "@cocalc/util/types/servers";
2830
import { useAvailableFeatures } from "./use-available-features";
2931

32+
const LAUNCHING_SERVER = defineMessage({
33+
id: "project.named-server-panel.launching_server",
34+
defaultMessage: "Launching server...",
35+
description: "A web-service is starting.",
36+
});
37+
3038
interface Server {
3139
longName: string;
32-
description: React.ReactNode;
40+
description: IntlMessage;
3341
usesBasePath: boolean;
3442
icon: IconName;
3543
}
@@ -39,46 +47,59 @@ export const SPEC: {
3947
} = {
4048
jupyter: {
4149
longName: "Jupyter Classic Notebook",
42-
description: `The Jupyter Classic notebook server runs in your project and provides
43-
support for classical Jupyter notebooks. You can also use the plain
44-
classical Jupyter notebook server directly via the link below. This
45-
does not support multiple users or TimeTravel, but fully supports all
46-
classical Jupyter notebook features and extensions.`,
50+
description: defineMessage({
51+
id: "project.named-server-panel.spec.jupyter.description",
52+
defaultMessage: `The Jupyter Classic notebook server runs in your project and provides
53+
support for classical Jupyter notebooks.
54+
You can also use the plain classical Jupyter notebook server directly via the link below.
55+
This does not support multiple users or TimeTravel,
56+
but fully supports all classical Jupyter notebook features and extensions.`,
57+
}),
4758
usesBasePath: true,
4859
icon: "ipynb",
4960
},
5061
jupyterlab: {
5162
longName: "JupyterLab Notebook",
52-
description: `The JupyterLab server runs from your project and provides support for
53-
Jupyter notebooks, terminals, drag and drop, with a nice multiwindow
54-
layout, and much more. JupyterLab does not yet support multiple users
55-
or TimeTravel, but fully supports most Jupyter notebook features and
56-
extensions.`,
63+
description: defineMessage({
64+
id: "project.named-server-panel.spec.jupyterlab.description",
65+
defaultMessage: `The JupyterLab server runs from your project and provides support for Jupyter notebooks,
66+
terminals, drag and drop, with a nice multiwindow layout, and much more.
67+
JupyterLab does not yet support multiple users or TimeTravel,
68+
but fully supports most Jupyter notebook features and extensions.`,
69+
}),
5770
usesBasePath: true,
5871
icon: "ipynb",
5972
},
6073
code: {
6174
longName: "Visual Studio Code",
62-
description: `Visual Studio Code is a source-code editor made by Microsoft. Features
63-
include support for debugging, syntax highlighting, intelligent
64-
code completion, snippets, code refactoring, and embedded Git.`,
75+
description: defineMessage({
76+
id: "project.named-server-panel.spec.code.description",
77+
defaultMessage: `Visual Studio Code is a source-code editor made by Microsoft.
78+
Features include support for debugging, syntax highlighting,
79+
intelligent code completion, snippets, code refactoring, and embedded Git.`,
80+
}),
6581
usesBasePath: false,
6682
icon: "vscode",
6783
},
6884
pluto: {
6985
longName: "Julia Pluto.jl",
70-
description: (
71-
<>
72-
Reactive notebooks for Julia.{" "}
73-
<b>NOTE: Pluto may take a long time to start, so be patient.</b>
74-
</>
75-
),
86+
description: defineMessage({
87+
id: "project.named-server-panel.spec.pluto.description",
88+
defaultMessage: `Reactive notebooks for Julia.
89+
<b>NOTE: Pluto may take a long time to start, so be patient.</b> `,
90+
}),
91+
7692
usesBasePath: false,
7793
icon: "julia",
7894
},
7995
rserver: {
8096
longName: R_IDE,
81-
description: `This is an integrated development environment (IDE) for R, sometimes called "R Studio". It is provided without any modifications. DISCLAIMER: Posit Software, PBC (formerly RStudio, PBC) IS IN NO WAY ASSOCIATED WITH COCALC.`,
97+
description: defineMessage({
98+
id: "project.named-server-panel.spec.rserver.description",
99+
defaultMessage: `This is an integrated development environment (IDE) for R, sometimes called "R Studio".
100+
It is provided without any modifications.
101+
<b>DISCLAIMER: Posit Software, PBC (formerly RStudio, PBC) IS IN NO WAY ASSOCIATED WITH COCALC.</b>`,
102+
}),
82103
usesBasePath: false,
83104
icon: "r",
84105
},
@@ -89,66 +110,76 @@ function getServerInfo(name: NamedServerName): Server {
89110
SPEC[name] ?? {
90111
icon: "server",
91112
longName: `${capitalize(name)} Server`,
92-
description: `The ${capitalize(
93-
name,
94-
)} server runs from your project. It does not yet
95-
support multiple users or TimeTravel, but fully supports most other
96-
features and extensions of ${name}.`,
113+
description: defineMessage({
114+
id: "project.named-server-panel.spec.server.description",
115+
defaultMessage: `The {name} server runs from your project.
116+
It does not yet support multiple users or TimeTravel,
117+
but fully supports most other features and extensions of {name}.`,
118+
}),
97119
}
98120
);
99121
}
100122

123+
const DISABLED = defineMessage({
124+
id: "project.named-server-panel.disabled.info",
125+
defaultMessage: `"Disabled. Please contact your instructor if you need to use {longName}.`,
126+
});
127+
101128
interface Props {
102129
project_id: string;
103130
name: NamedServerName;
104-
style?;
131+
style?: CSS;
105132
}
106133

107134
export function NamedServerPanel({ project_id, name, style }: Props) {
135+
const intl = useIntl();
136+
108137
const student_project_functionality =
109138
useStudentProjectFunctionality(project_id);
110139

111-
const { longName, description, icon } = getServerInfo(name);
140+
const { longName, description: descMsg, icon } = getServerInfo(name);
141+
const description = intl.formatMessage(descMsg, { name: capitalize(name) });
112142

113143
let body;
114144
if (
115145
name === "jupyterlab" &&
116146
student_project_functionality.disableJupyterLabServer
117147
) {
118-
body =
119-
"Disabled. Please contact your instructor if you need to use Jupyter Lab";
148+
body = intl.formatMessage(DISABLED, { longName });
120149
} else if (
121150
name === "jupyter" &&
122151
student_project_functionality.disableJupyterClassicServer
123152
) {
124-
body =
125-
"Disabled. Please contact your instructor if you need to use Jupyter Classic.";
153+
body = intl.formatMessage(DISABLED, { longName });
126154
} else if (
127155
name === "code" &&
128156
student_project_functionality.disableVSCodeServer
129157
) {
130-
body =
131-
"Disabled. Please contact your instructor if you need to use VS Code.";
158+
body = intl.formatMessage(DISABLED, { longName });
132159
} else if (
133160
name === "pluto" &&
134161
student_project_functionality.disablePlutoServer
135162
) {
136-
body = "Disabled. Please contact your instructor if you need to use Pluto.";
163+
body = intl.formatMessage(DISABLED, { longName });
137164
} else if (
138165
name === "rserver" &&
139166
student_project_functionality.disableRServer
140167
) {
141-
body =
142-
"Disabled. Please contact your instructor if you need to use RStudio.";
168+
body = intl.formatMessage(DISABLED, { longName });
143169
} else {
144170
body = (
145171
<>
146172
<Paragraph style={{ color: COLORS.GRAY_D }}>
147173
{description}
148174
<br />
149175
<br />
150-
Starting your {longName} server. It will then attempt to open in a new
151-
browser tab. If this doesn't work, check for a popup blocker warning!
176+
<FormattedMessage
177+
id="project.named-server-panel.long_start_info"
178+
defaultMessage={`Starting your {longName} server.
179+
It will then attempt to open in a new browser tab.
180+
If this doesn't work, check for a popup blocker warning!`}
181+
values={{ longName }}
182+
/>
152183
</Paragraph>
153184
<Paragraph
154185
style={{ textAlign: "center", fontSize: "14pt", margin: "15px" }}
@@ -157,7 +188,7 @@ export function NamedServerPanel({ project_id, name, style }: Props) {
157188
maxTime={1000 * 60 * 5}
158189
autoStart
159190
href={serverURL(project_id, name)}
160-
loadingText="Launching server..."
191+
loadingText={intl.formatMessage(LAUNCHING_SERVER)}
161192
onClick={() => {
162193
track("launch-server", { name, project_id });
163194
}}
@@ -196,6 +227,7 @@ export function ServerLink({
196227
name: NamedServerName;
197228
mode: "flyout" | "full";
198229
}) {
230+
const intl = useIntl();
199231
const student_project_functionality =
200232
useStudentProjectFunctionality(project_id);
201233
const available = useAvailableFeatures(project_id);
@@ -227,12 +259,13 @@ export function ServerLink({
227259
) {
228260
return null;
229261
} else {
230-
const { icon, longName, description } = getServerInfo(name);
262+
const { icon, longName, description: descMsg } = getServerInfo(name);
263+
const description = intl.formatMessage(descMsg, { name: capitalize(name) });
231264
return (
232265
<LinkRetry
233266
maxTime={1000 * 60 * 5}
234267
href={serverURL(project_id, name)}
235-
loadingText="Launching server..."
268+
loadingText={intl.formatMessage(LAUNCHING_SERVER)}
236269
tooltip={mode === "flyout" ? description : undefined}
237270
onClick={() => {
238271
track("launch-server", { name, project_id });

0 commit comments

Comments
 (0)