diff --git a/.env.example b/.env.example index a1ed6ab..60f8c28 100644 --- a/.env.example +++ b/.env.example @@ -50,8 +50,14 @@ NEXT_PUBLIC_ENABLE_BACKEND_SYNC= # SITE_INDEXING=false # Named admins who may open a private Rule. Comma-separated emails. Every such read is logged. +# The same list can open /rule-counts (finished Rules by group type and place). # RULE_ADMIN_EMAILS=ops@example.org +# Optional Umami (self-hosted beside the app). Unset: no tracker script. +# Cookie-free / no-cookies is an Umami server setting. +# NEXT_PUBLIC_UMAMI_SRC=https://analytics.example.com/script.js +# NEXT_PUBLIC_UMAMI_WEBSITE_ID= + # Writable directory for `POST /api/uploads` (community photo + custom-method attachments). # In production (e.g. Cloudron localstorage mount), set to the mounted path. Local dev example: # UPLOAD_ROOT="/absolute/path/to/community-rule/var/uploads" diff --git a/CloudronManifest.json b/CloudronManifest.json index 9a855d1..62d305c 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -4,7 +4,7 @@ "title": "Community Rule", "author": "MEDLab", "description": "Community governance and rule-building app", - "version": "0.1.14", + "version": "0.1.15", "httpPort": 3000, "healthCheckPath": "/api/health", "memoryLimit": 805306368, @@ -17,6 +17,10 @@ "prune-expired": { "schedule": "20 7 * * *", "command": "gosu node:node node /app/prune-expired.bundle.cjs" + }, + "follow-up-mail": { + "schedule": "15 * * * *", + "command": "gosu node:node node /app/follow-up-mail.bundle.cjs" } } }, diff --git a/Dockerfile b/Dockerfile index c32e82f..86bd34e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,10 @@ RUN ./node_modules/.bin/esbuild scripts/prune-sessions.ts \ --bundle --platform=node --format=cjs \ --outfile=prune-expired.bundle.cjs \ --external:@prisma/client +RUN ./node_modules/.bin/esbuild scripts/send-rule-follow-up.ts \ + --bundle --platform=node --format=cjs \ + --outfile=follow-up-mail.bundle.cjs \ + --external:@prisma/client FROM base AS runner # openssl: Prisma engines. gosu: privilege drop in start.sh after chown. @@ -53,6 +57,7 @@ COPY --from=builder --chown=node:node /app/.next/standalone ./ COPY --from=builder --chown=node:node /app/.next/static ./.next/static COPY --from=builder --chown=node:node /app/prisma ./prisma COPY --from=builder --chown=node:node /app/prune-expired.bundle.cjs ./prune-expired.bundle.cjs +COPY --from=builder --chown=node:node /app/follow-up-mail.bundle.cjs ./follow-up-mail.bundle.cjs # Facet/template seed JSON — NOT under /app/data (localstorage mount overlays that). COPY --from=builder --chown=node:node /app/data ./seed-data ENV SEED_DATA_DIR=/app/seed-data diff --git a/app/(admin)/rule-counts/page.tsx b/app/(admin)/rule-counts/page.tsx new file mode 100644 index 0000000..8a1bcdc --- /dev/null +++ b/app/(admin)/rule-counts/page.tsx @@ -0,0 +1,114 @@ +import type { Metadata } from "next"; +import Link from "next/link"; +import { notFound } from "next/navigation"; +import messages from "../../../messages/en/index"; +import communityStructure from "../../../messages/en/create/community/communityStructure.json"; +import { routeMetadata } from "../../../lib/siteMetadata"; +import { getRuleAdminEmails, isDatabaseConfigured } from "../../../lib/server/env"; +import { prisma } from "../../../lib/server/db"; +import { isRuleAdminEmail } from "../../../lib/server/ruleAdmins"; +import { aggregateRuleLaunchCounts } from "../../../lib/server/ruleLaunchCounts"; +import { getSessionUser } from "../../../lib/server/session"; + +export const metadata: Metadata = routeMetadata("/rule-counts", { + title: messages.metadata.ruleCounts.title, + robots: { index: false, follow: false }, +}); + +const ORG_LABELS = Object.fromEntries( + communityStructure.organizationTypes.map((row) => [row.id, row.label]), +); + +function typeLabel(orgType: string | null, folded: boolean, copy: typeof messages.pages.ruleCounts): string { + if (folded) return copy.folded; + if (!orgType) return copy.notGiven; + return ORG_LABELS[orgType] ?? orgType; +} + +function placeLabel(place: string | null, folded: boolean, copy: typeof messages.pages.ruleCounts): string { + if (folded) return copy.folded; + if (!place) return copy.notGiven; + return place; +} + +export default async function RuleCountsPage() { + if (getRuleAdminEmails().length === 0) notFound(); + + const copy = messages.pages.ruleCounts; + const user = await getSessionUser(); + if (!user) { + return ( +
+

+ {copy.title} +

+

{copy.signIn}

+ + {copy.signInButton} + +
+ ); + } + if (!isRuleAdminEmail(user.email)) { + return ( +
+

+ {copy.title} +

+

{copy.forbidden}

+
+ ); + } + + const rows = isDatabaseConfigured() + ? await prisma.publishedRule.findMany({ + select: { orgType: true, communityLocation: true }, + }) + : []; + const counts = aggregateRuleLaunchCounts( + rows.map((row) => ({ + orgType: row.orgType, + place: row.communityLocation, + })), + ); + + return ( +
+

+ {copy.title} +

+

{copy.intro}

+

+ {copy.finished}: {counts.finished} +

+ {counts.cells.length === 0 ? ( +

{copy.empty}

+ ) : ( + + + + + + + + + + {counts.cells.map((cell) => ( + + + + + + ))} + +
{copy.columns.type}{copy.columns.place}{copy.columns.count}
+ {typeLabel(cell.orgType, cell.folded, copy)} + + {placeLabel(cell.place, cell.folded, copy)} + {cell.count}
+ )} +
+ ); +} diff --git a/app/(app)/create/hooks/useCompletedRuleShareExport.ts b/app/(app)/create/hooks/useCompletedRuleShareExport.ts index deee50c..b1a4fb5 100644 --- a/app/(app)/create/hooks/useCompletedRuleShareExport.ts +++ b/app/(app)/create/hooks/useCompletedRuleShareExport.ts @@ -15,11 +15,10 @@ import { } from "../../../../lib/create/shareChannels"; import { buildPublicRuleUrl, + downloadStoredRuleAsMarkdown, downloadStoredRuleAsPdf, - downloadTextFile, - exportFilenameBase, - exportStoredRuleAsCsv, - exportStoredRuleAsMarkdown, + printStoredRule, + type RuleExportFormat, } from "../../../../lib/create/ruleExport"; export type CompletedFlowActionBanner = { @@ -101,7 +100,7 @@ export function useCompletedRuleShareExport({ sharePublishedRuleViaSignal: () => Promise; sharePublishedRuleViaSlack: () => Promise; sharePublishedRuleViaDiscord: () => Promise; - onSelectExportFormat: (_format: "pdf" | "csv" | "markdown") => void; + onSelectExportFormat: (_format: RuleExportFormat) => void; } { const t = useTranslation("create.reviewAndComplete.completed"); @@ -318,7 +317,7 @@ export function useCompletedRuleShareExport({ ]); const onSelectExportFormat = useCallback( - (format: "pdf" | "csv" | "markdown") => { + (format: RuleExportFormat) => { if (typeof window === "undefined") return; const rule = readLastPublishedRule(); if (!rule) { @@ -331,34 +330,29 @@ export function useCompletedRuleShareExport({ return; } - const base = exportFilenameBase(rule); + const origin = window.location.origin; try { if (format === "pdf") { - downloadStoredRuleAsPdf(rule); - } else if (format === "csv") { - const csv = exportStoredRuleAsCsv(rule); - downloadTextFile( - `${base}-community-rule.csv`, - csv, - "text/csv;charset=utf-8", - ); + downloadStoredRuleAsPdf(rule, origin); + } else if (format === "print") { + const opened = printStoredRule(rule, origin); + if (!opened) { + setActionBanner({ + key: "completedPrintBlocked", + status: "warning", + title: t("printBlockedTitle"), + description: t("printBlockedDescription"), + }); + } } else { - const md = exportStoredRuleAsMarkdown(rule); - downloadTextFile( - `${base}-community-rule.md`, - md, - "text/markdown;charset=utf-8", - ); + downloadStoredRuleAsMarkdown(rule, origin); } - } catch (e) { - const msg = e instanceof Error && e.message === "exportEmptyDocument"; + } catch { setActionBanner({ key: "completedExportFailed", status: "danger", - title: msg ? t("exportEmptyDocumentTitle") : t("exportFailedTitle"), - description: msg - ? t("exportEmptyDocumentDescription") - : t("exportFailedDescription"), + title: t("exportFailedTitle"), + description: t("exportFailedDescription"), }); } }, diff --git a/app/(app)/create/hooks/useCreateFlowFinalize.ts b/app/(app)/create/hooks/useCreateFlowFinalize.ts index dd67bcd..8962f8d 100644 --- a/app/(app)/create/hooks/useCreateFlowFinalize.ts +++ b/app/(app)/create/hooks/useCreateFlowFinalize.ts @@ -196,6 +196,9 @@ export function useCreateFlowFinalize({ title, summary: summary ?? null, document: ruleDocument, + ...(publishResult.createdAt + ? { finishedAt: publishResult.createdAt } + : {}), }); if (isGuest) { writePendingKeepRuleLogin(); diff --git a/app/(app)/create/screens/completed/CompletedScreen.tsx b/app/(app)/create/screens/completed/CompletedScreen.tsx index 9e86423..7d1af1e 100644 --- a/app/(app)/create/screens/completed/CompletedScreen.tsx +++ b/app/(app)/create/screens/completed/CompletedScreen.tsx @@ -4,16 +4,17 @@ import { useState, useEffect } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import CommunityRule from "../../../../components/type/CommunityRule"; import type { CommunityRuleSection } from "../../../../components/type/CommunityRule/CommunityRule.types"; +import Link from "next/link"; import Alert from "../../../../components/modals/Alert"; -import AskOrganizerInquiryModal from "../../../../components/modals/AskOrganizerInquiry"; -import InlineTextButton from "../../../../components/buttons/InlineTextButton"; import { useMessages } from "../../../../contexts/MessagesContext"; import { fetchPublishedRuleDetail } from "../../../../../lib/create/api"; import { parsePublishedDocumentForCommunityRuleDisplay } from "../../../../../lib/create/publishedDocumentToDisplaySections"; import { + finishedAtIso, readLastPublishedRule, writeLastPublishedRule, } from "../../../../../lib/create/lastPublishedRule"; +import { ASK_ORGANIZER_HASH } from "../../../../../lib/sharePaths"; import { useCreateFlowMdUp } from "../../hooks/useCreateFlowMdUp"; import { CreateFlowHeaderLockup } from "../../components/CreateFlowHeaderLockup"; import { @@ -99,7 +100,6 @@ export function CompletedScreen() { /** Latch: toast copy should survive `router.replace` after we strip `?celebrate=1`. */ const [showCelebrateToast] = useState(celebrateInUrl); const [showCopiedReady] = useState(copiedInUrl); - const [askOrganizerOpen, setAskOrganizerOpen] = useState(false); const [headerTitle, setHeaderTitle] = useState(initial.headerTitle); const [headerDescription, setHeaderDescription] = useState< string | undefined @@ -124,11 +124,13 @@ export function CompletedScreen() { return; } const doc = detail.rule.document as Record; + const finishedAt = finishedAtIso(detail.rule.createdAt); writeLastPublishedRule({ id: detail.rule.id, title: detail.rule.title, summary: detail.rule.summary, document: doc, + ...(finishedAt ? { finishedAt } : {}), }); const parsed = parsePublishedDocumentForCommunityRuleDisplay(doc); if (parsed.length === 0) { @@ -210,13 +212,17 @@ export function CompletedScreen() { /> {headerTitle && !surfaceCopied ? (

- {completed.askOrganizerLead}{" "} - setAskOrganizerOpen(true)} + {completed.askOrganizerLead ? ( + <> + {completed.askOrganizerLead}{" "} + + ) : null} + {completed.askOrganizerLink} - +

) : null} @@ -261,10 +267,6 @@ export function CompletedScreen() { {toast} - setAskOrganizerOpen(false)} - /> ); } diff --git a/app/(app)/invite/_components/InvitedRuleView.tsx b/app/(app)/invite/_components/InvitedRuleView.tsx index bf0430a..6059e53 100644 --- a/app/(app)/invite/_components/InvitedRuleView.tsx +++ b/app/(app)/invite/_components/InvitedRuleView.tsx @@ -12,7 +12,10 @@ import { communityPossessive } from "../../../../lib/create/ruleInviteCardMeta"; import { CREATE_FLOW_COPIED_QUERY, CREATE_FLOW_COPIED_VALUE } from "../../../../lib/create/invitePaths"; import { formatInviteLastChanged } from "../../../../lib/create/inviteLastChanged"; import { writeLastPublishedRule } from "../../../../lib/create/lastPublishedRule"; -import { downloadStoredRuleAsPdf } from "../../../../lib/create/ruleExport"; +import { + downloadStoredRuleAsPdf, + printStoredRule, +} from "../../../../lib/create/ruleExport"; import { createCompletedPath } from "../../create/utils/createFlowPaths"; import { CreateFlowHeaderLockup } from "../../create/components/CreateFlowHeaderLockup"; import { useCreateFlowMdUp } from "../../create/hooks/useCreateFlowMdUp"; @@ -79,18 +82,34 @@ export function InvitedRuleView({ const handlePdf = useCallback(() => { try { - downloadStoredRuleAsPdf({ - id: ruleId, - title, - summary, - document, - }); + downloadStoredRuleAsPdf( + { + id: ruleId, + title, + summary, + document, + }, + window.location.origin, + ); setExportError(false); } catch { setExportError(true); } }, [document, ruleId, summary, title]); + const handlePrint = useCallback(() => { + const opened = printStoredRule( + { + id: ruleId, + title, + summary, + document, + }, + window.location.origin, + ); + setExportError(!opened); + }, [document, ruleId, summary, title]); + const handleCopy = useCallback( async (communityName: string) => { setCopyBusy(true); @@ -194,7 +213,7 @@ export function InvitedRuleView({ size="xsmall" type="button" className={outlineButtonClass} - onClick={() => window.print()} + onClick={handlePrint} > {t("print")} diff --git a/app/(app)/profile/ProfilePageClient.tsx b/app/(app)/profile/ProfilePageClient.tsx index c5ed09f..2f36123 100644 --- a/app/(app)/profile/ProfilePageClient.tsx +++ b/app/(app)/profile/ProfilePageClient.tsx @@ -19,12 +19,11 @@ import { type PublishedRuleDetailForClient, } from "../../../lib/create/api"; import { + downloadStoredRuleAsMarkdown, downloadStoredRuleAsPdf, - downloadTextFile, - exportFilenameBase, - exportStoredRuleAsMarkdown, } from "../../../lib/create/ruleExport"; import { + finishedAtIso, writeLastPublishedRule, type StoredLastPublishedRule, } from "../../../lib/create/lastPublishedRule"; @@ -255,11 +254,13 @@ export default function ProfilePageClient() { setActionError(t("actionError")); return; } + const finishedAt = finishedAtIso(detail.rule.createdAt); writeLastPublishedRule({ id: detail.rule.id, title: detail.rule.title, summary: detail.rule.summary, document: detail.rule.document as Record, + ...(finishedAt ? { finishedAt } : {}), }); router.push( createFlowStepPath("confirm-stakeholders", { @@ -334,11 +335,13 @@ export default function ProfilePageClient() { ) { return null; } + const finishedAt = finishedAtIso(rule.createdAt); return { id: rule.id, title: rule.title, summary: rule.summary, document: rule.document as Record, + ...(finishedAt ? { finishedAt } : {}), }; }, [], @@ -354,7 +357,7 @@ export default function ProfilePageClient() { return; } try { - downloadStoredRuleAsPdf(stored); + downloadStoredRuleAsPdf(stored, window.location.origin); } catch { setActionError(t("actionError")); } @@ -372,12 +375,7 @@ export default function ProfilePageClient() { return; } try { - const markdown = exportStoredRuleAsMarkdown(stored); - downloadTextFile( - `${exportFilenameBase(stored)}-community-rule.md`, - markdown, - "text/markdown;charset=utf-8", - ); + downloadStoredRuleAsMarkdown(stored, window.location.origin); } catch { setActionError(t("actionError")); } diff --git a/app/(marketing)/kit/page.tsx b/app/(marketing)/kit/page.tsx new file mode 100644 index 0000000..e943c22 --- /dev/null +++ b/app/(marketing)/kit/page.tsx @@ -0,0 +1,6 @@ +import { redirect } from "next/navigation"; + +/** Office-hours pointer used in the 48-hour follow-up email. */ +export default function KitPage() { + redirect("/workshops"); +} diff --git a/app/api/ops/rule-counts/route.ts b/app/api/ops/rule-counts/route.ts new file mode 100644 index 0000000..dbc23e9 --- /dev/null +++ b/app/api/ops/rule-counts/route.ts @@ -0,0 +1,42 @@ +import { NextRequest, NextResponse } from "next/server"; +import { apiRoute } from "../../../../lib/server/apiRoute"; +import { prisma } from "../../../../lib/server/db"; +import { + getOpsPruneToken, + getRuleAdminEmails, + isDatabaseConfigured, +} from "../../../../lib/server/env"; +import { + dbUnavailable, + notFound, + unauthorized, +} from "../../../../lib/server/responses"; +import { isRuleAdminEmail } from "../../../../lib/server/ruleAdmins"; +import { aggregateRuleLaunchCounts } from "../../../../lib/server/ruleLaunchCounts"; +import { getSessionUser } from "../../../../lib/server/session"; + +export const GET = apiRoute("ops.ruleCounts", async (request: NextRequest) => { + if (getRuleAdminEmails().length === 0 && !getOpsPruneToken()) { + return notFound(); + } + if (!isDatabaseConfigured()) return dbUnavailable(); + + const header = request.headers.get("authorization") ?? ""; + const opsToken = getOpsPruneToken(); + const bearerOk = Boolean(opsToken) && header === `Bearer ${opsToken}`; + if (!bearerOk) { + const user = await getSessionUser(); + if (!user || !isRuleAdminEmail(user.email)) return unauthorized(); + } + + const rows = await prisma.publishedRule.findMany({ + select: { orgType: true, communityLocation: true }, + }); + const counts = aggregateRuleLaunchCounts( + rows.map((row) => ({ + orgType: row.orgType, + place: row.communityLocation, + })), + ); + return NextResponse.json(counts); +}); diff --git a/app/api/rules/[id]/export/[format]/route.ts b/app/api/rules/[id]/export/[format]/route.ts new file mode 100644 index 0000000..11b00e5 --- /dev/null +++ b/app/api/rules/[id]/export/[format]/route.ts @@ -0,0 +1,112 @@ +import { NextRequest, NextResponse } from "next/server"; +import { apiRoute } from "../../../../../../lib/server/apiRoute"; +import { prisma } from "../../../../../../lib/server/db"; +import { + getSessionPepper, + isDatabaseConfigured, +} from "../../../../../../lib/server/env"; +import { getPublicOrigin } from "../../../../../../lib/server/publicOrigin"; +import { + dbUnavailable, + forbidden, + notFound, + unauthorized, +} from "../../../../../../lib/server/responses"; +import { isRuleAdminEmail } from "../../../../../../lib/server/ruleAdmins"; +import { ruleExportTokenMatches } from "../../../../../../lib/server/ruleExportToken"; +import { getSessionUser } from "../../../../../../lib/server/session"; +import { + RULE_MD_FILENAME, + buildStoredRulePdfBytes, + exportPdfFilename, + exportStoredRuleAsMarkdown, +} from "../../../../../../lib/create/ruleExport"; + +type RouteContext = { params: Promise<{ id: string; format: string }> }; + +function attachmentDisposition(filename: string): string { + const ascii = filename.replace(/[^\x20-\x7E]/g, "_").replace(/"/g, ""); + const encoded = encodeURIComponent(filename); + return `attachment; filename="${ascii}"; filename*=UTF-8''${encoded}`; +} + +function documentRecord(value: unknown): Record | null { + if (!value || typeof value !== "object" || Array.isArray(value)) return null; + return value as Record; +} + +export const GET = apiRoute( + "rules.export", + async (request: NextRequest, context) => { + if (!isDatabaseConfigured()) return dbUnavailable(); + + const { id, format } = await context.params; + if (format !== "pdf" && format !== "md") return notFound(); + + const row = await prisma.publishedRule.findUnique({ + where: { id }, + select: { + id: true, + title: true, + summary: true, + document: true, + createdAt: true, + userId: true, + }, + }); + if (!row) return notFound(); + + const token = request.nextUrl.searchParams.get("t") ?? ""; + let tokenOk = false; + if (token.length > 0) { + try { + tokenOk = ruleExportTokenMatches(row.id, token, getSessionPepper()); + } catch { + tokenOk = false; + } + } + + if (!tokenOk) { + const user = await getSessionUser(); + if (!user) return unauthorized(); + const isOwner = row.userId === user.id; + if (!isOwner && !isRuleAdminEmail(user.email)) { + return forbidden("You do not have permission to export this rule"); + } + } + + const document = documentRecord(row.document); + if (!document) return notFound(); + + const origin = getPublicOrigin(request); + const source = { + id: row.id, + title: row.title, + summary: row.summary, + document, + finishedAt: row.createdAt, + }; + + if (format === "pdf") { + const bytes = buildStoredRulePdfBytes(source, origin); + return new NextResponse(Buffer.from(bytes), { + headers: { + "Content-Type": "application/pdf", + "Content-Disposition": attachmentDisposition( + exportPdfFilename(row.title), + ), + "Cache-Control": "private, no-store", + }, + }); + } + + const markdown = exportStoredRuleAsMarkdown(source, origin); + return new NextResponse(markdown, { + headers: { + "Content-Type": "text/markdown; charset=utf-8", + "Content-Disposition": attachmentDisposition(RULE_MD_FILENAME), + "Cache-Control": "private, no-store", + }, + }); + }, +); diff --git a/app/api/rules/[id]/route.ts b/app/api/rules/[id]/route.ts index ce6c7f4..36a3403 100644 --- a/app/api/rules/[id]/route.ts +++ b/app/api/rules/[id]/route.ts @@ -16,6 +16,7 @@ import { linkUploadsToRule } from "../../../../lib/server/uploads/linkUploads"; import { publishRuleBodySchema } from "../../../../lib/server/validation/createFlowSchemas"; import { readLimitedJson } from "../../../../lib/server/validation/requestBody"; import { jsonFromZodError } from "../../../../lib/server/validation/zodHttp"; +import { publishedRuleAnalyticsColumns } from "../../../../lib/server/publishedRulePersist"; type RouteContext = { params: Promise<{ id: string }> }; @@ -88,6 +89,7 @@ export const PATCH = apiRoute( title, summary, document: document as Prisma.InputJsonValue, + ...publishedRuleAnalyticsColumns(document), }, }); await linkUploadsToRule({ diff --git a/app/api/rules/route.ts b/app/api/rules/route.ts index 6b38103..4e207cc 100644 --- a/app/api/rules/route.ts +++ b/app/api/rules/route.ts @@ -34,6 +34,7 @@ import { } from "../../../lib/server/validation/createFlowSchemas"; import { readLimitedJson } from "../../../lib/server/validation/requestBody"; import { jsonFromZodError } from "../../../lib/server/validation/zodHttp"; +import { publishedRuleAnalyticsColumns } from "../../../lib/server/publishedRulePersist"; /** One anonymous publish per IP per minute (in-memory limiter). */ const ANONYMOUS_PUBLISH_IP_MIN_INTERVAL_MS = 60_000; @@ -113,6 +114,7 @@ export const POST = apiRoute( summary, document: document as Prisma.InputJsonValue, claimTokenHash, + ...publishedRuleAnalyticsColumns(document), }, }); @@ -160,6 +162,7 @@ export const POST = apiRoute( title, summary, document: document as Prisma.InputJsonValue, + ...publishedRuleAnalyticsColumns(document), }, }); await linkUploadsToRule({ @@ -196,6 +199,7 @@ export const POST = apiRoute( title, summary, document: document as Prisma.InputJsonValue, + ...publishedRuleAnalyticsColumns(document), }, }); const toSend: { email: string; token: string }[] = []; diff --git a/app/components/asset/icon/Icon.tsx b/app/components/asset/icon/Icon.tsx index d2fa1bb..3aea5e8 100644 --- a/app/components/asset/icon/Icon.tsx +++ b/app/components/asset/icon/Icon.tsx @@ -18,6 +18,7 @@ import Numeric2CircleIcon from "./numeric-2-circle.svg"; import Numeric3CircleIcon from "./numeric-3-circle.svg"; import NumberIcon from "./number.svg"; import PictureAsPdfIcon from "./picture_as_pdf.svg"; +import PrintIcon from "./print.svg"; import TagsIcon from "./tags.svg"; import TextBlockIcon from "./text_block.svg"; import WarningIcon from "./warning.svg"; @@ -39,6 +40,7 @@ export const ICON_NAME_OPTIONS = [ "numeric_3_circle", "number", "picture_as_pdf", + "print", "tags", "text_block", "warning", @@ -68,6 +70,7 @@ const iconMap: Record = { numeric_3_circle: Numeric3CircleIcon, number: NumberIcon, picture_as_pdf: PictureAsPdfIcon, + print: PrintIcon, tags: TagsIcon, text_block: TextBlockIcon, warning: WarningIcon, diff --git a/app/components/asset/icon/print.svg b/app/components/asset/icon/print.svg new file mode 100644 index 0000000..e32b3e8 --- /dev/null +++ b/app/components/asset/icon/print.svg @@ -0,0 +1,6 @@ + + + diff --git a/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.container.tsx b/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.container.tsx index 34fcb88..ed4b748 100644 --- a/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.container.tsx +++ b/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.container.tsx @@ -88,18 +88,18 @@ const CreateFlowTopNavContainer = memo( leadingIcon: "picture_as_pdf", onClick: () => onSelectExportFormat("pdf"), }, - { - id: "export-csv", - label: tPopover("downloadCsv"), - leadingIcon: "csv", - onClick: () => onSelectExportFormat("csv"), - }, { id: "export-markdown", label: tPopover("downloadMarkdown"), leadingIcon: "markdown_copy", onClick: () => onSelectExportFormat("markdown"), }, + { + id: "export-print", + label: tPopover("print"), + leadingIcon: "print", + onClick: () => onSelectExportFormat("print"), + }, ); } @@ -233,8 +233,8 @@ const CreateFlowTopNavContainer = memo( actionMenuItems={actionMenuItems} exportPopoverMenuAriaLabel={tPopover("menuAriaLabel")} exportPopoverPdfLabel={tPopover("downloadPdf")} - exportPopoverCsvLabel={tPopover("downloadCsv")} exportPopoverMarkdownLabel={tPopover("downloadMarkdown")} + exportPopoverPrintLabel={tPopover("print")} moreOptionsAriaLabel={t("moreOptionsAriaLabel")} actionsMenuAriaLabel={t("actionsMenuAriaLabel")} shareLabel={t("share")} diff --git a/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.types.ts b/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.types.ts index 944fe39..b7d3b55 100644 --- a/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.types.ts +++ b/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.types.ts @@ -55,7 +55,7 @@ export interface CreateFlowTopNavProps { /** * Callback when user picks an export format from the Export menu. */ - onSelectExportFormat?: (_format: "pdf" | "csv" | "markdown") => void; + onSelectExportFormat?: (_format: "pdf" | "markdown" | "print") => void; /** * Callback when Edit button is clicked */ @@ -106,8 +106,8 @@ export type CreateFlowTopNavViewProps = CreateFlowTopNavProps & { actionMenuItems: CreateFlowTopNavActionMenuItem[]; exportPopoverMenuAriaLabel: string; exportPopoverPdfLabel: string; - exportPopoverCsvLabel: string; exportPopoverMarkdownLabel: string; + exportPopoverPrintLabel: string; moreOptionsAriaLabel: string; actionsMenuAriaLabel: string; shareLabel: string; diff --git a/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.view.tsx b/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.view.tsx index ef5b332..675c971 100644 --- a/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.view.tsx +++ b/app/components/navigation/CreateFlowTopNav/CreateFlowTopNav.view.tsx @@ -61,8 +61,8 @@ export function CreateFlowTopNavView({ actionMenuItems, exportPopoverMenuAriaLabel, exportPopoverPdfLabel, - exportPopoverCsvLabel, exportPopoverMarkdownLabel, + exportPopoverPrintLabel, moreOptionsAriaLabel, actionsMenuAriaLabel, shareLabel, @@ -145,19 +145,19 @@ export function CreateFlowTopNavView({ /> { - onSelectExportFormat("csv"); + onSelectExportFormat("markdown"); setExportMenuOpen(false); }} /> { - onSelectExportFormat("markdown"); + onSelectExportFormat("print"); setExportMenuOpen(false); }} /> diff --git a/app/components/navigation/Footer.tsx b/app/components/navigation/Footer.tsx index 0dc311a..0fa2402 100644 --- a/app/components/navigation/Footer.tsx +++ b/app/components/navigation/Footer.tsx @@ -210,6 +210,9 @@ const Footer = memo(({ siteOrigin = PRODUCTION_SITE_ORIGIN }: { siteOrigin?: str lg:gap-10 lg:text-small-paragraph" > + + {t("takeaway")} + {t("legal.privacyPolicy")} diff --git a/app/components/sections/AskOrganizer/AskOrganizer.view.tsx b/app/components/sections/AskOrganizer/AskOrganizer.view.tsx index 4538111..65b54f5 100644 --- a/app/components/sections/AskOrganizer/AskOrganizer.view.tsx +++ b/app/components/sections/AskOrganizer/AskOrganizer.view.tsx @@ -2,6 +2,7 @@ import ContentLockup from "../../type/ContentLockup"; import Button from "../../buttons/Button"; +import { ASK_ORGANIZER_HASH } from "../../../../lib/sharePaths"; import type { AskOrganizerViewProps } from "./AskOrganizer.types"; function AskOrganizerView({ @@ -28,6 +29,7 @@ function AskOrganizerView({ return (
{ } export default function RootLayout({ children }: { children: ReactNode }) { - // Load messages for the default locale (single locale setup) + const umami = umamiTracker(); return ( @@ -148,11 +150,26 @@ export default function RootLayout({ children }: { children: ReactNode }) { type="image/png" /> - -
- {children} -
- + {umami ? ( + + " }], - }, - ]; const html = buildPrintableRuleHtmlDocument( - 'Title ', - null, - sections, + { + id: "id-1", + title: "Title ", + summary: null, + document: { + sections: [ + { + categoryName: "Values ", + entries: [{ title: "Entry", body: "" }], + }, + ], + }, + }, + origin, ); expect(html).toContain("<script>"); expect(html).not.toContain("