Skip to content

Commit 0855340

Browse files
committed
change timetravel cutoff to be in days, not revisions
1 parent 1155f4b commit 0855340

File tree

3 files changed

+63
-86
lines changed

3 files changed

+63
-86
lines changed

src/packages/frontend/frame-editors/time-travel-editor/time-travel.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Button, Checkbox, Space, Tooltip } from "antd";
99
import { Map } from "immutable";
1010
import { debounce } from "lodash";
1111
import { useEffect, useMemo, useState } from "react";
12-
12+
import { ALWAYS_ALLOWED_TIMETRAVEL } from "@cocalc/util/db-schema/site-defaults";
1313
import { AccountState } from "@cocalc/frontend/account/types";
1414
import {
1515
redux,
@@ -547,18 +547,13 @@ export function TimeTravel(props: Props) {
547547

548548
let body;
549549
if (
550-
unlicensedLimit &&
551-
!gitMode &&
552-
licenses != null &&
553-
version != null &&
554-
licenses.size == 0 &&
555-
versions.size - unlicensedLimit > version
550+
beyondTheLimit({ unlicensedLimit, gitMode, licenses, version, versions })
556551
) {
557552
// need license to view this
558553
body = (
559554
<RequireLicense
560555
project_id={project_id}
561-
message={`A license is required to view more than ${unlicensedLimit} versions of this file.`}
556+
message={`Upgrade to view more than the last ${unlicensedLimit} days (or ${ALWAYS_ALLOWED_TIMETRAVEL} versions) of TimeTravel history.`}
562557
/>
563558
);
564559
} else if (doc != null && docpath != null && docext != null && !changesMode) {
@@ -602,3 +597,27 @@ const saveState = debounce((actions, obj) => {
602597
a.set_frame_tree(obj);
603598
}
604599
}, 2000);
600+
601+
function beyondTheLimit({
602+
unlicensedLimit,
603+
gitMode,
604+
licenses,
605+
version,
606+
versions,
607+
}) {
608+
console.log({ unlicensedLimit, gitMode, licenses, version, versions });
609+
window.x = { unlicensedLimit, gitMode, licenses, version, versions };
610+
if (gitMode || (unlicensedLimit ?? 0) <= 0 || licenses.size > 0) {
611+
return false;
612+
}
613+
const cutoff = Date.now() - unlicensedLimit * 24 * 60 * 60 * 1000;
614+
if (version >= cutoff) {
615+
return false;
616+
}
617+
// beyond the limit unless one of the last few
618+
const n = versions.indexOf(version);
619+
if (n >= versions.size - ALWAYS_ALLOWED_TIMETRAVEL) {
620+
return false;
621+
}
622+
return true;
623+
}

src/packages/frontend/project/call-to-support.tsx

Lines changed: 33 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -7,81 +7,6 @@ import { appBasePath } from "@cocalc/frontend/customize/app-base-path";
77
const { Paragraph, Text } = Typography;
88
export const BUY_A_LICENSE_URL = join(appBasePath, "/store/site-license");
99

10-
// I'm just putting "CoCalc" since this is only for cocalc.com usage, and the
11-
// messages below literally only apply to cocalc.
12-
13-
const VERSIONS = {
14-
hsy: (
15-
<>
16-
<Paragraph strong>
17-
This is a call to support CoCalc by{" "}
18-
<A href={BUY_A_LICENSE_URL}>purchasing a license</A>.
19-
</Paragraph>
20-
<Paragraph>
21-
Behind the scenes, <A href={"/about/team"}>people are working hard</A>{" "}
22-
to keep the service running and improve it constantly. Your files and
23-
computations <A href={"/info/status"}>run in our cluster</A>, which
24-
costs money as well.
25-
</Paragraph>
26-
<Paragraph>
27-
CoCalc receives no funding from large organizations or charitable
28-
foundations. The site depends entirely{" "}
29-
<Text strong>on your financial support</Text> to continue operating.
30-
Without your financial support this service will not survive long-term!
31-
</Paragraph>
32-
<Paragraph>
33-
<A
34-
href={
35-
"/support/new?hideExtra=true&type=purchase&subject=Support+CoCalc&title=Support+CoCalc"
36-
}
37-
>
38-
Contact us
39-
</A>{" "}
40-
if you can give support in other ways or have any questions or comments.
41-
</Paragraph>
42-
</>
43-
),
44-
blaec: (
45-
<>
46-
<Paragraph strong>
47-
Please{" "}
48-
<b>
49-
<A href={BUY_A_LICENSE_URL}>purchase a CoCalc license</A>
50-
</b>
51-
!
52-
</Paragraph>
53-
<Paragraph>
54-
Not only will you{" "}
55-
<u>
56-
<b>have a better experience</b>
57-
</u>
58-
, but behind the scenes, a{" "}
59-
<A href={"/about/team"}>handful of individuals</A> are continuously
60-
working to make Collaborative Calculation accessible for academics and
61-
researchers everywhere. Behind every computation is a{" "}
62-
<A href={"/info/status"}>cluster</A> that takes resources to maintain,
63-
and believe it or not, our company receives no funding from large
64-
organizations, charitable foundations or institutional investors.
65-
</Paragraph>
66-
<Paragraph>
67-
The site depends entirely <Text strong>on your financial support</Text>{" "}
68-
to continue operating.
69-
</Paragraph>
70-
<Paragraph>
71-
Unable to purchase a license?{" "}
72-
<A
73-
href={
74-
"/support/new?hideExtra=true&type=purchase&subject=Support+CoCalc&title=Support+CoCalc"
75-
}
76-
>
77-
Contact us
78-
</A>{" "}
79-
if you can give support in other ways or have any questions or comments.
80-
</Paragraph>
81-
</>
82-
),
83-
};
84-
8510
export function CallToSupport({ onClose }: { onClose? }) {
8611
return (
8712
<Alert
@@ -90,7 +15,39 @@ export function CallToSupport({ onClose }: { onClose? }) {
9015
banner
9116
type="warning"
9217
showIcon={false}
93-
message={VERSIONS.blaec}
18+
message={
19+
<>
20+
<Paragraph strong>
21+
Please{" "}
22+
<b>
23+
<A href={BUY_A_LICENSE_URL}>purchase a CoCalc license</A>
24+
</b>
25+
!
26+
</Paragraph>
27+
<Paragraph>
28+
Not only will you{" "}
29+
<u>
30+
<b>have a better experience</b>
31+
</u>
32+
, but behind the scenes, a{" "}
33+
<A href={"/about/team"}>handful of individuals</A> are continuously
34+
working to make Collaborative Calculation accessible for academics
35+
and researchers everywhere. Behind every computation is a{" "}
36+
<A href={"/info/status"}>cluster</A> that takes resources to
37+
maintain.
38+
</Paragraph>
39+
<Paragraph>
40+
<A
41+
href={
42+
"/support/new?hideExtra=true&type=purchase&subject=Support+CoCalc&title=Support+CoCalc"
43+
}
44+
>
45+
Contact us
46+
</A>{" "}
47+
if you have any questions or comments.
48+
</Paragraph>
49+
</>
50+
}
9451
/>
9552
);
9653
}

src/packages/util/db-schema/site-defaults.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getDefaultLLM,
1717
isValidModel,
1818
} from "./llm-utils";
19+
export const ALWAYS_ALLOWED_TIMETRAVEL = 10;
1920

2021
export type ConfigValid = Readonly<string[]> | ((val: string) => boolean);
2122

@@ -657,12 +658,12 @@ export const site_settings_conf: SiteSettings = {
657658
},
658659
unlicensed_project_timetravel_limit: {
659660
name: "Require License to View Unlimited TimeTravel History",
660-
desc: "If this number is positive, then projects without a valid license can view at most this many past versions of a file via TimeTravel. Set this to 200 to allow up to 200 past versions.",
661+
desc: `If this number is positive, then in projects without some upgrade can only view this many days of TimeTravel history. Set this to 7 to allow up to one week of history. NOTE: Users are always allowed to view at least ${ALWAYS_ALLOWED_TIMETRAVEL} revisions, even if the revisions are older than this, in order to recover from possible data loss.`,
661662
default: "0",
662663
to_val: to_int,
663664
valid: only_nonneg_int,
664665
show: only_cocalc_com,
665-
to_display: (val) => `${val} versions`,
666+
to_display: (val) => `${val} days`,
666667
tags: ["Commercialization"],
667668
},
668669
datastore: {

0 commit comments

Comments
 (0)