@openpeepshq/react 0.7.0 → 0.7.1

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.
Files changed (188) hide show
  1. package/dist/components/configuration/ConfigurationCategory.js +3 -2
  2. package/dist/components/configuration/ConfigurationList.js +1 -1
  3. package/dist/components/form/LocationInput.js +1 -1
  4. package/dist/components/jams/JamCapacityGate.js +1 -1
  5. package/dist/components/jams/JamConference.js +2 -0
  6. package/dist/components/jams/JamParticipantConference.js +2 -0
  7. package/dist/components/jams/JamRoom.js +2 -3
  8. package/dist/components/jams/LiveJamsSection.js +8 -2
  9. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  10. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  11. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  12. package/dist/components/jams/dropLateAudio.js +115 -0
  13. package/dist/components/jams/index.d.ts +1 -0
  14. package/dist/components/jams/index.js +1 -0
  15. package/dist/components/notifications/TypedNotification.js +46 -4
  16. package/dist/components/post/Markdown.d.ts +2 -2
  17. package/dist/components/post/Markdown.js +1 -1
  18. package/dist/components/post/attachmentPreview.js +1 -1
  19. package/dist/components/post/pieces/Attachments.js +23 -17
  20. package/dist/components/post/pieces/EventRsvpButton.js +37 -7
  21. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  22. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  23. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  24. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  25. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  26. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  27. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  28. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  29. package/dist/components/post/pieces/PostActions.js +20 -12
  30. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  31. package/dist/components/post/pieces/ShareMenu.js +40 -7
  32. package/dist/components/post/post-form/EventForm.js +10 -2
  33. package/dist/components/post/types/Article.js +1 -1
  34. package/dist/components/post/types/article/FullArticle.js +1 -1
  35. package/dist/components/post/types/event/CardEvent.js +2 -1
  36. package/dist/components/post/types/event/FullEvent.js +22 -13
  37. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  38. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  39. package/dist/components/preview-link/PreviewLink.js +1 -1
  40. package/dist/components/preview-link/helpers.d.ts +5 -0
  41. package/dist/components/preview-link/helpers.js +27 -1
  42. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  43. package/dist/components/preview-link/local/WelcomePreview.js +6 -0
  44. package/dist/components/profile/Avatar.js +2 -2
  45. package/dist/components/profile/ProfileFromId.js +1 -1
  46. package/dist/components/server-data/context.d.ts +1 -0
  47. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  48. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  49. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  50. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  51. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  52. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  53. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  54. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  55. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  56. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  57. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  58. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  59. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  60. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  61. package/dist/hooks/events/useEventForm.d.ts +1 -0
  62. package/dist/hooks/events/useEventRsvp.d.ts +11 -2
  63. package/dist/hooks/events/useEventRsvp.js +46 -5
  64. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  65. package/dist/hooks/groups/useNewGroup.js +22 -2
  66. package/dist/hooks/index.d.ts +5 -1
  67. package/dist/hooks/index.js +4 -1
  68. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  69. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  70. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  71. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  72. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  73. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  74. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  75. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  76. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  77. package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
  78. package/dist/hooks/posts/useResourceComposer.js +4 -2
  79. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  80. package/dist/hooks/posts/useShareMenu.js +7 -0
  81. package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
  82. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  83. package/dist/hooks/useWelcomePreview.d.ts +13 -0
  84. package/dist/hooks/useWelcomePreview.js +39 -0
  85. package/dist/lib/groupFormErrors.d.ts +1 -0
  86. package/dist/lib/groupFormErrors.js +5 -2
  87. package/dist/lib/threadHelpers.js +1 -5
  88. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  89. package/dist/pages/admin/Diagnostics.js +1 -1
  90. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  91. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  92. package/dist/pages/admin/Invites.js +5 -3
  93. package/dist/pages/admin/Media.d.ts +1 -0
  94. package/dist/pages/admin/Media.js +135 -0
  95. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  96. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  97. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  98. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  99. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  100. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  101. package/dist/pages/auth/Register.js +30 -8
  102. package/dist/pages/conversations/Show.js +11 -0
  103. package/dist/pages/index.d.ts +3 -0
  104. package/dist/pages/index.js +3 -0
  105. package/dist/pages/jams/Index.js +2 -4
  106. package/dist/pages/settings/PublicProfile.js +15 -3
  107. package/dist/pwa/sw.d.ts +0 -1
  108. package/dist/react-native.d.ts +1 -0
  109. package/dist/react-native.js +1 -0
  110. package/dist/stores/newPosts.d.ts +4 -2
  111. package/dist/stores/newPosts.js +6 -1
  112. package/package.json +12 -7
  113. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  114. package/src/components/configuration/ConfigurationList.tsx +6 -1
  115. package/src/components/form/LocationInput.tsx +7 -1
  116. package/src/components/jams/JamCapacityGate.tsx +1 -1
  117. package/src/components/jams/JamConference.tsx +2 -0
  118. package/src/components/jams/JamParticipantConference.tsx +2 -0
  119. package/src/components/jams/JamRoom.tsx +2 -6
  120. package/src/components/jams/LiveJamsSection.tsx +16 -2
  121. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  122. package/src/components/jams/dropLateAudio.ts +153 -0
  123. package/src/components/jams/index.ts +1 -0
  124. package/src/components/notifications/TypedNotification.tsx +81 -9
  125. package/src/components/post/Markdown.tsx +8 -2
  126. package/src/components/post/attachmentPreview.ts +1 -3
  127. package/src/components/post/pieces/Attachments.tsx +93 -78
  128. package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
  129. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  130. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  131. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  132. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  133. package/src/components/post/pieces/PostActions.tsx +73 -42
  134. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  135. package/src/components/post/post-form/EventForm.tsx +26 -0
  136. package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
  137. package/src/components/post/types/Article.tsx +1 -1
  138. package/src/components/post/types/article/FullArticle.tsx +2 -2
  139. package/src/components/post/types/event/CardEvent.tsx +26 -14
  140. package/src/components/post/types/event/FullEvent.tsx +48 -35
  141. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  142. package/src/components/post/types/note/FullNote.tsx +1 -4
  143. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  144. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  145. package/src/components/preview-link/PreviewLink.tsx +2 -7
  146. package/src/components/preview-link/helpers.ts +32 -1
  147. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  148. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  149. package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
  150. package/src/components/profile/Avatar.tsx +6 -2
  151. package/src/components/profile/ProfileFromId.tsx +1 -5
  152. package/src/components/resources/ResourceCard.tsx +0 -1
  153. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  154. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  155. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  156. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  157. package/src/css.d.ts +4 -0
  158. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  159. package/src/hooks/events/useEventRsvp.ts +51 -7
  160. package/src/hooks/groups/useNewGroup.ts +28 -3
  161. package/src/hooks/index.ts +8 -1
  162. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  163. package/src/hooks/posts/useResourceComposer.ts +8 -6
  164. package/src/hooks/posts/useShareMenu.ts +9 -0
  165. package/src/hooks/useWelcomePreview.ts +57 -0
  166. package/src/i18n/I18nProvider.tsx +1 -4
  167. package/src/lib/groupFormErrors.ts +9 -2
  168. package/src/lib/threadHelpers.ts +1 -5
  169. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  170. package/src/pages/admin/Diagnostics.tsx +4 -0
  171. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  172. package/src/pages/admin/Invites.tsx +23 -1
  173. package/src/pages/admin/Media.tsx +290 -0
  174. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  175. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  176. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  177. package/src/pages/auth/Register.tsx +33 -4
  178. package/src/pages/conversations/Show.tsx +11 -0
  179. package/src/pages/index.ts +3 -0
  180. package/src/pages/jams/Index.tsx +2 -6
  181. package/src/pages/settings/PublicProfile.tsx +20 -2
  182. package/src/pwa/sw.ts +6 -3
  183. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  184. package/src/react-native.ts +1 -0
  185. package/src/stores/newPosts.ts +6 -1
  186. package/src/streaming.ts +3 -3
  187. package/dist/setupTests.d.ts +0 -1
  188. package/dist/setupTests.js +0 -5
@@ -39,6 +39,10 @@ const adminBackupsConfig = (client: OpenpeepsClientInstance) => ({
39
39
  restoreBackupAction: payloadMutation(client.admin.backups.restore, [
40
40
  ['admin', 'backups'],
41
41
  ]),
42
+ useMediaList: () => apiHook(client.admin.media.list),
43
+ deleteMediaAction: noPayloadMutation(client.admin.media.delete, [
44
+ ['admin', 'media'],
45
+ ]),
42
46
  useConfigRead: (namespace: string, name: string) =>
43
47
  apiHook(client.admin.config.read, { pathParams: { namespace, name } }),
44
48
  updateConfigAction: payloadMutation(client.admin.config.update, [
@@ -68,14 +72,17 @@ const adminDbInvites = (client: OpenpeepsClientInstance) => ({
68
72
  ['admin', 'db', 'sql'],
69
73
  ]),
70
74
  createInviteAction: payloadMutation(client.admin.invites.create, [
71
- ['admin', 'invites'],
75
+ ['invite-links'],
72
76
  ]),
73
77
  useInvitesList: () => apiHook(client.admin.invites.list),
78
+ updateInviteAction: payloadMutation(client.admin.invites.update, [
79
+ ['invite-links'],
80
+ ]),
74
81
  activateInviteAction: noPayloadMutation(client.admin.invites.activate, [
75
- ['admin', 'invites'],
82
+ ['invite-links'],
76
83
  ]),
77
84
  deactivateInviteAction: noPayloadMutation(client.admin.invites.deactivate, [
78
- ['admin', 'invites'],
85
+ ['invite-links'],
79
86
  ]),
80
87
  useLogsList: (date?: string, refetchInterval?: number) =>
81
88
  apiHook(client.admin.logs.list, {
@@ -189,6 +196,7 @@ const adminDiagnostics = (client: OpenpeepsClientInstance) => ({
189
196
  apiHook(client.admin.diagnostics.performance, {
190
197
  refetchInterval: 15_000,
191
198
  }),
199
+ useLivekitDiagnosis: () => apiHook(client.admin.diagnostics.livekit),
192
200
  useJobDetail: (queue: string, jobId: string) =>
193
201
  apiHook(client.admin.diagnostics.jobs.jobDetail, {
194
202
  pathParams: { queue, jobId },
@@ -54,18 +54,15 @@ export const otherHooks = (client: OpenpeepsClient) => ({
54
54
  const ctrl = new AbortController();
55
55
  setController(ctrl);
56
56
  setState({ uploading: true, uploadPercent: 0 });
57
- const result = await client.mediaAttachment.createWithProgress(
58
- input,
59
- {
60
- signal: ctrl.signal,
61
- onUploadProgress: ({ percent, estimatedRemainingMs }) =>
62
- setState((s) => ({
63
- ...s,
64
- uploadPercent: percent,
65
- uploadEstimatedRemainingMs: estimatedRemainingMs,
66
- })),
67
- },
68
- );
57
+ const result = await client.mediaAttachment.createWithProgress(input, {
58
+ signal: ctrl.signal,
59
+ onUploadProgress: ({ percent, estimatedRemainingMs }) =>
60
+ setState((s) => ({
61
+ ...s,
62
+ uploadPercent: percent,
63
+ uploadEstimatedRemainingMs: estimatedRemainingMs,
64
+ })),
65
+ });
69
66
  if ('data' in result) {
70
67
  setState({
71
68
  uploading: false,
@@ -20,6 +20,6 @@ export type VodStreamStatusHook = ReturnType<
20
20
  StreamingHooks['useVodStreamStatus']
21
21
  >;
22
22
 
23
- export type CreateVodStreamAction = (
24
- input: { url: string },
25
- ) => Promise<MediaStream>;
23
+ export type CreateVodStreamAction = (input: {
24
+ url: string;
25
+ }) => Promise<MediaStream>;
package/src/css.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare module '*.css' {
2
+ const classes: Record<string, string>;
3
+ export default classes;
4
+ }
@@ -0,0 +1,27 @@
1
+ import {
2
+ adminSections,
3
+ canAccessAdminSection,
4
+ type AdminSectionKey,
5
+ } from '@openpeepshq/common/lib';
6
+ import { useCurrentProfile } from '../../components/layout/IdentityContext';
7
+
8
+ /**
9
+ * Local profile roles. Non-local profiles (e.g. remote or SAML) expose no role
10
+ * set, so every admin-section capability check resolves to false for them,
11
+ * mirroring the backend `ensureRoleCapabilities` gating.
12
+ */
13
+ export const useAdminRoles = () => {
14
+ const profile = useCurrentProfile();
15
+ return profile?.type === 'local' ? profile.roles : undefined;
16
+ };
17
+
18
+ /**
19
+ * Whether the current profile may access a given admin section. Reuses the
20
+ * shared `adminSections` definitions so Web, native, and route guards agree
21
+ * with the backend's capability checks.
22
+ */
23
+ export const useCanAccessAdminSection = (section: AdminSectionKey) => {
24
+ const roles = useAdminRoles();
25
+ const sectionDef = adminSections.find((s) => s.key === section);
26
+ return sectionDef ? canAccessAdminSection(roles, sectionDef) : false;
27
+ };
@@ -2,15 +2,16 @@ import { useMemo, useState } from 'react';
2
2
  import type { PublicPost } from '@openpeepshq/common/types';
3
3
  import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
4
4
  import {
5
+ canClaimYesRsvp,
5
6
  checkPostCapabilities,
6
- countYesRsvps,
7
7
  defaultRsvpRecurrenceId,
8
8
  displayRsvpForProfile,
9
9
  eventRsvpOpen,
10
10
  isCapacityEvent,
11
11
  isRecurringEvent,
12
12
  listRsvpOccurrences,
13
- recurringEventHasOpenOccurrence,
13
+ offerStillOpen,
14
+ seriesHasClaimableOccurrence,
14
15
  } from '@openpeepshq/common/lib';
15
16
  import { useOpenpeeps } from '../../contexts/openpeeps';
16
17
  import { useT } from '../../i18n/context';
@@ -21,7 +22,7 @@ import {
21
22
  } from '../../components/layout/IdentityContext';
22
23
  import { useCapabilities } from '../../components/server-data';
23
24
 
24
- export type RsvpChoice = 'yes' | 'tentative' | 'no';
25
+ export type RsvpChoice = 'yes' | 'tentative' | 'no' | 'waitlist';
25
26
 
26
27
  export type RsvpScopeChoice =
27
28
  | { kind: 'this'; recurrenceId: string }
@@ -52,6 +53,7 @@ export const useEventRsvp = ({
52
53
  const rsvpToEvent = openpeepsApi.rsvpToEventAction({ id: post.id });
53
54
  const [error, setError] = useState<string | null>(null);
54
55
  const [pending, setPending] = useState<RsvpChoice | null>(null);
56
+ const [confirmingWaitlist, setConfirmingWaitlist] = useState(false);
55
57
  const [submitting, setSubmitting] = useState(false);
56
58
 
57
59
  const eventData = post.data?.type === 'event' ? post.data : undefined;
@@ -71,14 +73,18 @@ export const useEventRsvp = ({
71
73
  : undefined;
72
74
  const occurrences: ExpandedOccurrence[] =
73
75
  eventData && recurring ? listRsvpOccurrences(eventData) : [];
74
- const capacityRecurrenceId = lockToOccurrence ? recurrenceId : defaultId;
76
+ const capacityRecurrenceId = recurring
77
+ ? lockToOccurrence
78
+ ? recurrenceId
79
+ : defaultId
80
+ : undefined;
75
81
  const capacityEvent = eventData ? isCapacityEvent(eventData) : false;
76
82
  const atCapacity =
77
83
  capacityEvent &&
78
- eventData?.maxAttendees !== undefined &&
84
+ !!profile &&
79
85
  (recurring && !lockToOccurrence
80
- ? !recurringEventHasOpenOccurrence(post, profile?.id)
81
- : countYesRsvps(post, capacityRecurrenceId) >= eventData.maxAttendees);
86
+ ? !seriesHasClaimableOccurrence(post, profile.id)
87
+ : !canClaimYesRsvp(post, profile.id, capacityRecurrenceId));
82
88
 
83
89
  const myEvent = post.profile?.id === profile?.id;
84
90
  const myRsvp = useMemo(
@@ -98,6 +104,9 @@ export const useEventRsvp = ({
98
104
  [authData, post, capabilities],
99
105
  );
100
106
  const full = atCapacity && myRsvp?.response !== 'yes';
107
+ const onWaitlist = myRsvp?.response === 'waitlist';
108
+ const offerExpiresAt =
109
+ onWaitlist && offerStillOpen(myRsvp) ? myRsvp.offerExpiresAt : undefined;
101
110
 
102
111
  const writeRsvp = async (response: RsvpChoice, recurrenceIds?: string[]) => {
103
112
  setError(null);
@@ -121,6 +130,34 @@ export const useEventRsvp = ({
121
130
  }
122
131
  };
123
132
 
133
+ const requestJoinWaitlist = () => {
134
+ if (rsvpClosed) return;
135
+ if (!recurring || lockToOccurrence) {
136
+ setError(null);
137
+ setConfirmingWaitlist(true);
138
+ return;
139
+ }
140
+ setError(null);
141
+ setPending('waitlist');
142
+ };
143
+
144
+ const confirmJoinWaitlist = async () => {
145
+ try {
146
+ await writeRsvp('waitlist', recurrenceId ? [recurrenceId] : undefined);
147
+ setConfirmingWaitlist(false);
148
+ return true;
149
+ } catch {
150
+ return false;
151
+ }
152
+ };
153
+
154
+ const claimSpot = () => {
155
+ const id = recurring
156
+ ? (myRsvp?.recurrenceId ?? (lockToOccurrence ? recurrenceId : defaultId))
157
+ : undefined;
158
+ writeRsvp('yes', id ? [id] : undefined).catch(() => undefined);
159
+ };
160
+
124
161
  const requestRespond = (response: RsvpChoice) => {
125
162
  if (rsvpClosed) return;
126
163
  if (!recurring || lockToOccurrence) {
@@ -161,11 +198,18 @@ export const useEventRsvp = ({
161
198
  occurrences,
162
199
  capacityEvent,
163
200
  full,
201
+ onWaitlist,
202
+ offerExpiresAt,
164
203
  error,
165
204
  pending,
166
205
  setPending,
206
+ confirmingWaitlist,
207
+ setConfirmingWaitlist,
167
208
  submitting,
168
209
  requestRespond,
210
+ requestJoinWaitlist,
211
+ confirmJoinWaitlist,
212
+ claimSpot,
169
213
  confirmScope,
170
214
  };
171
215
  };
@@ -1,5 +1,10 @@
1
1
  import { useState } from 'react';
2
- import type { GroupData, PublicProfile } from '@openpeepshq/common/types';
2
+ import {
3
+ HANDLE_RESERVED_MESSAGE,
4
+ isForbiddenHandle,
5
+ type GroupData,
6
+ type PublicProfile,
7
+ } from '@openpeepshq/common/types';
3
8
  import {
4
9
  applySimpleGroupTemplate,
5
10
  defaultSimpleGroupTemplate,
@@ -30,7 +35,10 @@ export const useNewGroup = () => {
30
35
  const navigate = useNavigate();
31
36
  const { openpeepsApi } = useOpenpeeps();
32
37
  const createGroup = openpeepsApi.createGroupAction();
33
- const { publicContent } = useServerInfo();
38
+ const serverInfo = useServerInfo();
39
+ const { publicContent } = serverInfo;
40
+ const additionalForbiddenHandles =
41
+ serverInfo.communityConfig?.settings?.additionalForbiddenHandles;
34
42
  const [members, setMembers] = useState<PublicProfile[]>([]);
35
43
  const [groupData, setGroupData] = useState<GroupData>(() => ({
36
44
  displayName: '',
@@ -47,7 +55,9 @@ export const useNewGroup = () => {
47
55
 
48
56
  const submit = async () => {
49
57
  setError(null);
50
- const nextFieldErrors = groupFormFieldErrors(groupData, t);
58
+ const nextFieldErrors = groupFormFieldErrors(groupData, t, {
59
+ additionalForbiddenHandles,
60
+ });
51
61
  if (hasGroupFormFieldErrors(nextFieldErrors)) {
52
62
  setFieldErrors(nextFieldErrors);
53
63
  return;
@@ -60,6 +70,13 @@ export const useNewGroup = () => {
60
70
  handle: handleFromDisplayName(groupData.displayName!),
61
71
  }
62
72
  : groupData;
73
+ if (isForbiddenHandle(data.handle, additionalForbiddenHandles)) {
74
+ const msg = t('profile.form.handleReserved', {
75
+ defaultValue: 'That handle is reserved. Please choose another.',
76
+ });
77
+ setFieldErrors({ handle: msg });
78
+ return;
79
+ }
63
80
  setSubmitting(true);
64
81
  try {
65
82
  const group = (await createGroup({ ...data, members })) as {
@@ -67,6 +84,14 @@ export const useNewGroup = () => {
67
84
  };
68
85
  navigate({ type: 'group', handle: group.handle });
69
86
  } catch (err) {
87
+ if ((err as Error).message === HANDLE_RESERVED_MESSAGE) {
88
+ const msg = t('profile.form.handleReserved', {
89
+ defaultValue: 'That handle is reserved. Please choose another.',
90
+ });
91
+ setFieldErrors({ handle: msg });
92
+ setError(msg);
93
+ return;
94
+ }
70
95
  if (isDuplicateHandleError(err)) {
71
96
  const msg = duplicateHandleMessage(t);
72
97
  setFieldErrors({ handle: msg });
@@ -2,6 +2,7 @@ export { useJoinGroup } from './groups/useJoinGroup';
2
2
  export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel';
3
3
  export { useCreateConversation } from './conversations/useCreateConversation';
4
4
  export type { UseCreateConversationArgs } from './conversations/useCreateConversation';
5
+ export { useCanDiagnoseLivekit } from './jams/useCanDiagnoseLivekit';
5
6
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam';
6
7
  export type { UseLeaveCloseJamArgs } from './jams/useLeaveCloseJam';
7
8
  export { useCreateNewJamForm } from './jams/useCreateNewJamForm';
@@ -94,7 +95,7 @@ export { useCommunityInfoPages } from './community/useCommunityInfoPages';
94
95
  export { usePostThreads } from './posts/usePostThreads';
95
96
  export { usePostDetailTitle } from './posts/usePostDetailTitle';
96
97
  export { useEventMenu } from './events/useEventMenu';
97
- export { useShareMenu } from './posts/useShareMenu';
98
+ export { postPublicPath, useShareMenu } from './posts/useShareMenu';
98
99
  export type { EventIcsFile } from './posts/useShareMenu';
99
100
  export { useNewEvent, useEditEvent } from './events/useEventComposer';
100
101
  export { EVENT_WEEKDAYS, useEventForm } from './events/useEventForm';
@@ -107,3 +108,9 @@ export type {
107
108
  EventFormat,
108
109
  UseEventTypeSwitcherArgs,
109
110
  } from './events/useEventTypeSwitcher';
111
+ export {
112
+ useAdminRoles,
113
+ useCanAccessAdminSection,
114
+ } from './admin/useCanAccessAdminSection';
115
+ export { useWelcomePreview } from './useWelcomePreview';
116
+ export type { WelcomePreviewContent } from './useWelcomePreview';
@@ -0,0 +1,5 @@
1
+ import { useCanAccessAdminSection } from '../admin/useCanAccessAdminSection';
2
+
3
+ /** Admins who can open Diagnostics can see why LiveKit failed. */
4
+ export const useCanDiagnoseLivekit = () =>
5
+ useCanAccessAdminSection('diagnostics');
@@ -14,8 +14,8 @@ import { useT } from '../../i18n/context';
14
14
  import { useServerInfo } from '../../components/server-data';
15
15
  import { defaultNewResource, getNewPostStores } from '../../stores';
16
16
 
17
- const asResource = (data: PostDataUnion): ResourcePost | null =>
18
- data.type === 'resource' ? data : null;
17
+ const asResource = (data: PostDataUnion | undefined): ResourcePost | null =>
18
+ data?.type === 'resource' ? data : null;
19
19
 
20
20
  const preparedResource = (resource: ResourcePost): ResourcePost => ({
21
21
  ...resource,
@@ -121,7 +121,11 @@ export const useEditResource = (resourceId: string) => {
121
121
  const [error, setError] = useState<string | null>(null);
122
122
 
123
123
  useEffect(() => {
124
- if (postQuery.data && postQuery.data.type === 'resource') {
124
+ if (
125
+ postQuery.data &&
126
+ postQuery.data.type === 'resource' &&
127
+ postQuery.data.data
128
+ ) {
125
129
  setPostData({
126
130
  visibility: postQuery.data.visibility,
127
131
  type: 'resource',
@@ -132,9 +136,7 @@ export const useEditResource = (resourceId: string) => {
132
136
  }
133
137
  }, [postQuery.data]);
134
138
 
135
- const resourceTitle = asResource(
136
- postQuery.data?.data as PostDataUnion,
137
- )?.title;
139
+ const resourceTitle = asResource(postQuery.data?.data)?.title;
138
140
 
139
141
  const submit = useCallback(async () => {
140
142
  if (!postData) return;
@@ -5,6 +5,15 @@ import { useCurrentProfile } from '../../components/layout/IdentityContext';
5
5
 
6
6
  export type EventIcsFile = { filename: string; content: string };
7
7
 
8
+ /** Canonical public path for a post, including a recurring event occurrence. */
9
+ export const postPublicPath = (
10
+ post: Pick<PublicPost, 'id' | 'occurrenceRecurrenceId'>,
11
+ ) => {
12
+ const occurrence = post.occurrenceRecurrenceId;
13
+ if (!occurrence) return `/posts/${post.id}`;
14
+ return `/posts/${post.id}?occurrence=${encodeURIComponent(occurrence)}`;
15
+ };
16
+
8
17
  /** Share actions for a post; `postUrl` is the platform's canonical public link. */
9
18
  export const useShareMenu = (post: PublicPost, postUrl: string) => {
10
19
  const me = useCurrentProfile();
@@ -0,0 +1,57 @@
1
+ import { getTheme } from '@openpeepshq/common';
2
+ import { useCurrentProfileSettings } from '../components/layout/IdentityContext';
3
+ import {
4
+ firstMarkdownImage,
5
+ welcomePreviewExcerpt,
6
+ } from '../components/preview-link/helpers';
7
+ import { useServerInfo } from '../components/server-data/context';
8
+ import { useT } from '../i18n/context';
9
+
10
+ export type WelcomePreviewContent = {
11
+ /** Short label above the title. Omitted when it would repeat the title. */
12
+ eyebrow?: string;
13
+ title: string;
14
+ description: string;
15
+ imageUrl?: string;
16
+ imageFit: 'cover' | 'contain';
17
+ };
18
+
19
+ /**
20
+ * Shared welcome-link card. Native passes the device color scheme because
21
+ * `getTheme` cannot read it from `window` there.
22
+ */
23
+ export const useWelcomePreview = (
24
+ systemScheme?: 'dark' | 'light',
25
+ ): WelcomePreviewContent => {
26
+ const t = useT();
27
+ const serverInfo = useServerInfo();
28
+ const profileSettings = useCurrentProfileSettings();
29
+ const config = serverInfo.communityConfig;
30
+ const configured = config.content.welcomePage?.trim() ?? '';
31
+ const markdownImage = firstMarkdownImage(configured);
32
+ const logo = (
33
+ systemScheme
34
+ ? getTheme(config, profileSettings, systemScheme)
35
+ : getTheme(config, profileSettings)
36
+ ).logoSmall;
37
+ const label = t('welcome.previewLabel', { defaultValue: 'Welcome page' });
38
+ const name = config.info.name.trim();
39
+ const title = name
40
+ ? t('welcome.heading', {
41
+ name,
42
+ defaultValue: 'Welcome to {{name}}',
43
+ })
44
+ : label;
45
+
46
+ return {
47
+ eyebrow: title === label ? undefined : label,
48
+ title,
49
+ description: configured
50
+ ? welcomePreviewExcerpt(configured)
51
+ : t('welcome.defaultIntro', {
52
+ defaultValue: 'Welcome to this community, hosted on AllPeep.',
53
+ }),
54
+ imageUrl: markdownImage || logo || undefined,
55
+ imageFit: markdownImage ? 'cover' : 'contain',
56
+ };
57
+ };
@@ -52,10 +52,7 @@ export function I18nProvider({
52
52
  };
53
53
  }, [i18n, lang]);
54
54
 
55
- const value = useMemo(
56
- () => ({ i18n, t: i18n.t.bind(i18n) }),
57
- [i18n, lng],
58
- );
55
+ const value = useMemo(() => ({ i18n, t: i18n.t.bind(i18n) }), [i18n, lng]);
59
56
 
60
57
  if (!ready) return <>{fallback}</>;
61
58
 
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  accountNameSchema,
3
3
  GROUP_DISPLAY_NAME_MAX_LENGTH,
4
+ HANDLE_RESERVED_MESSAGE,
5
+ isForbiddenHandle,
4
6
  } from '@openpeepshq/common/types';
5
7
  import type { TFunction } from 'i18next';
6
8
 
@@ -19,7 +21,7 @@ const displayNameMaxLengthMessage = (t: TFunction) =>
19
21
  });
20
22
 
21
23
  const handleErrorMessage = (issue: string | undefined, t: TFunction) =>
22
- issue === 'Handle is reserved'
24
+ issue === HANDLE_RESERVED_MESSAGE
23
25
  ? t('profile.form.handleReserved', {
24
26
  defaultValue: 'That handle is reserved. Please choose another.',
25
27
  })
@@ -31,7 +33,10 @@ const handleErrorMessage = (issue: string | undefined, t: TFunction) =>
31
33
  export const groupFormFieldErrors = (
32
34
  data: { displayName?: string; handle?: string },
33
35
  t: TFunction,
34
- options?: { skipHandle?: boolean },
36
+ options?: {
37
+ skipHandle?: boolean;
38
+ additionalForbiddenHandles?: readonly string[];
39
+ },
35
40
  ): GroupFormFieldErrors => {
36
41
  const errors: GroupFormFieldErrors = {};
37
42
  const displayName = data.displayName ?? '';
@@ -49,6 +54,8 @@ export const groupFormFieldErrors = (
49
54
  const result = accountNameSchema.safeParse(handle);
50
55
  if (!result.success) {
51
56
  errors.handle = handleErrorMessage(result.error.issues[0]?.message, t);
57
+ } else if (isForbiddenHandle(handle, options?.additionalForbiddenHandles)) {
58
+ errors.handle = handleErrorMessage(HANDLE_RESERVED_MESSAGE, t);
52
59
  }
53
60
  } else if (!displayName && !errors.displayName) {
54
61
  errors.displayName = t('handle.validation.error', {
@@ -22,9 +22,5 @@ export const collectPath = (
22
22
  currentPath: PublicPost[] = [],
23
23
  ): PublicPost[] => {
24
24
  if (!thread) return currentPath;
25
- return [
26
- ...currentPath,
27
- thread,
28
- ...collectPath(thread.children[0]),
29
- ];
25
+ return [...currentPath, thread, ...collectPath(thread.children[0])];
30
26
  };
@@ -42,6 +42,11 @@ export function AdminConfigurationCommunity() {
42
42
  translationPrefix="configuration.community.profileFields"
43
43
  action="/admin/configuration/community/profile-fields"
44
44
  />
45
+ <ConfigMenuButton
46
+ translationPrefix="configuration.community.forbiddenUsernames"
47
+ action="/admin/configuration/community/forbidden-usernames"
48
+ testId="admin-community-forbidden-usernames"
49
+ />
45
50
  <ConfigMenuButton
46
51
  translationPrefix="configuration.community.roles"
47
52
  action="/admin/configuration/community/roles"
@@ -12,6 +12,10 @@ export function AdminDiagnostics() {
12
12
  translationPrefix="diagnostics.email"
13
13
  action="/admin/diagnostics/email"
14
14
  />
15
+ <ConfigMenuButton
16
+ translationPrefix="diagnostics.livekit"
17
+ action="/admin/diagnostics/livekit"
18
+ />
15
19
  <ConfigMenuButton
16
20
  translationPrefix="diagnostics.logs"
17
21
  action="/admin/diagnostics/logs"