Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/reports/admin-submissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ function SubmissionDialog({ report, last, onClose, onEdit }: { /** The report op
</div>
{/* Who gets its PDF, under the licence it was signed under: a reviewer may change it as its author may. Not
for a withdrawn report, whose file nobody gets: "Anyone can read and download the PDF" was untrue of it. */}
{s.withdrawn ? null : <FileAccessChange licence={s.licence} saved={s.fileAccess} live={s.activatedAt !== undefined} disabled={busy} onSave={(fileAccess) => setFileAccess({ key: s.key, fileAccess }).catch(failed)} />}
{s.withdrawn ? null : <FileAccessChange licence={s.licence} registers={s.registration} saved={s.fileAccess} live={s.activatedAt !== undefined} disabled={busy} onSave={(fileAccess) => setFileAccess({ key: s.key, fileAccess }).catch(failed)} />}
{/* What the checks said comes straight after the facts: it is what a reviewer decides on. With changes
open, their checks above are the ones to read, and the report's own would say most of it twice. */}
{s.results?.length && !changes ? (
Expand Down
20 changes: 13 additions & 7 deletions components/reports/file-access-choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Who gets a report's PDF, under the licence it is published under (#1467): the choices follow the licence. Under one
// that lets anyone share the report: anyone, nobody but the people who can change it, or anyone from a date. Under the
// author's own that doesn't: Openscholar's readers, or nobody but those people. Zenodo keeps the file private whenever
// it isn't anyone's.
// it isn't anyone's. What a choice says names Zenodo and Crossref only for a report they are sent (`Registers`).

import { useId, useState } from "react";
import { useFormatter, useTranslations } from "next-intl";
Expand All @@ -16,6 +16,9 @@ import { fileAccessModes, fileAccessOf, isCalendarDay, MORE_REPORT_CHOICES, utcD
import { cn } from "@/lib/utils";
import { FieldMessage, useStepForm } from "@/components/reports/form";

/** The registrars a report is sent to, of those the choices name. */
type Registers = { crossref: boolean; zenodo: boolean };

/** A year from today, where an embargo starts when it is picked: changed in the date box under it. */
const aYearOn = () => {
const date = new Date();
Expand All @@ -39,7 +42,7 @@ const tomorrowDay = () => utcDay(new Date(Date.now() + 24 * 60 * 60 * 1000));
export const embargoProblem = (access: FileAccess, from: FileAccess | null = null): "past" | "notSooner" | null =>
access.mode !== "embargo" ? null : !isCalendarDay(access.until) || access.until < tomorrowDay() ? "past" : from?.mode === "embargo" && access.until >= from.until ? "notSooner" : null;

export function FileAccessChoice({ licence, value, onChange, disabled = false, from = null, dateId }: { licence: Licence; /** The choice made, which the licence may not allow: then it gets the licence's own. */ value: FileAccess | null; onChange: (access: FileAccess) => void; disabled?: boolean; /** A live report's saved access, which it may only open further from: every other choice is off. */ from?: FileAccess | null; /** The embargo day's box, for the step's Next to take the person to. */ dateId?: string }) {
export function FileAccessChoice({ licence, registers, value, onChange, disabled = false, from = null, dateId }: { licence: Licence; registers: Registers; /** The choice made, which the licence may not allow: then it gets the licence's own. */ value: FileAccess | null; onChange: (access: FileAccess) => void; disabled?: boolean; /** A live report's saved access, which it may only open further from: every other choice is off. */ from?: FileAccess | null; /** The embargo day's box, for the step's Next to take the person to. */ dateId?: string }) {
const t = useTranslations("publishReports.flow.fileAccess");
const format = useFormatter();
const id = useId();
Expand All @@ -50,11 +53,14 @@ export function FileAccessChoice({ licence, value, onChange, disabled = false, f
const [tomorrow] = useState(tomorrowDay);
const date = dateId ?? `${id}-date`;
const wrong = embargoProblem(access, from);
// ponytail: only the choices offered today leave Zenodo out where a report has none (Public, From a date). Private and
// Openscholar readers, held back (MORE_REPORT_CHOICES), still name it: give them the same forms when they come back.
const zenodo = registers.zenodo ? "yes" : "no";
const meaning =
access.mode === "embargo" && wrong
? t("embargoBody")
: access.mode === "embargo"
? t("meaning.embargo", { date: format.dateTime(new Date(`${access.until}T00:00:00Z`), { dateStyle: "long", timeZone: "UTC" }) })
? t("meaning.embargo", { zenodo, date: format.dateTime(new Date(`${access.until}T00:00:00Z`), { dateStyle: "long", timeZone: "UTC" }) })
: t(access.mode === "private" && !modes.includes("open") ? "meaning.privateClosed" : `meaning.${access.mode}`);
return (
<div className="space-y-3">
Expand All @@ -77,7 +83,7 @@ export function FileAccessChoice({ licence, value, onChange, disabled = false, f
<RadioGroupItem id={`${id}-${mode}`} value={mode} disabled={off} className="mt-0.5" />
<span className="min-w-0 flex-1">
<span className="block text-sm font-medium">{t(mode)}</span>
<span className="mt-0.5 block text-sm text-muted-foreground">{t(`${mode}Body`)}</span>
<span className="mt-0.5 block text-sm text-muted-foreground">{t(`${mode}Body`, { zenodo })}</span>
</span>
</label>
);
Expand Down Expand Up @@ -125,7 +131,7 @@ export function FileAccessChoice({ licence, value, onChange, disabled = false, f
* Who gets a report's file, changed after signing: picked here, then confirmed, so a change is meant and the
* registrars aren't sent one for every click. Live, the file only ever opens further, which the prompt says.
*/
export function FileAccessChange({ licence, saved, live, onSave, disabled = false }: { licence: Licence; saved: FileAccess; /** Readers may have had the file: it only opens further. */ live: boolean; onSave: (access: FileAccess) => Promise<unknown>; disabled?: boolean }) {
export function FileAccessChange({ licence, registers, saved, live, onSave, disabled = false }: { licence: Licence; registers: Registers; saved: FileAccess; /** Readers may have had the file: it only opens further. */ live: boolean; onSave: (access: FileAccess) => Promise<unknown>; disabled?: boolean }) {
const t = useTranslations("publishReports.flow.fileAccess");
const [picked, setPicked] = useState<FileAccess | null>(null);
const [asking, setAsking] = useState(false);
Expand All @@ -145,7 +151,7 @@ export function FileAccessChange({ licence, saved, live, onSave, disabled = fals
};
return (
<div className="space-y-3">
<FileAccessChoice licence={licence} value={picked ?? saved} onChange={setPicked} disabled={disabled || saving} from={live ? saved : null} dateId={date} />
<FileAccessChoice licence={licence} registers={registers} value={picked ?? saved} onChange={setPicked} disabled={disabled || saving} from={live ? saved : null} dateId={date} />
{/* Live, it only opens further, said while it can: one already as open as its licence allows is told why it stops there. */}
{live && (saved.mode === "private" || saved.mode === "embargo") ? <p className="text-xs text-pretty text-muted-foreground">{t("oneWay")}</p> : null}
{live && saved.mode === "readers" ? <p className="text-xs text-pretty text-muted-foreground">{t("readersMost")}</p> : null}
Expand All @@ -166,7 +172,7 @@ export function FileAccessChange({ licence, saved, live, onSave, disabled = fals
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{t("confirmTitle")}</AlertDialogTitle>
<AlertDialogDescription>{t(live ? "confirmLive" : "confirmBefore")}</AlertDialogDescription>
<AlertDialogDescription>{live ? t("confirmLive", { sent: registers.crossref && registers.zenodo ? "both" : registers.zenodo ? "zenodo" : registers.crossref ? "crossref" : "none" }) : t("confirmBefore")}</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={saving}>{t("cancel")}</AlertDialogCancel>
Expand Down
3 changes: 2 additions & 1 deletion components/reports/publish-flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ function AgreementStep({ basics: ours, starts: here, workspaceId: pageWorkspace,
</section>
) : null}
<section className="mb-7">
<FileAccessChoice licence={named} value={access} onChange={setAccess} disabled={busy || !!signed} dateId={fields.until} />
<FileAccessChoice licence={named} registers={route} value={access} onChange={setAccess} disabled={busy || !!signed} dateId={fields.until} />
</section>
{/* Where the permanent copy goes, said before the agreement that promises one: a copy kept under its Crossref DOI,
so only while it gets one. */}
Expand Down Expand Up @@ -2993,6 +2993,7 @@ function LiveFileAccess({ report }: { report: Report }) {
return (
<FileAccessChange
licence={report.licence}
registers={report.registration}
saved={report.fileAccess}
live
disabled={!workspaceId}
Expand Down
12 changes: 10 additions & 2 deletions convex/migrations/seriesWords.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ describe("checks saved with advice a shipped check no longer gives", () => {
await world.t.run(async (ctx) => {
const row = (await ctx.db.query("reportSettings").first())!;
const checks = row.checks.map((check) => (check.fix === now ? { ...check, fix: old } : check)).map((check) => (check.question === asksNow ? { ...check, question: asked } : check));
// The agreement as it read before its fee had a blank.
await ctx.db.patch("reportSettings", row._id, { checks, agreement: { ...row.agreement, text: row.agreement.text.replace("costs [fee].", "costs the publication fee shown on openscholar.ai when the Work is made live.") } });
// The agreement as it read before its fee had a blank, and while only an author could sign it.
const text = row.agreement.text
.replace("costs [fee].", "costs the publication fee shown on openscholar.ai when the Work is made live.")
.replace(/^1\. The author or authors.*$/m, "1. [Name of author(s) or organisation] (the “Author”). Where there are several authors, one of them signs on behalf of all and confirms that they have the others’ agreement; and")
.replace("a [DOI or DOCiD] is permanent", "a DOI is permanent");
await ctx.db.patch("reportSettings", row._id, { checks, agreement: { ...row.agreement, text } });
await ctx.db.patch("reportCheckVersions", (await ctx.db.query("reportCheckVersions").first())!._id, { checks });
});
// The lab's own checks start as the series' were then.
Expand All @@ -35,6 +39,10 @@ describe("checks saved with advice a shipped check no longer gives", () => {
// The agreement's fee is a blank again, in a new version.
const agreement = (await world.t.run((ctx) => ctx.db.query("reportSettings").first()))!.agreement;
expect(agreement.text).toContain("costs [fee].");
// Its signer signs for the authors, and its clauses name the identifier the report gets.
expect(agreement.text).toContain("for whom [name of the person signing] signs.");
expect(agreement.text).not.toContain("[Name of author(s) or organisation]");
expect(agreement.text).toContain("a [DOI or DOCiD] is permanent");
expect(agreement.version).toBeGreaterThan(1);
// A question a shipped check no longer asks is today's too.
const questions = (await world.t.run((ctx) => ctx.db.query("reportSettings").first()))!.checks.map((check) => check.question);
Expand Down
14 changes: 13 additions & 1 deletion convex/migrations/seriesWords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ const blanked = (text: string) =>
// The fee's section is found by its blank, and left out of an agreement signed for nothing.
.replace("costs the publication fee shown on openscholar.ai when the Work is made live.", "costs [fee].")
// The line may sit on a last page Openscholar adds, which the upload step offers: the clause said only the cover.
.replace("[byline] on its cover or first page. Openscholar may add a cover sheet with this information.", "[byline], on its cover or first page or on a last page that Openscholar adds.");
.replace("[byline] on its cover or first page. Openscholar may add a cover sheet with this information.", "[byline], on its cover or first page or on a last page that Openscholar adds.")
// Someone the authors asked may sign for them: the first party is the authors, and the signer is named beside them.
.replace(
"1. [Name of author(s) or organisation] (the “Author”). Where there are several authors, one of them signs on behalf of all and confirms that they have the others’ agreement; and",
"1. The author or authors of the Work (the “Author”), for whom [name of the person signing] signs. The person signing is an author, or has the authors’ authority to sign, and confirms that every author agrees; and",
)
// A report that gets only a DOCiD is promised no DOI: these three clauses name the identifier it gets.
.replace("this agreement ends and no DOI is registered.", "this agreement ends and no [DOI or DOCiD] is registered.")
.replace("The Author understands that a DOI is permanent and cannot be deleted.", "The Author understands that a [DOI or DOCiD] is permanent and cannot be deleted.")
.replace("the DOI will continue to resolve to a page explaining that the Work has been withdrawn.", "the [DOI or DOCiD] will continue to resolve to a page explaining that the Work has been withdrawn.");

/**
* What a deployment saved while Openscholar Reports was the one series and every report had a price, said so a
Expand All @@ -27,6 +36,9 @@ const blanked = (text: string) =>
* npx convex run migrations/seriesWords:run
* - The agreement names its series and publisher through `[series]` and `[publisher]`, its fee through `[fee]`, and
* says the byline may sit on a last page Openscholar adds, where the saved text says otherwise in fixed words.
* - Its first party is the work's authors, with the person who signs for them named through
* `[name of the person signing]`, and its clauses on declining, permanence and withdrawal name the identifier the
* report gets through `[DOI or DOCiD]`.
* - A check's advice that names Openscholar Reports becomes the advice the check ships with now
* (lib/reports/settings.ts `OLD_FIXES`).
* - A check's question a shipped check no longer asks becomes the one it asks now (`OLD_QUESTIONS`): the rights check
Expand Down
8 changes: 4 additions & 4 deletions lib/reports/agreement-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const DEFAULT_AGREEMENT = `# Publishing agreement: single work ([series])

This agreement is made on [date] between:

1. [Name of author(s) or organisation] (the “Author”). Where there are several authors, one of them signs on behalf of all and confirms that they have the others’ agreement; and
1. The author or authors of the Work (the “Author”), for whom [name of the person signing] signs. The person signing is an author, or has the authors’ authority to sign, and confirms that every author agrees; and
2. Openscholar, a service run by eKitabu, LLC, which incubates it in Kenya, of Rainbow Tower, 5th floor, Nairobi, Kenya (“Openscholar”).

## 1. The Work
Expand All @@ -20,7 +20,7 @@ The Work is: [title], by [authors], [number of pages], [date of completion] (the

2.2. The Work will carry the byline [byline], on its cover or first page or on a last page that Openscholar adds.

2.3. Openscholar may decline to publish the Work, for example if it is outside Openscholar’s scope, not original, or raises legal or ethical concerns. If it declines, this agreement ends and no DOI is registered.
2.3. Openscholar may decline to publish the Work, for example if it is outside Openscholar’s scope, not original, or raises legal or ethical concerns. If it declines, this agreement ends and no [DOI or DOCiD] is registered.

## 3. Copyright and licence

Expand All @@ -47,11 +47,11 @@ The Author will provide the title, authors (with ORCID iDs where available) and

## 6. Permanence and withdrawal

6.1. The Author understands that a DOI is permanent and cannot be deleted.
6.1. The Author understands that a [DOI or DOCiD] is permanent and cannot be deleted.

6.2. Openscholar will keep the landing page online.

6.3. If the Work has to be withdrawn (for example for legal reasons), the DOI will continue to resolve to a page explaining that the Work has been withdrawn. Corrections are published as a new version or a correction notice.
6.3. If the Work has to be withdrawn (for example for legal reasons), the [DOI or DOCiD] will continue to resolve to a page explaining that the Work has been withdrawn. Corrections are published as a new version or a correction notice.

## 7. Fee

Expand Down
25 changes: 25 additions & 0 deletions lib/reports/agreement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ describe("the services an agreement names", () => {
});
});

// Someone the authors asked may sign for them, and a report is promised only the identifier it gets.
describe("who signs the agreement we ship, and the identifier it promises", () => {
const facts = { name: "A Name", date: new Date("2026-11-26"), byline: "", licence: "CC BY 4.0" as const, ownArchive: false, series: "Openscholar Reports", publisher: "Openscholar" };

it("names the signer as signing for the work's authors, and leaves no blank open", () => {
const text = fillAgreement(DEFAULT_AGREEMENT, { ...facts, services: ["crossref", "zenodo"] });
expect(text).toContain("The author or authors of the Work (the “Author”), for whom A Name signs.");
expect(text).toContain("no DOI is registered");
expect(text).not.toContain("to be confirmed");
expect(text).not.toContain("DOCiD");
});

it("speaks of a DOCiD where the report gets no DOI", () => {
const text = fillAgreement(DEFAULT_AGREEMENT, { ...facts, services: ["docid"] });
expect(text).toContain("no DOCiD is registered");
expect(text).toContain("a DOCiD is permanent and cannot be deleted");
expect(text).toContain("the DOCiD will continue to resolve");
expect(fillAgreement(DEFAULT_AGREEMENT, { ...facts, services: ["crossref", "zenodo", "docid"] })).toContain("a DOI is permanent");
});

it("still names the signer of a version signed before, as its Author", () => {
expect(fillAgreement("1. [Name of author(s) or organisation] (the “Author”).", { ...facts, services: [] })).toBe("1. A Name (the “Author”).");
});
});

// What is signed names who publishes the work, and binds its author only to clauses that apply to it.
describe("the series and the byline an agreement names", () => {
const text = "# Agreement ([series])\n\n2.1. Openscholar will publish the Work in the series [series], published by [publisher], and keep a page for it.\n\n2.2. The Work will carry the byline [byline] on its cover.\n\n2.3. Openscholar may correct its details.\n\n3.1. The Author keeps the copyright.";
Expand Down
Loading
Loading