Skip to content
File

Blob: src/client/components/workspace/share-dialog/types.ts

typescript101 lines
1import type { ShareDialogAffordance } from "@/client/lib/affordance/share-dialog";
2import type { SitePublishAffordance } from "@/client/lib/affordance/site-publish";
3import type { ResolvedWorkspaceRole } from "@/shared/entitlements";
4import type { PageKind, PageShare, SitePageStatus, WorkspaceMember, WorkspaceSiteResponse } from "@/shared/types";
5 
6export type SharePermission = "view" | "edit";
7export type WorkspaceRole = ResolvedWorkspaceRole;
8export type DialogTab = "share" | "publish";
9 
10export interface ShareDialogProps {
11 pageId: string;
12 workspaceId: string;
13 pageKind: PageKind;
14 disabled?: boolean;
15 title?: string;
16}
17 
18export interface ShareDialogShellValue {
19 disabled: boolean;
20 title: string | undefined;
21 open: boolean;
22 loading: boolean;
23 creating: boolean;
24 error: string | null;
25 dialogAffordance: ShareDialogAffordance;
26 publishAffordance: SitePublishAffordance;
27 workspaceRole: WorkspaceRole;
28 online: boolean;
29 currentUserId: string | undefined;
30 activeTab: DialogTab;
31 setActiveTab: (tab: DialogTab) => void;
32 toggleOpen: () => void;
33 close: () => void;
34 deleteShare: (shareId: string) => Promise<void>;
35}
36 
37export interface SharePeopleValue {
38 peopleInput: string;
39 peoplePermission: SharePermission;
40 showSuggestions: boolean;
41 userShares: PageShare[];
42 members: WorkspaceMember[];
43 filteredSuggestions: WorkspaceMember[];
44 /** True when the input text exactly matches a shareable workspace member.
45 * Members (no canShareByEmail) cannot submit without this. */
46 hasMatchedMember: boolean;
47 memberName: (member: WorkspaceMember) => string;
48 granteeName: (share: PageShare) => string;
49 setPeopleInput: (value: string) => void;
50 setPeoplePermission: (value: SharePermission) => void;
51 openSuggestions: () => void;
52 dismissSuggestions: () => void;
53 selectMember: (member: WorkspaceMember) => void;
54 submitPeopleShare: () => Promise<void>;
55}
56 
57export interface ShareLinkValue {
58 linkPermission: SharePermission;
59 linkShares: PageShare[];
60 copiedId: string | null;
61 setLinkPermission: (value: SharePermission) => void;
62 createLinkShare: () => Promise<void>;
63 copyLink: (share: PageShare) => void;
64}
65 
66export interface SitePublishValue {
67 pageId: string;
68 workspaceId: string;
69 site: WorkspaceSiteResponse | undefined;
70 pageStatus: SitePageStatus | undefined;
71 loading: boolean;
72 /** Any mutation in flight — used to disable peers while one is running. */
73 saving: boolean;
74 /** Per-action pending flags so each button can show its own spinner without
75 * the others spinning sympathetically. */
76 slugSavePending: boolean;
77 siteTogglePending: boolean;
78 setHomePending: boolean;
79 publishPending: boolean;
80 unpublishPending: boolean;
81 featureDisabled: boolean;
82 error: string | null;
83 slugDraft: string;
84 setSlugDraft: (next: string) => void;
85 saveSiteSlug: (slug: string) => Promise<void>;
86 toggleSitePublished: () => Promise<void>;
87 publishPage: () => Promise<void>;
88 unpublishPage: () => Promise<void>;
89 isHome: boolean;
90 toggleHomePage: () => Promise<void>;
91 copyPublicUrl: () => void;
92 copied: boolean;
93}
94 
95export interface ShareDialogSlices {
96 shell: ShareDialogShellValue;
97 people: SharePeopleValue;
98 link: ShareLinkValue;
99 publish: SitePublishValue;
100}