Skip to content

Commit b788faf

Browse files
committed
Merge branch 'master' of github.com:sagemathinc/cocalc
2 parents b3f35a0 + 25d3957 commit b788faf

File tree

110 files changed

+6809
-5779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+6809
-5779
lines changed

src/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@
3838
"bugs": {
3939
"url": "https://github.com/sagemathinc/cocalc/issues"
4040
},
41-
"homepage": "https://github.com/sagemathinc/cocalc"
41+
"homepage": "https://github.com/sagemathinc/cocalc",
42+
"dependencies": {
43+
"lru-cache": "^7.18.3"
44+
}
4245
}

src/packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"debug": "^4.3.2",
4040
"fs-extra": "^11.2.0",
4141
"lodash": "^4.17.21",
42-
"lru-cache": "^7.14.1",
42+
"lru-cache": "^7.18.3",
4343
"password-hash": "^1.2.2",
4444
"prom-client": "^13.0.0",
4545
"rimraf": "^5.0.5",

src/packages/database/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"immutable": "^4.3.0",
3333
"json-stable-stringify": "^1.0.1",
3434
"lodash": "^4.17.21",
35-
"lru-cache": "^7.14.1",
35+
"lru-cache": "^7.18.3",
3636
"node-fetch": "2.6.7",
3737
"pg": "^8.7.1",
3838
"random-key": "^0.3.2",

src/packages/database/qdrant/jsonl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function save({
5757
"vectors to save in",
5858
collection,
5959
"to",
60-
file
60+
file,
6161
);
6262

6363
// Create a write stream for the output file
@@ -66,7 +66,7 @@ export async function save({
6666
// Fetch all points in the collection in blocks, compressing and
6767
// writing them to the output file
6868
let offset: string | undefined = undefined;
69-
for (let n = 0; n < vectors_count; n += batchSize) {
69+
for (let n = 0; n < (vectors_count ?? 0); n += batchSize) {
7070
log("save: from ", n, " to ", n + batchSize);
7171
const { points } = await client.scroll(collection, {
7272
limit: batchSize + (offset ? 1 : 0),
@@ -79,7 +79,7 @@ export async function save({
7979
// delete first point since it was the offset.
8080
points.shift();
8181
}
82-
offset = points[points.length-1].id as string;
82+
offset = points[points.length - 1].id as string;
8383
for (const point of points) {
8484
const compressedLine = JSON.stringify(point) + "\n";
8585
compressedStream.write(compressedLine);

src/packages/database/qdrant/sqlite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export async function save({
6868
// Fetch all points in the collection in blocks, inserting them
6969
// into our database.
7070
let offset: string | undefined = undefined;
71-
for (let n = 0; n < vectors_count; n += batchSize) {
71+
for (let n = 0; n < (vectors_count ?? 0); n += batchSize) {
7272
log("save: from ", n, " to ", n + batchSize);
7373
const { points } = await client.scroll(collection, {
7474
limit: batchSize + (offset ? 1 : 0),
@@ -84,7 +84,7 @@ export async function save({
8484
offset = points[points.length - 1].id as string;
8585
// insert points into the sqlite3 table collection efficiently:
8686
const insertStmt = db.prepare(
87-
`INSERT INTO ${collection} (id, payload, vector) VALUES (?, ?, ?)`
87+
`INSERT INTO ${collection} (id, payload, vector) VALUES (?, ?, ?)`,
8888
);
8989

9090
db.transaction(() => {

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

Lines changed: 6 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ for different account related information
1010
and configuration.
1111
*/
1212

13-
import { useState } from "react";
14-
import { DownOutlined } from "@ant-design/icons";
15-
import { Button, Dropdown, MenuProps, Modal, Space, Tooltip } from "antd";
13+
import { Space } from "antd";
1614
import { useIntl } from "react-intl";
15+
1716
import { SignOut } from "@cocalc/frontend/account/sign-out";
1817
import { AntdTabItem, Col, Row, Tabs } from "@cocalc/frontend/antd-bootstrap";
1918
import {
@@ -22,17 +21,10 @@ import {
2221
useTypedRedux,
2322
useWindowDimensions,
2423
} from "@cocalc/frontend/app-framework";
25-
import { useLocalizationCtx } from "@cocalc/frontend/app/localize";
26-
import { Icon, Loading, Paragraph } from "@cocalc/frontend/components";
24+
import { Icon, Loading } from "@cocalc/frontend/components";
2725
import { cloudFilesystemsEnabled } from "@cocalc/frontend/compute";
2826
import CloudFilesystems from "@cocalc/frontend/compute/cloud-filesystem/cloud-filesystems";
29-
import {
30-
getLocale,
31-
labels,
32-
Locale,
33-
LOCALIZATIONS,
34-
OTHER_SETTINGS_LOCALE_KEY,
35-
} from "@cocalc/frontend/i18n";
27+
import { labels } from "@cocalc/frontend/i18n";
3628
import { LandingPage } from "@cocalc/frontend/landing-page/landing-page";
3729
import { local_storage_length } from "@cocalc/frontend/misc/local-storage";
3830
import PurchasesPage from "@cocalc/frontend/purchases/purchases-page";
@@ -44,19 +36,18 @@ import {
4436
KUCALC_ON_PREMISES,
4537
} from "@cocalc/util/db-schema/site-defaults";
4638
import { AccountPreferences } from "./account-preferences";
39+
import { I18NSelector } from "./i18n-selector";
4740
import { LicensesPage } from "./licenses/licenses-page";
4841
import { PublicPaths } from "./public-paths/public-paths";
4942
import { SSHKeysPage } from "./ssh-keys/global-ssh-keys";
5043
import { UpgradesPage } from "./upgrades/upgrades-page";
5144

5245
export const AccountPage: React.FC = () => {
5346
const intl = useIntl();
54-
const { setLocale, locale } = useLocalizationCtx();
5547

5648
const { width: windowWidth } = useWindowDimensions();
5749
const isWide = windowWidth > 800;
5850

59-
const other_settings = useTypedRedux("account", "other_settings");
6051
const active_page = useTypedRedux("account", "active_page");
6152
const is_logged_in = useTypedRedux("account", "is_logged_in");
6253
const account_id = useTypedRedux("account", "account_id");
@@ -85,8 +76,6 @@ export const AccountPage: React.FC = () => {
8576
const ssh_gateway = useTypedRedux("customize", "ssh_gateway");
8677
const is_commercial = useTypedRedux("customize", "is_commercial");
8778
const get_api_key = useTypedRedux("page", "get_api_key");
88-
const i18n_enabled = useTypedRedux("customize", "i18n");
89-
const [langOpen, setLangOpen] = useState<boolean>(false);
9079

9180
// for each exclusive domain, tell the user which strategy to use
9281
const exclusive_sso_domains = React.useMemo(() => {
@@ -264,126 +253,10 @@ export const AccountPage: React.FC = () => {
264253
return items;
265254
}
266255

267-
function renderI18N(): JSX.Element | null {
268-
if (
269-
i18n_enabled == null ||
270-
i18n_enabled.isEmpty() ||
271-
(i18n_enabled.size === 1 && i18n_enabled.includes("en"))
272-
) {
273-
return null;
274-
}
275-
276-
const i18n: Locale = getLocale(other_settings);
277-
278-
const items: MenuProps["items"] =
279-
Object.entries(LOCALIZATIONS)
280-
.filter(([key, _]) => i18n_enabled.includes(key as any))
281-
.map(([key, { name, trans, native, flag }]) => {
282-
const other = key === locale ? name : intl.formatMessage(trans);
283-
return { key, label: `${flag} ${native} (${other})` };
284-
}) ?? [];
285-
286-
items.push({ type: "divider" });
287-
items.push({
288-
key: "help",
289-
label: (
290-
<Space>
291-
<Icon name="translation-outlined" />
292-
{intl.formatMessage({
293-
id: "account.account_page.translation.info.label",
294-
defaultMessage: "Translation Info...",
295-
description: "Label of translation information modal in dropdown",
296-
})}
297-
</Space>
298-
),
299-
onClick: () =>
300-
Modal.info({
301-
width: "min(90vw, 600px)",
302-
title: intl.formatMessage({
303-
id: "account.account_page.translation.info.title",
304-
defaultMessage: "Translation Information",
305-
description: "Title of translation information modal",
306-
}),
307-
content: (
308-
<Paragraph>
309-
{intl.formatMessage({
310-
id: "account.account_page.translation.info.content",
311-
defaultMessage: `
312-
We're excited to start offering our application in multiple languages! Here's what you need to know:
313-
314-
<ul>
315-
<li><b>Work in Progress</b>: Our translation effort is just beginning. Many parts of the application are not yet translated.</li>
316-
<li><b>Gradual Improvement</b>: We're continuously working to expand our language coverage. You'll see more content translated over time.</li>
317-
<li><b>Your Help is Welcome</b>: We value our community's input. If you're fluent in multiple languages and would like to contribute to our translation efforts, we'd love to hear from you!</li>
318-
<li><b>Contact Us</b>: To learn more about contributing to translations or to report any issues, please reach out to our support team.</li>
319-
</ul>
320-
321-
Thank you for your patience and understanding as we work to make our application accessible to a global audience!`,
322-
description: "Content of translation information modal",
323-
})}
324-
</Paragraph>
325-
),
326-
}),
327-
});
328-
329-
const menu: MenuProps = {
330-
items,
331-
style: { maxHeight: "75vh", overflow: "auto" },
332-
onClick: ({ key }) => {
333-
if (key in LOCALIZATIONS) {
334-
redux
335-
.getActions("account")
336-
.set_other_settings(OTHER_SETTINGS_LOCALE_KEY, key);
337-
setLocale(key);
338-
}
339-
},
340-
};
341-
342-
const lang_icon = LOCALIZATIONS[i18n]?.flag;
343-
344-
const title =
345-
i18n in LOCALIZATIONS
346-
? intl.formatMessage(LOCALIZATIONS[i18n].trans)
347-
: i18n;
348-
349-
const cur = `${title} (${LOCALIZATIONS[i18n]?.name ?? i18n})`;
350-
const msg = intl.formatMessage(labels.account_language_tooltip);
351-
const tooltip = (
352-
<>
353-
{cur}
354-
<br />
355-
{msg}
356-
{labels.account_language_tooltip.defaultMessage != msg ? (
357-
<>
358-
<br />({labels.account_language_tooltip.defaultMessage})
359-
</>
360-
) : undefined}
361-
</>
362-
);
363-
364-
return (
365-
<Tooltip title={langOpen ? undefined : tooltip} trigger={["hover"]}>
366-
<Dropdown
367-
menu={menu}
368-
trigger={["click"]}
369-
onOpenChange={(open) => setLangOpen(open)}
370-
>
371-
<Button>
372-
<Space>
373-
{lang_icon}
374-
{isWide ? title : undefined}
375-
<DownOutlined />
376-
</Space>
377-
</Button>
378-
</Dropdown>
379-
</Tooltip>
380-
);
381-
}
382-
383256
function renderExtraContent() {
384257
return (
385258
<Space>
386-
{renderI18N()}
259+
<I18NSelector isWide={isWide} />
387260
<SignOut everywhere={false} highlight={true} narrow={!isWide} />
388261
</Space>
389262
);

0 commit comments

Comments
 (0)