mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 22:02:16 +00:00
fix(data-wipe): say what undoing a wipe does not bring back
A restore of the copy a data wipe took replaces the record with that copy, so anything added after the wipe is gone, and the wipe ended integration connections, sharing in both directions, Guardian roles and share links, none of which are in a copy. Neither the person's confirmation nor the admin's restore dialog said so. Both do now, in every locale.
This commit is contained in:
1 parent
2b79c01952
commit
69c5c65376
12 files changed
+107
-29
No files matched your search
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Undoing a data wipe with the copy it took brings the record back as it was
|
||||
* at the wipe, and nothing else: whatever arrived since is replaced, and the
|
||||
* connections, sharing, Guardian access and share links the wipe ended stay
|
||||
* ended. Both dialogs that lead there say so: the person's own confirmation
|
||||
* before the wipe, and the admin's before the restore of such a copy.
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { restoreDescription } from "../restore-dialog";
|
||||
import { wipeConfirmBody } from "@/components/settings/advanced-section";
|
||||
|
||||
const t = (key: string) => key;
|
||||
|
||||
describe("what an undo of a data wipe does not bring back", () => {
|
||||
it("is said before an admin restores a copy a data wipe took, and only then", () => {
|
||||
expect(
|
||||
restoreDescription(
|
||||
{ username: "u", type: "PRE_WIPE_1761300000000" },
|
||||
t,
|
||||
"when",
|
||||
),
|
||||
).toContain("admin.section.backups.restorePreWipeLimits");
|
||||
expect(
|
||||
restoreDescription({ username: "u", type: "WEEKLY_AUTO" }, t, "when"),
|
||||
).not.toContain("restorePreWipeLimits");
|
||||
});
|
||||
|
||||
it("is said before the person deletes their data, when a copy is kept", () => {
|
||||
expect(wipeConfirmBody(14, t)).toContain(
|
||||
"settings.dangerZoneRestoreLimits",
|
||||
);
|
||||
expect(wipeConfirmBody(0, t)).not.toContain("dangerZoneRestoreLimits");
|
||||
});
|
||||
});
|
||||
@@ -20,6 +20,7 @@ import { Label } from "@/components/ui/label";
|
||||
import { ApiError, apiGet } from "@/lib/api/api-fetch";
|
||||
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import { isPreWipeBackupType } from "@/lib/account-deletion/pre-wipe-type";
|
||||
import type { BackupRow } from "@/types/backups";
|
||||
|
||||
/**
|
||||
@@ -221,6 +222,24 @@ export function RestorePreview({
|
||||
* Mirrors the wipe dialog's pattern but adds the typed gate because the
|
||||
* blast radius is bigger (re-creates rows, not just deletes).
|
||||
*/
|
||||
/**
|
||||
* What the restore does, and for a copy a data wipe took, what undoing the
|
||||
* wipe with it does not bring back.
|
||||
*/
|
||||
export function restoreDescription(
|
||||
row: Pick<BackupRow, "username" | "type">,
|
||||
t: ReturnType<typeof useTranslations>["t"],
|
||||
when: string,
|
||||
): string {
|
||||
const replaces = t("admin.section.backups.restoreDescription", {
|
||||
username: row.username,
|
||||
when,
|
||||
});
|
||||
return isPreWipeBackupType(row.type)
|
||||
? `${replaces} ${t("admin.section.backups.restorePreWipeLimits")}`
|
||||
: replaces;
|
||||
}
|
||||
|
||||
export function RestoreRowDialog({
|
||||
row,
|
||||
pending,
|
||||
@@ -277,10 +296,7 @@ export function RestoreRowDialog({
|
||||
{t("admin.section.backups.restoreTitle")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("admin.section.backups.restoreDescription", {
|
||||
username: row.username,
|
||||
when: fmt.dateTime(row.createdAt),
|
||||
})}
|
||||
{restoreDescription(row, t, fmt.dateTime(row.createdAt))}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
{/* What the file contains, before the typed gate. */}
|
||||
|
||||
Reference in new issue
Block a user