Rebuild Share and Delete Account from the privacy designs.

Share asks the person who holds the pen to confirm their community agreed before a link turns on, and deleting an account lists each owned Rule with PDF and RULE.md export. Case-study Share copies the page link instead of opening the privacy modal, and the sign-in banner stays below the header so Share remains clickable.
This commit is contained in:
adilallo committed 2026-11-09 19:54:09 -07:00
1 parent 5cbda35e32
commit b6795c1f18
28 files changed
+1467 -377

No files matched your search

+73 -1
View File
@@ -16,7 +16,18 @@ import {
logout,
requestEmailChange,
type MyPublishedRule,
type PublishedRuleDetailForClient,
} from "../../../lib/create/api";
import {
downloadStoredRuleAsPdf,
downloadTextFile,
exportFilenameBase,
exportStoredRuleAsMarkdown,
} from "../../../lib/create/ruleExport";
import {
writeLastPublishedRule,
type StoredLastPublishedRule,
} from "../../../lib/create/lastPublishedRule";
import {
CREATE_FLOW_MANAGE_STAKEHOLDERS_QUERY,
CREATE_FLOW_MANAGE_STAKEHOLDERS_VALUE,
@@ -29,7 +40,6 @@ import { clearAnonymousCreateFlowStorage } from "../create/utils/anonymousDraftS
import { clearCoreValueDetailsLocalStorage } from "../create/utils/coreValueDetailsLocalStorage";
import { prepareFreshCreateFlowEntrySync } from "../create/utils/prepareFreshCreateFlowEntry";
import { createFlowStepPath } from "../create/utils/createFlowPaths";
import { writeLastPublishedRule } from "../../../lib/create/lastPublishedRule";
import { useMediaQuery } from "../../hooks/useMediaQuery";
import {
ProfilePageSignedOutView,
@@ -315,6 +325,66 @@ export default function ProfilePageClient() {
void load();
}, [draftDeleteBusy, load]);
const toStoredRule = useCallback(
(rule: PublishedRuleDetailForClient): StoredLastPublishedRule | null => {
if (
rule.document === null ||
typeof rule.document !== "object" ||
Array.isArray(rule.document)
) {
return null;
}
return {
id: rule.id,
title: rule.title,
summary: rule.summary,
document: rule.document as Record<string, unknown>,
};
},
[],
);
const handleExportRulePdf = useCallback(
async (id: string) => {
setActionError(null);
const detail = await fetchPublishedRuleDetail(id);
const stored = detail ? toStoredRule(detail.rule) : null;
if (!stored) {
setActionError(t("actionError"));
return;
}
try {
downloadStoredRuleAsPdf(stored);
} catch {
setActionError(t("actionError"));
}
},
[t, toStoredRule],
);
const handleExportRuleMarkdown = useCallback(
async (id: string) => {
setActionError(null);
const detail = await fetchPublishedRuleDetail(id);
const stored = detail ? toStoredRule(detail.rule) : null;
if (!stored) {
setActionError(t("actionError"));
return;
}
try {
const markdown = exportStoredRuleAsMarkdown(stored);
downloadTextFile(
`${exportFilenameBase(stored)}-community-rule.md`,
markdown,
"text/markdown;charset=utf-8",
);
} catch {
setActionError(t("actionError"));
}
},
[t, toStoredRule],
);
const handleConfirmDeleteAccount = useCallback(async () => {
setActionError(null);
setAccountDeleteBusy(true);
@@ -409,6 +479,8 @@ export default function ProfilePageClient() {
}}
onCloseDeleteAccount={() => setAccountDeleteOpen(false)}
onConfirmDeleteAccount={handleConfirmDeleteAccount}
onExportRulePdf={(id) => void handleExportRulePdf(id)}
onExportRuleMarkdown={(id) => void handleExportRuleMarkdown(id)}
onStartNewCustomRule={handleStartNewCustomRule}
/>
);
@@ -9,6 +9,7 @@ import type { ListItem, ListSize } from "../../../components/layout/List";
import ListEntry from "../../../components/layout/ListEntry";
import Icon from "../../../components/asset/icon";
import Dialog from "../../../components/modals/Dialog";
import DeleteAccount from "../../../components/modals/DeleteAccount";
import Alert from "../../../components/modals/Alert";
import HeaderLockup from "../../../components/type/HeaderLockup";
import { useTranslation } from "../../../contexts/MessagesContext";
@@ -71,6 +72,8 @@ export type ProfilePageViewProps = {
onOpenDeleteAccount: () => void;
onCloseDeleteAccount: () => void;
onConfirmDeleteAccount: () => void;
onExportRulePdf: (id: string) => void;
onExportRuleMarkdown: (id: string) => void;
onDismissProfileSuccess: () => void;
onDismissActionError: () => void;
onDismissRulesError: () => void;
@@ -194,6 +197,8 @@ export function ProfilePageView({
onOpenDeleteAccount,
onCloseDeleteAccount,
onConfirmDeleteAccount,
onExportRulePdf,
onExportRuleMarkdown,
onDismissProfileSuccess,
onDismissActionError,
onDismissRulesError,
@@ -489,39 +494,18 @@ export function ProfilePageView({
}
/>
<Dialog
<DeleteAccount
isOpen={accountDeleteOpen}
onClose={() => {
if (!accountDeleteBusy) onCloseDeleteAccount();
}}
backdropVariant="blurredYellow"
title={t("deleteAccountModalTitle")}
description={t("deleteAccountModalBody")}
footer={
<>
<Button
type="button"
size="medium"
buttonType="outline"
palette="default"
onClick={onCloseDeleteAccount}
disabled={accountDeleteBusy}
>
{t("deleteAccountCancel")}
</Button>
<Button
type="button"
size="medium"
buttonType="outline"
danger
palette="default"
onClick={onConfirmDeleteAccount}
disabled={accountDeleteBusy}
>
{t("deleteAccountConfirm")}
</Button>
</>
}
onConfirm={onConfirmDeleteAccount}
busy={accountDeleteBusy}
rules={rules
.filter((rule) => rule.role === "owner")
.map((rule) => ({ id: rule.id, title: rule.title }))}
onExportPdf={onExportRulePdf}
onExportMarkdown={onExportRuleMarkdown}
/>
<Dialog