Skip to content

Commit 94bbec9

Browse files
committed
Merge branch 'master' into issue-3798
2 parents e2096bc + 572b64a commit 94bbec9

25 files changed

+788
-147
lines changed

src/packages/frontend/account/account-preferences.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ export const AccountPreferences: React.FC = () => {
148148
{render_account_settings()}
149149
<ProfileSettings
150150
email_address={email_address}
151-
first_name={first_name}
152-
last_name={last_name}
151+
// first_name={first_name}
152+
// last_name={last_name}
153153
/>
154154
{render_other_settings()}
155155
{!is_anonymous && <ApiKeys />}

src/packages/frontend/account/editor-settings/checkboxes.tsx

Lines changed: 109 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,96 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6+
import { defineMessage, useIntl } from "react-intl";
7+
68
import { Checkbox } from "@cocalc/frontend/antd-bootstrap";
7-
import { Component, Rendered } from "@cocalc/frontend/app-framework";
8-
import { capitalize, is_different, keys } from "@cocalc/util/misc";
9-
import { JUPYTER_CLASSIC_MODERN } from "@cocalc/util/theme";
9+
import { Rendered } from "@cocalc/frontend/app-framework";
1010
import { A } from "@cocalc/frontend/components";
11+
import { IntlMessage, isIntlMessage } from "@cocalc/frontend/i18n";
12+
import { capitalize, keys } from "@cocalc/util/misc";
13+
import { JUPYTER_CLASSIC_MODERN } from "@cocalc/util/theme";
1114

12-
const EDITOR_SETTINGS_CHECKBOXES: { [setting: string]: string | Rendered } = {
13-
extra_button_bar:
14-
"customizable button bar below menu bar with shortcuts to menu items",
15-
line_wrapping: "wrap long lines",
16-
line_numbers: "show line numbers",
17-
jupyter_line_numbers: "show line numbers in Jupyter notebooks",
18-
code_folding: "fold code using control+Q",
19-
smart_indent: "context sensitive indentation",
20-
electric_chars: "sometimes reindent current line",
21-
match_brackets: "highlight matching brackets near cursor",
22-
auto_close_brackets: "automatically close brackets",
23-
match_xml_tags: "automatically match XML tags",
24-
auto_close_xml_tags: "automatically close XML tags",
25-
auto_close_latex: "automatically close LaTeX environments",
26-
strip_trailing_whitespace: "remove whenever file is saved",
27-
show_trailing_whitespace: "show spaces at ends of lines",
28-
spaces_instead_of_tabs: "send spaces when the tab key is pressed",
29-
build_on_save: "build LaTex/Rmd files whenever it is saved to disk",
30-
show_exec_warning: "warn that certain files are not directly executable",
31-
ask_jupyter_kernel: "ask which kernel to use for a new Jupyter Notebook",
32-
disable_jupyter_virtualization:
33-
"render entire notebook instead of just visible part (slower and not recommended)",
15+
const EDITOR_SETTINGS_CHECKBOXES: {
16+
[setting: string]: IntlMessage | Rendered;
17+
} = {
18+
extra_button_bar: defineMessage({
19+
id: "account.editor-setting.checkbox.extra_button_bar",
20+
defaultMessage:
21+
"customizable button bar below menu bar with shortcuts to menu items",
22+
}),
23+
line_wrapping: defineMessage({
24+
id: "account.editor-setting.checkbox.line_wrapping",
25+
defaultMessage: "wrap long lines",
26+
}),
27+
line_numbers: defineMessage({
28+
id: "account.editor-setting.checkbox.line_numbers",
29+
defaultMessage: "show line numbers",
30+
}),
31+
jupyter_line_numbers: defineMessage({
32+
id: "account.editor-setting.checkbox.jupyter_line_numbers",
33+
defaultMessage: "show line numbers in Jupyter Notebooks",
34+
}),
35+
code_folding: defineMessage({
36+
id: "account.editor-setting.checkbox.code_folding",
37+
defaultMessage: "fold code using control+Q",
38+
}),
39+
smart_indent: defineMessage({
40+
id: "account.editor-setting.checkbox.smart_indent",
41+
defaultMessage: "context sensitive indentation",
42+
}),
43+
electric_chars: defineMessage({
44+
id: "account.editor-setting.checkbox.electric_chars",
45+
defaultMessage: "sometimes reindent current line",
46+
}),
47+
match_brackets: defineMessage({
48+
id: "account.editor-setting.checkbox.match_brackets",
49+
defaultMessage: "highlight matching brackets near cursor",
50+
}),
51+
auto_close_brackets: defineMessage({
52+
id: "account.editor-setting.checkbox.auto_close_brackets",
53+
defaultMessage: "automatically close brackets",
54+
}),
55+
match_xml_tags: defineMessage({
56+
id: "account.editor-setting.checkbox.match_xml_tags",
57+
defaultMessage: "automatically match XML tags",
58+
}),
59+
auto_close_xml_tags: defineMessage({
60+
id: "account.editor-setting.checkbox.auto_close_xml_tags",
61+
defaultMessage: "automatically close XML tags",
62+
}),
63+
auto_close_latex: defineMessage({
64+
id: "account.editor-setting.checkbox.auto_close_latex",
65+
defaultMessage: "automatically close LaTeX environments",
66+
}),
67+
strip_trailing_whitespace: defineMessage({
68+
id: "account.editor-setting.checkbox.strip_trailing_whitespace",
69+
defaultMessage: "remove whenever file is saved",
70+
}),
71+
show_trailing_whitespace: defineMessage({
72+
id: "account.editor-setting.checkbox.show_trailing_whitespace",
73+
defaultMessage: "show spaces at ends of lines",
74+
}),
75+
spaces_instead_of_tabs: defineMessage({
76+
id: "account.editor-setting.checkbox.spaces_instead_of_tabs",
77+
defaultMessage: "send spaces when the tab key is pressed",
78+
}),
79+
build_on_save: defineMessage({
80+
id: "account.editor-setting.checkbox.build_on_save",
81+
defaultMessage: "build LaTex/Rmd files whenever it is saved to disk",
82+
}),
83+
show_exec_warning: defineMessage({
84+
id: "account.editor-setting.checkbox.show_exec_warning",
85+
defaultMessage: "warn that certain files are not directly executable",
86+
}),
87+
ask_jupyter_kernel: defineMessage({
88+
id: "account.editor-setting.checkbox.ask_jupyter_kernel",
89+
defaultMessage: "ask which kernel to use for a new Jupyter Notebook",
90+
}),
91+
disable_jupyter_virtualization: defineMessage({
92+
id: "account.editor-setting.checkbox.disable_jupyter_virtualization",
93+
defaultMessage:
94+
"render entire Jupyter Notebook instead of just visible part (slower and not recommended)",
95+
}),
3496
jupyter_classic: (
3597
<span>
3698
<A href="https://github.com/sagemathinc/cocalc/issues/7706">
@@ -50,15 +112,13 @@ interface Props {
50112
on_change: Function;
51113
}
52114

53-
export class EditorSettingsCheckboxes extends Component<Props> {
54-
public shouldComponentUpdate(props): boolean {
55-
return is_different(this.props, props, [
56-
"editor_settings",
57-
"email_address",
58-
]);
59-
}
115+
export function EditorSettingsCheckboxes(props: Props) {
116+
const intl = useIntl();
60117

61-
private label_checkbox(name: string, desc: string | Rendered): Rendered {
118+
function label_checkbox(
119+
name: string,
120+
desc: IntlMessage | Rendered,
121+
): Rendered {
62122
return (
63123
<span>
64124
{capitalize(
@@ -68,37 +128,38 @@ export class EditorSettingsCheckboxes extends Component<Props> {
68128
.replace("xml", "XML")
69129
.replace("latex", "LaTeX"),
70130
) + ": "}
71-
{desc}
131+
{isIntlMessage(desc) ? intl.formatMessage(desc) : desc}
72132
</span>
73133
);
74134
}
75135

76-
private render_checkbox(name: string, desc: string | Rendered): Rendered {
136+
function render_checkbox(
137+
name: string,
138+
desc: IntlMessage | Rendered,
139+
): Rendered {
77140
if (
78-
this.props.email_address?.indexOf("minervaproject.com") != -1 &&
141+
props.email_address?.indexOf("minervaproject.com") != -1 &&
79142
name === "jupyter_classic"
80143
) {
81144
// Special case -- minerva doesn't get the jupyter classic option, to avoid student confusion.
82145
return;
83146
}
84147
return (
85148
<Checkbox
86-
checked={!!this.props.editor_settings.get(name)}
149+
checked={!!props.editor_settings.get(name)}
87150
key={name}
88-
onChange={(e) => this.props.on_change(name, e.target.checked)}
151+
onChange={(e) => props.on_change(name, e.target.checked)}
89152
>
90-
{this.label_checkbox(name, desc)}
153+
{label_checkbox(name, desc)}
91154
</Checkbox>
92155
);
93156
}
94157

95-
public render(): JSX.Element {
96-
return (
97-
<span>
98-
{keys(EDITOR_SETTINGS_CHECKBOXES).map((name) =>
99-
this.render_checkbox(name, EDITOR_SETTINGS_CHECKBOXES[name]),
100-
)}
101-
</span>
102-
);
103-
}
158+
return (
159+
<span>
160+
{keys(EDITOR_SETTINGS_CHECKBOXES).map((name) =>
161+
render_checkbox(name, EDITOR_SETTINGS_CHECKBOXES[name]),
162+
)}
163+
</span>
164+
);
104165
}

src/packages/frontend/account/editor-settings/keyboard-bindings.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6+
import { useIntl } from "react-intl";
67

7-
import { LabeledRow, SelectorInput } from "../../components";
8+
import { LabeledRow, SelectorInput } from "@cocalc/frontend/components";
89
import { EDITOR_BINDINGS } from "@cocalc/util/db-schema/accounts";
910

1011
interface Props {
@@ -13,8 +14,15 @@ interface Props {
1314
}
1415

1516
export function EditorSettingsKeyboardBindings(props: Props): JSX.Element {
17+
const intl = useIntl();
18+
19+
const label = intl.formatMessage({
20+
id: "account.editor-settings.keyboard-bindings.label",
21+
defaultMessage: "Editor keyboard bindings",
22+
});
23+
1624
return (
17-
<LabeledRow label="Editor keyboard bindings">
25+
<LabeledRow label={label}>
1826
<SelectorInput
1927
options={EDITOR_BINDINGS}
2028
selected={props.bindings}

src/packages/frontend/account/editor-settings/x11-keyboard.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,35 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { LabeledRow, Loading, SelectorInput } from "../../components";
6+
import { useIntl } from "react-intl";
77

8-
import { PHYSICAL_KEYBOARDS } from "../../frame-editors/x11-editor/xpra/keyboards";
8+
import {
9+
LabeledRow,
10+
Loading,
11+
SelectorInput,
12+
} from "@cocalc/frontend/components";
13+
import { PHYSICAL_KEYBOARDS } from "@cocalc/frontend/frame-editors/x11-editor/xpra/keyboards";
914

1015
interface PhysicalKeyboardProps {
1116
physical_keyboard: string;
1217
on_change: (selected: string) => void;
1318
}
1419

1520
export function EditorSettingsPhysicalKeyboard(
16-
props: PhysicalKeyboardProps
21+
props: PhysicalKeyboardProps,
1722
): JSX.Element {
23+
const intl = useIntl();
24+
1825
if (props.physical_keyboard === "NO_DATA") {
1926
return <Loading />;
2027
} else {
28+
const label = intl.formatMessage({
29+
id: "account.editor-settings.x11-physical-keyboard.label",
30+
defaultMessage: "Keyboard layout (for X11 Desktop)",
31+
});
32+
2133
return (
22-
<LabeledRow label="Keyboard layout (for X11 Desktop)">
34+
<LabeledRow label={label}>
2335
<SelectorInput
2436
options={PHYSICAL_KEYBOARDS}
2537
selected={props.physical_keyboard}
@@ -38,13 +50,20 @@ interface KeyboardVariantProps {
3850
}
3951

4052
export function EditorSettingsKeyboardVariant(
41-
props: KeyboardVariantProps
53+
props: KeyboardVariantProps,
4254
): JSX.Element {
55+
const intl = useIntl();
56+
4357
if (props.keyboard_variant === "NO_DATA") {
4458
return <Loading />;
4559
} else {
60+
const label = intl.formatMessage({
61+
id: "account.editor-settings.x11-keyboard-variant.label",
62+
defaultMessage: "Keyboard variant (for X11 Desktop)",
63+
});
64+
4665
return (
47-
<LabeledRow label="Keyboard variant (for X11 Desktop)">
66+
<LabeledRow label={label}>
4867
<SelectorInput
4968
options={props.keyboard_variant_options}
5069
selected={props.keyboard_variant}

0 commit comments

Comments
 (0)