@anthusai/papyrus 1.19.1 → 2.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/globals.css +0 -175
- package/app/newsroom/[section]/[...selection]/page.tsx +0 -6
- package/app/newsroom/[section]/page.tsx +2 -4
- package/app/newsroom/articles/page.tsx +1 -2
- package/app/newsroom/sections/[sectionId]/page.tsx +2 -6
- package/bin/papyrus-infra.mjs +11 -2
- package/components/news-desk-page.tsx +3 -4
- package/components/newsroom-ops-shell.tsx +142 -234
- package/components/reference-cyclotron-priming.tsx +12 -13
- package/components/reference-cyclotron-status.tsx +4 -4
- package/components/reference-cyclotron-suggestion.tsx +6 -6
- package/components/reference-live-agreement.tsx +10 -10
- package/components/reference-priming.tsx +1 -1
- package/components/reference-relevance-review.tsx +1 -1
- package/components/reference-section-suggestion.tsx +1 -1
- package/components/topic-steering-workspace.tsx +17 -510
- package/lib/cyclotron-suggestions.ts +9 -9
- package/lib/newsroom-list-selection.ts +0 -3
- package/lib/newsroom-nav.ts +5 -8
- package/lib/newsroom-section-routing.ts +2 -4
- package/lib/relevance-status.ts +4 -4
- package/lib/site-brand.ts +1 -8
- package/package.json +2 -3
- package/routes.manifest.json +1 -1
- package/src/cdk-environment.mjs +44 -0
- package/components/newsroom-organizer-shell.tsx +0 -153
|
@@ -92,13 +92,13 @@ export function latestShadowAgreement(payloads: Array<{ json: unknown; updatedAt
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
const STOP_REASON_WORDS: Record<string, string> = {
|
|
95
|
-
disabled: "
|
|
96
|
-
"daily decision cap": "The last
|
|
95
|
+
disabled: "Suggestions are switched off in the settings, so none are being made.",
|
|
96
|
+
"daily decision cap": "The last check reached the daily limit, so some references have no suggestion yet.",
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
/** The sentence an editor reads for a stop reason; unknown reasons are shown as given. */
|
|
100
100
|
export function stopReasonSentence(reason: string): string {
|
|
101
|
-
return STOP_REASON_WORDS[reason] ?? `The last
|
|
101
|
+
return STOP_REASON_WORDS[reason] ?? `The last check stopped early: ${reason}.`;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
@@ -123,14 +123,14 @@ export function agreementStripState(agreement: ShadowAgreement | null): Agreemen
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
/** "
|
|
126
|
+
/** "Suggestions on" or "Suggestions off", the words the panel leads with. */
|
|
127
127
|
export function loopStateWords(loop: CyclotronLoopState): string {
|
|
128
|
-
return loop.enabled ? "
|
|
128
|
+
return loop.enabled ? "Suggestions on" : "Suggestions off";
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/** The daily cap in words; no cap is said plainly. */
|
|
132
132
|
export function dailyCapWords(loop: CyclotronLoopState): string {
|
|
133
|
-
return loop.maxDecisionsPerDay === null ? "No daily
|
|
133
|
+
return loop.maxDecisionsPerDay === null ? "No daily limit" : `Daily limit ${loop.maxDecisionsPerDay} decisions`;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
export function formatPercentage(fraction: number | null): string {
|
|
@@ -202,10 +202,10 @@ export function provenanceSummary(decision: RelevanceDecisionView): ProvenanceSu
|
|
|
202
202
|
if (!provenance) return null;
|
|
203
203
|
const plural = (count: number, singular: string) => `${count} ${singular}${count === 1 ? "" : "s"}`;
|
|
204
204
|
return {
|
|
205
|
-
teachingLabelsSentence: `
|
|
206
|
-
primingExamplesSentence: `${plural(provenance.primingExamples, "
|
|
205
|
+
teachingLabelsSentence: `Based on ${plural(provenance.teachingLabels, "decision")} that editors made themselves`,
|
|
206
|
+
primingExamplesSentence: `${plural(provenance.primingExamples, "example reference")} supplied as starting examples`,
|
|
207
207
|
doctrineShortHash: provenance.doctrineFingerprint ? provenance.doctrineFingerprint.slice(0, SHORT_HASH_LENGTH) : null,
|
|
208
|
-
modelVersion: decision.version === null ? null : `
|
|
208
|
+
modelVersion: decision.version === null ? null : `revision ${decision.version}`,
|
|
209
209
|
decidedAt: decision.decidedAt,
|
|
210
210
|
};
|
|
211
211
|
}
|
|
@@ -22,9 +22,6 @@ export const NEWSROOM_INBOX_ROW_ACTIVE =
|
|
|
22
22
|
export const NEWSROOM_SIDEBAR_NAV_ACTIVE =
|
|
23
23
|
"bg-primary/10 text-foreground shadow-none hover:bg-primary/15";
|
|
24
24
|
|
|
25
|
-
export const NEWSROOM_SIDEBAR_NAV_INACTIVE =
|
|
26
|
-
"text-muted-foreground hover:bg-muted/50 hover:text-foreground";
|
|
27
|
-
|
|
28
25
|
export function newsroomListRowClassName(active: boolean, className?: string): string {
|
|
29
26
|
return cn(
|
|
30
27
|
NEWSROOM_LIST_ROW_BASE,
|
package/lib/newsroom-nav.ts
CHANGED
|
@@ -18,23 +18,20 @@ export type NewsroomNavItem = {
|
|
|
18
18
|
label: string;
|
|
19
19
|
detail: string;
|
|
20
20
|
href: string;
|
|
21
|
-
mobilePrimary?: boolean;
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
export const NEWSROOM_OPS_NAV: NewsroomNavItem[] = [
|
|
25
|
-
{ id: "overview", label: "Overview", detail: "Desk home", href: newsroomHref()
|
|
26
|
-
{ id: "articles", label: getContentItemName().plural, detail: "Drafts & published", href: newsroomHref("articles")
|
|
27
|
-
{ id: "assignments", label: "Assignments", detail: "Work queue", href: newsroomHref("assignments")
|
|
28
|
-
{ id: "references", label: "References", detail: "Knowledge base", href: newsroomHref("references")
|
|
24
|
+
{ id: "overview", label: "Overview", detail: "Desk home", href: newsroomHref() },
|
|
25
|
+
{ id: "articles", label: getContentItemName().plural, detail: "Drafts & published", href: newsroomHref("articles") },
|
|
26
|
+
{ id: "assignments", label: "Assignments", detail: "Work queue", href: newsroomHref("assignments") },
|
|
27
|
+
{ id: "references", label: "References", detail: "Knowledge base", href: newsroomHref("references") },
|
|
29
28
|
{ id: "messages", label: "Messages", detail: "Forum", href: newsroomHref("messages") },
|
|
30
|
-
{ id: "topics", label: "Topics", detail: "Taxonomy", href: newsroomHref("topics")
|
|
29
|
+
{ id: "topics", label: "Topics", detail: "Taxonomy", href: newsroomHref("topics") },
|
|
31
30
|
{ id: "concepts", label: "Concept wiki", detail: "Knowledge graph", href: newsroomHref("concepts") },
|
|
32
31
|
{ id: "search", label: "Search", detail: "Knowledge base", href: newsroomHref("search") },
|
|
33
32
|
{ id: "administration", label: "Administration", detail: "Users & policies", href: newsroomHref("administration") },
|
|
34
33
|
];
|
|
35
34
|
|
|
36
|
-
export const NEWSROOM_MOBILE_PRIMARY_NAV = NEWSROOM_OPS_NAV.filter((item) => item.mobilePrimary);
|
|
37
|
-
|
|
38
35
|
export function getNewsroomNavHref(href: string, demo?: boolean): string {
|
|
39
36
|
const path = toPublicNewsroomPath(href);
|
|
40
37
|
if (!demo) return path;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { NewsDeskTab } from "../components/topic-steering-workspace";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** Resolves the requested newsroom section, mapping retired aliases onto their current destinations. */
|
|
4
4
|
export function resolveNewsDeskTab(
|
|
5
5
|
sectionValue: string | string[] | null | undefined,
|
|
6
6
|
legacyTabValue: string | string[] | null | undefined,
|
|
7
|
-
organizer = false,
|
|
8
7
|
): NewsDeskTab {
|
|
9
8
|
const section = Array.isArray(sectionValue) ? sectionValue[0] : sectionValue;
|
|
10
9
|
const legacyTab = Array.isArray(legacyTabValue) ? legacyTabValue[0] : legacyTabValue;
|
|
11
10
|
const raw = section ?? (legacyTab === "categories" ? "topics" : legacyTab);
|
|
12
|
-
const value = raw === "users" || raw === "doctrine" ? "administration"
|
|
13
|
-
: raw === "desks" && !organizer ? "topics" : raw;
|
|
11
|
+
const value = raw === "users" || raw === "doctrine" ? "administration" : raw;
|
|
14
12
|
switch (value) {
|
|
15
13
|
case "desks": case "administration": case "topics": case "concepts":
|
|
16
14
|
case "references": case "messages": case "assignments": case "search":
|
package/lib/relevance-status.ts
CHANGED
|
@@ -127,10 +127,10 @@ export function isPrimingOutcome(value: unknown): value is PrimingOutcome {
|
|
|
127
127
|
|| (outcome.state === "failed" && typeof outcome.message === "string");
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/** In words:
|
|
130
|
+
/** In plain words: Adding, Added, or Couldn't add with the reason. */
|
|
131
131
|
export function primingStateText(view: PrimingRequestView): string {
|
|
132
|
-
if (!view.outcome) return "
|
|
132
|
+
if (!view.outcome) return "Adding";
|
|
133
133
|
return view.outcome.state === "applied"
|
|
134
|
-
?
|
|
135
|
-
: `
|
|
134
|
+
? "Added"
|
|
135
|
+
: `Couldn't add: ${view.outcome.message}`;
|
|
136
136
|
}
|
package/lib/site-brand.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isLocalPreviewEnabled } from "./local-preview";
|
|
2
1
|
import { areEditionsEnabled } from "./site-env";
|
|
3
2
|
import type { ComponentType } from "react";
|
|
4
3
|
import type { EditionPresentationFormat } from "./content-types";
|
|
@@ -134,8 +133,6 @@ export type SiteBrand = {
|
|
|
134
133
|
/** Public URL prefix for the Pretext reader (home, editions, articles, archive, settings). Default `""`; e.g. `/information`. */
|
|
135
134
|
readerBasePath?: string;
|
|
136
135
|
opsChrome: OpsChrome;
|
|
137
|
-
/** Opt-in CMS viewport layout; independent of the public reader renderer/theme. */
|
|
138
|
-
newsroomLayout?: "organizer";
|
|
139
136
|
corpusKey: string;
|
|
140
137
|
steeringConfigPath: string;
|
|
141
138
|
newsroomSectionsConfigPath: string;
|
|
@@ -205,11 +202,7 @@ const REGISTERED_SITE_BRANDS: Record<SiteBrandId, SiteBrand> = {
|
|
|
205
202
|
...Object.fromEntries((papyrusSite.brands ?? []).map((brand) => [brand.id, brand])),
|
|
206
203
|
};
|
|
207
204
|
|
|
208
|
-
const SITE_BRANDS: Record<SiteBrandId, SiteBrand> =
|
|
209
|
-
? Object.fromEntries(
|
|
210
|
-
Object.entries(REGISTERED_SITE_BRANDS).map(([id, brand]) => [id, { ...brand, newsroomLayout: "organizer" as const }]),
|
|
211
|
-
)
|
|
212
|
-
: REGISTERED_SITE_BRANDS;
|
|
205
|
+
const SITE_BRANDS: Record<SiteBrandId, SiteBrand> = REGISTERED_SITE_BRANDS;
|
|
213
206
|
|
|
214
207
|
export function normalizeSiteBrandId(value: string | undefined | null): SiteBrandId | null {
|
|
215
208
|
if (!value) return null;
|
package/package.json
CHANGED
|
@@ -94,7 +94,6 @@
|
|
|
94
94
|
"./components/newsroom-curation-provider": "./components/newsroom-curation-provider.tsx",
|
|
95
95
|
"./components/newsroom-ops-overview": "./components/newsroom-ops-overview.tsx",
|
|
96
96
|
"./components/newsroom-ops-shell": "./components/newsroom-ops-shell.tsx",
|
|
97
|
-
"./components/newsroom-organizer-shell": "./components/newsroom-organizer-shell.tsx",
|
|
98
97
|
"./components/newsroom-references-view": "./components/newsroom-references-view.tsx",
|
|
99
98
|
"./components/newsroom-topics-view": "./components/newsroom-topics-view.tsx",
|
|
100
99
|
"./components/papyrus-console-shell": "./components/papyrus-console-shell.tsx",
|
|
@@ -379,7 +378,7 @@
|
|
|
379
378
|
"optional": true
|
|
380
379
|
}
|
|
381
380
|
},
|
|
382
|
-
"version": "
|
|
381
|
+
"version": "2.0.0-next.2",
|
|
383
382
|
"dependencies": {
|
|
384
383
|
"@aws-amplify/adapter-nextjs": "^1.7.3",
|
|
385
384
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
@@ -392,7 +391,7 @@
|
|
|
392
391
|
"@aws-sdk/s3-request-presigner": "^3.1045.0",
|
|
393
392
|
"@base-ui/react": "^1.5.0",
|
|
394
393
|
"@chenglou/pretext": "^0.0.7",
|
|
395
|
-
"@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.3.
|
|
394
|
+
"@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.3.1/kanbus-ui-0.3.1.tgz",
|
|
396
395
|
"@radix-ui/colors": "3.0.0",
|
|
397
396
|
"@smithy/protocol-http": "5.4.1",
|
|
398
397
|
"@smithy/signature-v4": "5.7.4",
|
package/routes.manifest.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_REGION = "us-east-1";
|
|
4
|
+
|
|
5
|
+
export function resolveCdkRegion({ explicitRegion, environment = process.env }) {
|
|
6
|
+
return (
|
|
7
|
+
explicitRegion ||
|
|
8
|
+
environment.AWS_REGION ||
|
|
9
|
+
environment.AWS_DEFAULT_REGION ||
|
|
10
|
+
environment.CDK_DEFAULT_REGION ||
|
|
11
|
+
DEFAULT_REGION
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function callerAccountFromAwsCli() {
|
|
16
|
+
const completed = spawnSync("aws", ["sts", "get-caller-identity", "--output", "json"], { encoding: "utf8" });
|
|
17
|
+
if (completed.error) throw new Error(`could not run the aws CLI: ${completed.error.message}`);
|
|
18
|
+
if (completed.status !== 0) throw new Error(String(completed.stderr || completed.stdout).trim() || `aws exited with status ${completed.status}`);
|
|
19
|
+
return JSON.parse(completed.stdout).Account;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function resolveCdkAccount({ explicitAccount, environment = process.env, lookupCallerAccount = callerAccountFromAwsCli }) {
|
|
23
|
+
if (explicitAccount) return explicitAccount;
|
|
24
|
+
if (environment.CDK_DEFAULT_ACCOUNT) return environment.CDK_DEFAULT_ACCOUNT;
|
|
25
|
+
let account;
|
|
26
|
+
try {
|
|
27
|
+
account = lookupCallerAccount();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`cannot determine the AWS account: pass --account, set CDK_DEFAULT_ACCOUNT, or provide credentials for "aws sts get-caller-identity" (${error instanceof Error ? error.message : error})`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (!/^\d{12}$/.test(String(account))) {
|
|
34
|
+
throw new Error(`cannot determine the AWS account: "aws sts get-caller-identity" returned ${JSON.stringify(account)}; pass --account or set CDK_DEFAULT_ACCOUNT`);
|
|
35
|
+
}
|
|
36
|
+
return String(account);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function resolveCdkEnvironment({ explicitAccount, explicitRegion, environment = process.env, lookupCallerAccount }) {
|
|
40
|
+
return {
|
|
41
|
+
account: resolveCdkAccount({ explicitAccount, environment, lookupCallerAccount }),
|
|
42
|
+
region: resolveCdkRegion({ explicitRegion, environment }),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useEffect, useId, useState } from "react";
|
|
4
|
-
import Link from "next/link";
|
|
5
|
-
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
6
|
-
import { BookOpen, ClipboardList, Menu, Search, MessagesSquare, PanelLeftClose, PanelLeftOpen, Settings, UserRound, LogIn, LogOut } from "lucide-react";
|
|
7
|
-
import { ORGANIZER_NAV_GROUPS, ORGANIZER_PRIMARY_NAV, ORGANIZER_SETTINGS_DESTINATION } from "../lib/newsroom-organizer-nav";
|
|
8
|
-
import { browserPathToInternalNewsroomPath } from "../lib/newsroom-base-path";
|
|
9
|
-
import { getNewsroomNavHref } from "../lib/newsroom-nav";
|
|
10
|
-
import { SITE_BRAND } from "../lib/site-brand";
|
|
11
|
-
import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
|
|
12
|
-
import { ReaderAuthControl } from "./reader-auth-control";
|
|
13
|
-
import { ProspectusAccountChooser, useProspectusAccountSummary } from "./prospectus-account-chooser";
|
|
14
|
-
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetTrigger } from "./ui/sheet";
|
|
15
|
-
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuSeparator } from "./ui/dropdown-menu";
|
|
16
|
-
import type { NewsroomOpsShellProps } from "./newsroom-ops-shell";
|
|
17
|
-
import "./newsroom-organizer.css";
|
|
18
|
-
|
|
19
|
-
/** The standard place to search the knowledge base; the Search page is the results page. */
|
|
20
|
-
function OrganizerSearch({ demo }: { demo: boolean }) {
|
|
21
|
-
const router = useRouter();
|
|
22
|
-
const searchParams = useSearchParams();
|
|
23
|
-
const [text, setText] = useState(searchParams.get("q") ?? "");
|
|
24
|
-
return <form className="organizer-search" role="search" onSubmit={event => {
|
|
25
|
-
event.preventDefault();
|
|
26
|
-
const query = text.trim();
|
|
27
|
-
if (query) router.push(getNewsroomNavHref(`/newsroom/search?q=${encodeURIComponent(query)}`, demo));
|
|
28
|
-
}}>
|
|
29
|
-
<Search size={14} aria-hidden="true" />
|
|
30
|
-
<input aria-label="Search the knowledge base" data-newsroom-search type="search" onChange={event => setText(event.target.value)} placeholder="Search" value={text} />
|
|
31
|
-
</form>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const ICONS = { articles: ClipboardList, references: BookOpen, messages: MessagesSquare };
|
|
35
|
-
|
|
36
|
-
/** Navigation is a presentation layer; existing route and server authorization still own access. */
|
|
37
|
-
function Navigation({ activePath, demo, admin, surface, onNavigate }: { activePath: string; demo: boolean; admin: boolean; surface: string; onNavigate?: () => void }) {
|
|
38
|
-
const id = useId();
|
|
39
|
-
const all = ORGANIZER_NAV_GROUPS.flatMap(group => group.items);
|
|
40
|
-
const active = all.filter(item => [item.path, ...(item.alsoActiveOnPaths ?? [])].some(candidate => activePath === candidate || (candidate !== "/newsroom" && activePath.startsWith(candidate + "/")))).sort((a, b) => b.path.length - a.path.length)[0]?.key;
|
|
41
|
-
return <nav className="organizer-destinations" aria-label={surface === "sidebar" ? "Newsroom" : "All workspaces"}>
|
|
42
|
-
{ORGANIZER_NAV_GROUPS.map((group, index) => <section key={group.title} aria-labelledby={`${id}-${index}`}>
|
|
43
|
-
<h3 id={`${id}-${index}`}>{group.title}</h3>
|
|
44
|
-
{group.items.filter(item => item.access !== "admin" || admin).map(item => <Link key={item.key}
|
|
45
|
-
href={getNewsroomNavHref(item.path, demo)} onClick={onNavigate} aria-label={item.label}
|
|
46
|
-
aria-current={active === item.key ? "page" : undefined} aria-describedby={`${id}-${item.key}`}
|
|
47
|
-
data-news-desk-tab={item.key}>
|
|
48
|
-
<strong>{item.label}</strong><small id={`${id}-${item.key}`}>{item.description}</small>
|
|
49
|
-
</Link>)}
|
|
50
|
-
</section>)}
|
|
51
|
-
</nav>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function Account({ placement }: { placement: "sidebar" | "header" }) {
|
|
55
|
-
const session = useOptionalNewsDeskClient();
|
|
56
|
-
const auth = session?.shell.auth ?? { status: "loading" as const, label: "Checking sign-in" };
|
|
57
|
-
const [open, setOpen] = useState(false);
|
|
58
|
-
const accountSummary = useProspectusAccountSummary();
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
const media = matchMedia("(max-width: 900px)");
|
|
61
|
-
const close = () => setOpen(false);
|
|
62
|
-
media.addEventListener("change", close);
|
|
63
|
-
return () => media.removeEventListener("change", close);
|
|
64
|
-
}, []);
|
|
65
|
-
return <DropdownMenu open={open} onOpenChange={setOpen}>
|
|
66
|
-
<DropdownMenuTrigger id={`organizer-account-trigger-${placement}`} className={`organizer-account organizer-account-${placement}`} aria-label="Account menu" title="Account menu">
|
|
67
|
-
<UserRound size={18} aria-hidden="true" /><span><strong>{auth.label}</strong><small>{accountSummary ?? (auth.status === "signedIn" ? "Account & preferences" : auth.status === "signedOut" ? "Not signed in" : "Checking session")}</small></span>
|
|
68
|
-
</DropdownMenuTrigger>
|
|
69
|
-
<DropdownMenuContent className="organizer-account-popup" side={placement === "sidebar" ? "top" : "bottom"} align="end">
|
|
70
|
-
<DropdownMenuGroup>
|
|
71
|
-
<DropdownMenuLabel>{auth.label}</DropdownMenuLabel><DropdownMenuSeparator />
|
|
72
|
-
<ProspectusAccountChooser />
|
|
73
|
-
<DropdownMenuItem render={<Link href={getNewsroomNavHref(ORGANIZER_SETTINGS_DESTINATION.path)} />}><Settings aria-hidden="true" />{ORGANIZER_SETTINGS_DESTINATION.label}</DropdownMenuItem>
|
|
74
|
-
<ReaderAuthControl authState={auth} renderAction={({ disabled, onClick, signedIn }) => <DropdownMenuItem disabled={disabled} closeOnClick={false} onClick={onClick}>
|
|
75
|
-
{signedIn ? <LogOut aria-hidden="true" /> : <LogIn aria-hidden="true" />}{signedIn ? "Sign out" : "Sign in"}
|
|
76
|
-
</DropdownMenuItem>} />
|
|
77
|
-
</DropdownMenuGroup>
|
|
78
|
-
</DropdownMenuContent>
|
|
79
|
-
</DropdownMenu>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function NewsroomOrganizerShell({ activeTab, appTitle, backHref = "/", backLabel, children, demo = false, headerActions, pageTitle, showNavigation = true }: NewsroomOpsShellProps) {
|
|
83
|
-
const pathname = usePathname();
|
|
84
|
-
const session = useOptionalNewsDeskClient();
|
|
85
|
-
const admin = demo || session?.shell.dashboard?.canManageUsers === true;
|
|
86
|
-
const [menuOpen, setMenuOpen] = useState(false);
|
|
87
|
-
const [collapsed, setCollapsed] = useState(false);
|
|
88
|
-
const [loadedPreference, setLoadedPreference] = useState(false);
|
|
89
|
-
const preferenceKey = `papyrus.cms.sidebar.v1.${SITE_BRAND.id}`;
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
try { setCollapsed(localStorage.getItem(preferenceKey) === "true"); } catch { /* Optional browser preference. */ }
|
|
92
|
-
setLoadedPreference(true);
|
|
93
|
-
}, [preferenceKey]);
|
|
94
|
-
useEffect(() => { if (loadedPreference) try { localStorage.setItem(preferenceKey, String(collapsed)); } catch { /* Controls still work without storage. */ } }, [collapsed, loadedPreference, preferenceKey]);
|
|
95
|
-
useEffect(() => { setMenuOpen(false); }, [pathname]);
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
const media = matchMedia("(max-width: 900px)");
|
|
98
|
-
let previousFocus: Element | null = null;
|
|
99
|
-
let frame = 0;
|
|
100
|
-
const remember = () => { if (document.activeElement !== document.body) previousFocus = document.activeElement; };
|
|
101
|
-
const change = () => {
|
|
102
|
-
const active = document.activeElement === document.body ? previousFocus : document.activeElement;
|
|
103
|
-
if (!(active instanceof HTMLElement)) return;
|
|
104
|
-
if (!media.matches) setMenuOpen(false);
|
|
105
|
-
const selector = active.closest(".organizer-account, .organizer-account-popup") ? ".organizer-account"
|
|
106
|
-
: media.matches && active.closest(".organizer-sidebar, .organizer-toggle") ? ".organizer-more"
|
|
107
|
-
: !media.matches && active.closest(".organizer-bottom-nav, .organizer-menu") ? ".organizer-toggle" : null;
|
|
108
|
-
if (!selector) return;
|
|
109
|
-
cancelAnimationFrame(frame);
|
|
110
|
-
frame = requestAnimationFrame(() => {
|
|
111
|
-
if (document.activeElement === active || document.activeElement === document.body || !(document.activeElement as HTMLElement)?.getClientRects().length)
|
|
112
|
-
Array.from(document.querySelectorAll<HTMLElement>(selector)).find(element => element.getClientRects().length)?.focus();
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
document.addEventListener("focusin", remember);
|
|
116
|
-
media.addEventListener("change", change);
|
|
117
|
-
return () => { document.removeEventListener("focusin", remember); media.removeEventListener("change", change); cancelAnimationFrame(frame); };
|
|
118
|
-
}, []);
|
|
119
|
-
const activePath = browserPathToInternalNewsroomPath(pathname ?? "/newsroom");
|
|
120
|
-
const sidebarToggleLabel = collapsed ? "Expand sidebar" : "Collapse sidebar";
|
|
121
|
-
const sidebarToggle = <button type="button" className="organizer-toggle" title={sidebarToggleLabel}
|
|
122
|
-
aria-label={sidebarToggleLabel} aria-expanded={!collapsed} aria-controls="organizer-sidebar" onClick={() => setCollapsed(value => !value)}>
|
|
123
|
-
{collapsed ? <PanelLeftOpen size={16} aria-hidden="true" /> : <PanelLeftClose size={16} aria-hidden="true" />}
|
|
124
|
-
</button>;
|
|
125
|
-
return <div className="newsroom-organizer" data-news-desk data-newsroom-ops-shell="true" data-newsroom-chrome="organizer" data-sidebar-collapsed={collapsed || !showNavigation ? "true" : "false"}>
|
|
126
|
-
{showNavigation && <aside className="organizer-sidebar" hidden={collapsed} id="organizer-sidebar">
|
|
127
|
-
<div className="organizer-sidebar-head">
|
|
128
|
-
<Link className="organizer-brand" href={getNewsroomNavHref("/newsroom", demo)}>{SITE_BRAND.components?.NewsroomLogo ? <SITE_BRAND.components.NewsroomLogo className="organizer-brand-logo" /> : appTitle}<small>The newsroom</small></Link>
|
|
129
|
-
{sidebarToggle}
|
|
130
|
-
</div>
|
|
131
|
-
<Navigation activePath={activePath} demo={demo} admin={admin} surface="sidebar" />
|
|
132
|
-
<Account placement="sidebar" />
|
|
133
|
-
</aside>}
|
|
134
|
-
<div className="organizer-workspace">
|
|
135
|
-
<header className="organizer-topbar" data-newsroom-ops-topbar>
|
|
136
|
-
{showNavigation && collapsed && sidebarToggle}
|
|
137
|
-
<Link className="organizer-masthead" href={backHref} title={backLabel}>{appTitle}</Link>
|
|
138
|
-
<h1 data-newsroom-ops-title>{pageTitle}</h1><OrganizerSearch demo={demo} /><div className="organizer-header-actions">{headerActions}</div><Account placement="header" />
|
|
139
|
-
</header>
|
|
140
|
-
<main className="organizer-main">{demo && <p className="organizer-demo-notice">Demo workspace · synthetic examples</p>}{children}</main>
|
|
141
|
-
</div>
|
|
142
|
-
{showNavigation && <nav className="organizer-bottom-nav" aria-label="Primary newsroom navigation"><ul>
|
|
143
|
-
{ORGANIZER_PRIMARY_NAV.map(item => { const Icon = ICONS[item.key as keyof typeof ICONS]; return <li key={item.key}><Link
|
|
144
|
-
href={getNewsroomNavHref(item.path, demo)} title={item.description} aria-label={item.label} aria-current={activeTab === item.key ? "page" : undefined}>
|
|
145
|
-
<Icon size={18} aria-hidden="true" /><span>{item.label}</span></Link></li>; })}
|
|
146
|
-
<li><Sheet open={menuOpen} onOpenChange={setMenuOpen}><SheetTrigger className="organizer-more" aria-label="More"><Menu size={18} aria-hidden="true" /><span>More</span></SheetTrigger>
|
|
147
|
-
<SheetContent side="bottom" className="organizer-menu"><SheetHeader><SheetTitle>Newsroom</SheetTitle><SheetDescription>Workspaces and administration</SheetDescription></SheetHeader>
|
|
148
|
-
<Navigation activePath={activePath} demo={demo} admin={admin} surface="menu" onNavigate={() => setMenuOpen(false)} />
|
|
149
|
-
</SheetContent>
|
|
150
|
-
</Sheet></li>
|
|
151
|
-
</ul></nav>}
|
|
152
|
-
</div>;
|
|
153
|
-
}
|