@openpeepshq/react 0.7.0 → 0.8.0

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 (251) 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/markdown/compileMarkdown.js +1 -0
  16. package/dist/components/navigation/FooterMobile.js +4 -3
  17. package/dist/components/navigation/HeaderMobile.js +5 -2
  18. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  19. package/dist/components/navigation/MobileMenuItem.js +7 -2
  20. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  21. package/dist/components/navigation/NavWithTooltip.js +4 -0
  22. package/dist/components/navigation/index.d.ts +2 -0
  23. package/dist/components/navigation/index.js +1 -0
  24. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  25. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  26. package/dist/components/notifications/TypedNotification.js +46 -4
  27. package/dist/components/post/CompactReplyParent.js +5 -6
  28. package/dist/components/post/Markdown.d.ts +2 -2
  29. package/dist/components/post/Markdown.js +1 -1
  30. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  31. package/dist/components/post/TruncatedMarkdown.js +37 -0
  32. package/dist/components/post/attachmentPreview.js +1 -1
  33. package/dist/components/post/helpers.d.ts +2 -2
  34. package/dist/components/post/helpers.js +3 -16
  35. package/dist/components/post/index.d.ts +2 -0
  36. package/dist/components/post/index.js +1 -0
  37. package/dist/components/post/pieces/Attachments.js +23 -17
  38. package/dist/components/post/pieces/EventLocation.js +14 -0
  39. package/dist/components/post/pieces/EventRsvpButton.js +39 -7
  40. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  41. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  42. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  43. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  44. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  45. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  46. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  47. package/dist/components/post/pieces/PollContent.js +8 -2
  48. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  49. package/dist/components/post/pieces/PostActions.js +20 -12
  50. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  51. package/dist/components/post/pieces/ShareMenu.js +40 -7
  52. package/dist/components/post/post-form/ArticleForm.js +1 -1
  53. package/dist/components/post/post-form/EventForm.js +33 -5
  54. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  55. package/dist/components/post/post-form/ResourceForm.js +48 -7
  56. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  57. package/dist/components/post/types/Article.js +2 -3
  58. package/dist/components/post/types/Event.js +10 -1
  59. package/dist/components/post/types/article/FullArticle.js +1 -1
  60. package/dist/components/post/types/event/CardEvent.js +2 -1
  61. package/dist/components/post/types/event/FullEvent.js +22 -13
  62. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  63. package/dist/components/post/types/resource/FullResource.js +3 -3
  64. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  65. package/dist/components/preview-link/PreviewLink.js +1 -1
  66. package/dist/components/preview-link/helpers.d.ts +5 -0
  67. package/dist/components/preview-link/helpers.js +27 -1
  68. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  69. package/dist/components/preview-link/local/WelcomePreview.js +8 -0
  70. package/dist/components/profile/Avatar.js +2 -2
  71. package/dist/components/profile/ProfileFromId.js +1 -1
  72. package/dist/components/resources/ResourceCard.d.ts +5 -1
  73. package/dist/components/resources/ResourceCard.js +29 -5
  74. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  75. package/dist/components/resources/ResourceCard.test.js +75 -0
  76. package/dist/components/resources/ResourceLibrary.js +1 -1
  77. package/dist/components/server-data/context.d.ts +1 -0
  78. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  79. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  80. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  81. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  82. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  83. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  84. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  85. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  86. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  87. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  88. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  89. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  90. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  91. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  92. package/dist/hooks/events/useEventForm.d.ts +1 -0
  93. package/dist/hooks/events/useEventRsvp.d.ts +12 -2
  94. package/dist/hooks/events/useEventRsvp.js +59 -10
  95. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  96. package/dist/hooks/groups/useNewGroup.js +22 -2
  97. package/dist/hooks/index.d.ts +5 -1
  98. package/dist/hooks/index.js +4 -1
  99. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  100. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  101. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  102. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  103. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  104. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  105. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  106. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  107. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  108. package/dist/hooks/posts/useResourceComposer.d.ts +95 -41
  109. package/dist/hooks/posts/useResourceComposer.js +135 -27
  110. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  111. package/dist/hooks/posts/useShareMenu.js +7 -0
  112. package/dist/hooks/resources/useResourceLibrary.d.ts +177 -79
  113. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  114. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  115. package/dist/hooks/useWelcomePreview.d.ts +16 -0
  116. package/dist/hooks/useWelcomePreview.js +40 -0
  117. package/dist/lib/groupFormErrors.d.ts +1 -0
  118. package/dist/lib/groupFormErrors.js +5 -2
  119. package/dist/lib/threadHelpers.js +1 -5
  120. package/dist/navigation/menuItems.js +15 -0
  121. package/dist/navigation/targets.d.ts +2 -0
  122. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  123. package/dist/pages/admin/Diagnostics.js +1 -1
  124. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  125. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  126. package/dist/pages/admin/Invites.js +5 -3
  127. package/dist/pages/admin/Media.d.ts +1 -0
  128. package/dist/pages/admin/Media.js +135 -0
  129. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  130. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  131. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  132. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  133. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  134. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  135. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  136. package/dist/pages/auth/Register.js +33 -9
  137. package/dist/pages/conversations/Show.js +11 -0
  138. package/dist/pages/index.d.ts +3 -0
  139. package/dist/pages/index.js +3 -0
  140. package/dist/pages/jams/Index.js +2 -4
  141. package/dist/pages/resources/Edit.js +3 -3
  142. package/dist/pages/resources/New.js +2 -2
  143. package/dist/pages/settings/Account.js +30 -2
  144. package/dist/pages/settings/PublicProfile.js +15 -3
  145. package/dist/pwa/sw.d.ts +0 -1
  146. package/dist/react-native.d.ts +1 -0
  147. package/dist/react-native.js +1 -0
  148. package/dist/stores/newPosts.d.ts +4 -2
  149. package/dist/stores/newPosts.js +6 -1
  150. package/package.json +12 -7
  151. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  152. package/src/components/configuration/ConfigurationList.tsx +6 -1
  153. package/src/components/form/LocationInput.tsx +7 -1
  154. package/src/components/jams/JamCapacityGate.tsx +1 -1
  155. package/src/components/jams/JamConference.tsx +2 -0
  156. package/src/components/jams/JamParticipantConference.tsx +2 -0
  157. package/src/components/jams/JamRoom.tsx +2 -6
  158. package/src/components/jams/LiveJamsSection.tsx +16 -2
  159. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  160. package/src/components/jams/dropLateAudio.ts +153 -0
  161. package/src/components/jams/index.ts +1 -0
  162. package/src/components/markdown/compileMarkdown.ts +1 -0
  163. package/src/components/navigation/FooterMobile.tsx +41 -33
  164. package/src/components/navigation/HeaderMobile.tsx +55 -41
  165. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  166. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  167. package/src/components/navigation/index.ts +2 -0
  168. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  169. package/src/components/notifications/TypedNotification.tsx +81 -9
  170. package/src/components/post/CompactReplyParent.tsx +17 -10
  171. package/src/components/post/Markdown.tsx +8 -2
  172. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  173. package/src/components/post/attachmentPreview.ts +1 -3
  174. package/src/components/post/helpers.ts +4 -18
  175. package/src/components/post/index.ts +2 -0
  176. package/src/components/post/pieces/Attachments.tsx +93 -78
  177. package/src/components/post/pieces/EventLocation.tsx +27 -0
  178. package/src/components/post/pieces/EventRsvpButton.tsx +110 -7
  179. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  180. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  181. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  182. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  183. package/src/components/post/pieces/PollContent.tsx +8 -2
  184. package/src/components/post/pieces/PostActions.tsx +73 -42
  185. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  186. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  187. package/src/components/post/post-form/EventForm.tsx +69 -15
  188. package/src/components/post/post-form/ResourceForm.tsx +132 -4
  189. package/src/components/post/post-form/VisibilitySelector.tsx +12 -5
  190. package/src/components/post/types/Article.tsx +6 -6
  191. package/src/components/post/types/Event.tsx +68 -7
  192. package/src/components/post/types/article/FullArticle.tsx +2 -2
  193. package/src/components/post/types/event/CardEvent.tsx +26 -14
  194. package/src/components/post/types/event/FullEvent.tsx +48 -35
  195. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  196. package/src/components/post/types/note/FullNote.tsx +1 -4
  197. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  198. package/src/components/post/types/resource/FullResource.tsx +9 -1
  199. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  200. package/src/components/preview-link/PreviewLink.tsx +2 -7
  201. package/src/components/preview-link/helpers.ts +32 -1
  202. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  203. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  204. package/src/components/preview-link/local/WelcomePreview.tsx +45 -0
  205. package/src/components/profile/Avatar.tsx +6 -2
  206. package/src/components/profile/ProfileFromId.tsx +1 -5
  207. package/src/components/resources/ResourceCard.tsx +68 -11
  208. package/src/components/resources/ResourceLibrary.tsx +2 -2
  209. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  210. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  211. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  212. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  213. package/src/css.d.ts +4 -0
  214. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  215. package/src/hooks/events/useEventRsvp.ts +69 -13
  216. package/src/hooks/groups/useNewGroup.ts +28 -3
  217. package/src/hooks/index.ts +8 -1
  218. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  219. package/src/hooks/posts/useResourceComposer.ts +165 -39
  220. package/src/hooks/posts/useShareMenu.ts +9 -0
  221. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  222. package/src/hooks/useWelcomePreview.ts +61 -0
  223. package/src/i18n/I18nProvider.tsx +1 -4
  224. package/src/lib/groupFormErrors.ts +9 -2
  225. package/src/lib/threadHelpers.ts +1 -5
  226. package/src/navigation/menuItems.ts +16 -0
  227. package/src/navigation/targets.ts +2 -0
  228. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  229. package/src/pages/admin/Diagnostics.tsx +4 -0
  230. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  231. package/src/pages/admin/Invites.tsx +23 -1
  232. package/src/pages/admin/Media.tsx +290 -0
  233. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  234. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  235. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  236. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  237. package/src/pages/auth/Register.tsx +45 -4
  238. package/src/pages/conversations/Show.tsx +11 -0
  239. package/src/pages/index.ts +3 -0
  240. package/src/pages/jams/Index.tsx +2 -6
  241. package/src/pages/resources/Edit.tsx +3 -2
  242. package/src/pages/resources/New.tsx +6 -1
  243. package/src/pages/settings/Account.tsx +51 -1
  244. package/src/pages/settings/PublicProfile.tsx +20 -2
  245. package/src/pwa/sw.ts +6 -3
  246. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  247. package/src/react-native.ts +1 -0
  248. package/src/stores/newPosts.ts +6 -1
  249. package/src/streaming.ts +3 -3
  250. package/dist/setupTests.d.ts +0 -1
  251. package/dist/setupTests.js +0 -5
@@ -2,12 +2,16 @@ import { useMemo, useState } from 'react';
2
2
  import { categoryTreeFromPaths, normalizeResourceTags, pathStartsWith, } from '@openpeepshq/common/lib';
3
3
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
4
4
  import { useFeedListParams } from '../useResolvedFeedFormat.js';
5
- export const useResourceLibrary = (groupId) => {
5
+ export const useResourceLibrary = (groupId, ungrouped) => {
6
6
  const { openpeepsApi } = useOpenpeeps();
7
7
  const params = useFeedListParams({ format: 'linear' });
8
8
  const query = openpeepsApi.usePostsByType('resource', {
9
9
  ...params,
10
- ...(groupId ? { groupId } : { ungrouped: 'true' }),
10
+ ...(groupId
11
+ ? { groupId }
12
+ : ungrouped
13
+ ? { ungrouped: 'true' }
14
+ : {}),
11
15
  });
12
16
  const bookmarkedIds = openpeepsApi.useCurrentProfileBookmarkedIds();
13
17
  const [search, setSearch] = useState('');
@@ -7,7 +7,7 @@ export declare const useNotificationPreferences: ({ ensurePush, }?: UseNotificat
7
7
  me: import("@openpeepshq/common").ProfileWithMeta | undefined;
8
8
  types: {
9
9
  type: string;
10
- requiredCapabilities?: ("core-posts-delete" | "core-groups-read" | "core-groups-delete" | "core-groups-addMember" | "core-groups-removeMember" | "core-groups-changeMemberRole" | "core-profiles-read" | "core-profiles-update" | "core-profiles-delete" | "core-reports-create" | "core-serviceTokens-create" | "core-serviceTokens-read" | "core-serviceTokens-delete" | "core-local" | "core-accounts-read" | "core-accounts-create" | "core-accounts-update" | "core-accounts-delete" | "core-reports-update" | "core-groups-create" | "core-posts-create-note-local" | "core-posts-create-note-public" | "core-posts-create-note-direct" | "core-posts-create-note-private" | "core-posts-create-event-local" | "core-posts-create-event-public" | "core-posts-create-event-direct" | "core-posts-create-event-private" | "core-posts-create-poll-local" | "core-posts-create-poll-public" | "core-posts-create-poll-direct" | "core-posts-create-poll-private" | "core-posts-create-article-local" | "core-posts-create-article-public" | "core-posts-create-article-direct" | "core-posts-create-article-private" | "core-posts-create-resource-local" | "core-posts-create-resource-public" | "core-posts-create-resource-direct" | "core-posts-create-resource-private" | "core-posts-read-local" | "core-posts-announce" | "core-profiles-roles-update" | "core-profiles-suspend" | "core-profiles-impersonate" | "core-analytics-read" | "core-config-update" | "core-config-read" | "core-customization-read" | "core-customization-update" | "core-capabilities-read" | "core-capabilities-update" | "core-backups-create" | "core-backups-read" | "core-backups-download" | "core-backups-restore" | "core-db-access" | "core-i18n-update" | "core-logs-read" | "core-roles-read" | "core-roles-update" | "core-maintenance-restart" | "core-inviteLinks-create" | "core-inviteLinks-read" | "core-inviteLinks-update" | "core-inviteLinks-delete" | "core-serviceTokens-update" | "core-plugins-manage")[] | undefined;
10
+ requiredCapabilities?: ("core-posts-delete" | "core-groups-read" | "core-groups-delete" | "core-groups-addMember" | "core-groups-removeMember" | "core-groups-changeMemberRole" | "core-profiles-read" | "core-profiles-update" | "core-profiles-delete" | "core-reports-create" | "core-serviceTokens-create" | "core-serviceTokens-read" | "core-serviceTokens-delete" | "core-local" | "core-accounts-read" | "core-accounts-create" | "core-accounts-update" | "core-accounts-delete" | "core-reports-update" | "core-groups-create" | "core-posts-create-note-local" | "core-posts-create-note-public" | "core-posts-create-note-direct" | "core-posts-create-note-private" | "core-posts-create-event-local" | "core-posts-create-event-public" | "core-posts-create-event-direct" | "core-posts-create-event-private" | "core-posts-create-poll-local" | "core-posts-create-poll-public" | "core-posts-create-poll-direct" | "core-posts-create-poll-private" | "core-posts-create-article-local" | "core-posts-create-article-public" | "core-posts-create-article-direct" | "core-posts-create-article-private" | "core-posts-create-resource-local" | "core-posts-create-resource-public" | "core-posts-create-resource-direct" | "core-posts-create-resource-private" | "core-posts-read-local" | "core-posts-announce" | "core-profiles-roles-update" | "core-profiles-suspend" | "core-profiles-impersonate" | "core-analytics-read" | "core-config-update" | "core-config-read" | "core-customization-read" | "core-customization-update" | "core-capabilities-read" | "core-capabilities-update" | "core-backups-create" | "core-backups-read" | "core-backups-download" | "core-backups-restore" | "core-db-access" | "core-i18n-update" | "core-logs-read" | "core-roles-read" | "core-roles-update" | "core-maintenance-restart" | "core-media-read" | "core-media-delete" | "core-inviteLinks-create" | "core-inviteLinks-read" | "core-inviteLinks-update" | "core-inviteLinks-delete" | "core-serviceTokens-update" | "core-plugins-manage")[] | undefined;
11
11
  defaultSettings?: {
12
12
  create: boolean;
13
13
  push: boolean;
@@ -0,0 +1,16 @@
1
+ export type WelcomePreviewContent = {
2
+ /** Short label above the title. Omitted when it would repeat the title. */
3
+ eyebrow?: string;
4
+ title: string;
5
+ /** Plain-text excerpt (image-stripped) for non-markdown consumers / fallback. */
6
+ description: string;
7
+ /** Raw welcome markdown (image-bearing) for markdown rendering + overlays. */
8
+ markdown: string;
9
+ imageUrl?: string;
10
+ imageFit: 'cover' | 'contain';
11
+ };
12
+ /**
13
+ * Shared welcome-link card. Native passes the device color scheme because
14
+ * `getTheme` cannot read it from `window` there.
15
+ */
16
+ export declare const useWelcomePreview: (systemScheme?: "dark" | "light") => WelcomePreviewContent;
@@ -0,0 +1,40 @@
1
+ import { getTheme } from '@openpeepshq/common';
2
+ import { useCurrentProfileSettings } from '../components/layout/IdentityContext.js';
3
+ import { firstMarkdownImage, welcomePreviewExcerpt, } from '../components/preview-link/helpers.js';
4
+ import { useServerInfo } from '../components/server-data/context.js';
5
+ import { useT } from '../i18n/context.js';
6
+ /**
7
+ * Shared welcome-link card. Native passes the device color scheme because
8
+ * `getTheme` cannot read it from `window` there.
9
+ */
10
+ export const useWelcomePreview = (systemScheme) => {
11
+ const t = useT();
12
+ const serverInfo = useServerInfo();
13
+ const profileSettings = useCurrentProfileSettings();
14
+ const config = serverInfo.communityConfig;
15
+ const configured = config.content.welcomePage?.trim() ?? '';
16
+ const markdownImage = firstMarkdownImage(configured);
17
+ const logo = (systemScheme
18
+ ? getTheme(config, profileSettings, systemScheme)
19
+ : getTheme(config, profileSettings)).logoSmall;
20
+ const label = t('welcome.previewLabel', { defaultValue: 'Welcome page' });
21
+ const name = config.info.name.trim();
22
+ const title = name
23
+ ? t('welcome.heading', {
24
+ name,
25
+ defaultValue: 'Welcome to {{name}}',
26
+ })
27
+ : label;
28
+ return {
29
+ eyebrow: title === label ? undefined : label,
30
+ title,
31
+ description: configured
32
+ ? welcomePreviewExcerpt(configured)
33
+ : t('welcome.defaultIntro', {
34
+ defaultValue: 'Welcome to this community, hosted on AllPeep.',
35
+ }),
36
+ markdown: configured,
37
+ imageUrl: markdownImage || logo || undefined,
38
+ imageFit: markdownImage ? 'cover' : 'contain',
39
+ };
40
+ };
@@ -9,6 +9,7 @@ export declare const groupFormFieldErrors: (data: {
9
9
  handle?: string;
10
10
  }, t: TFunction, options?: {
11
11
  skipHandle?: boolean;
12
+ additionalForbiddenHandles?: readonly string[];
12
13
  }) => GroupFormFieldErrors;
13
14
  /** Server conflict when a group/profile handle is already taken. */
14
15
  export declare const isDuplicateHandleError: (err: unknown) => boolean;
@@ -1,10 +1,10 @@
1
- import { accountNameSchema, GROUP_DISPLAY_NAME_MAX_LENGTH, } from '@openpeepshq/common/types';
1
+ import { accountNameSchema, GROUP_DISPLAY_NAME_MAX_LENGTH, HANDLE_RESERVED_MESSAGE, isForbiddenHandle, } from '@openpeepshq/common/types';
2
2
  export const hasGroupFormFieldErrors = (errors) => Boolean(errors.displayName || errors.handle);
3
3
  const displayNameMaxLengthMessage = (t) => t('groups.form.displayNameMaxLength', {
4
4
  defaultValue: `Group name should be ${GROUP_DISPLAY_NAME_MAX_LENGTH} characters or fewer`,
5
5
  max: GROUP_DISPLAY_NAME_MAX_LENGTH,
6
6
  });
7
- const handleErrorMessage = (issue, t) => issue === 'Handle is reserved'
7
+ const handleErrorMessage = (issue, t) => issue === HANDLE_RESERVED_MESSAGE
8
8
  ? t('profile.form.handleReserved', {
9
9
  defaultValue: 'That handle is reserved. Please choose another.',
10
10
  })
@@ -26,6 +26,9 @@ export const groupFormFieldErrors = (data, t, options) => {
26
26
  if (!result.success) {
27
27
  errors.handle = handleErrorMessage(result.error.issues[0]?.message, t);
28
28
  }
29
+ else if (isForbiddenHandle(handle, options?.additionalForbiddenHandles)) {
30
+ errors.handle = handleErrorMessage(HANDLE_RESERVED_MESSAGE, t);
31
+ }
29
32
  }
30
33
  else if (!displayName && !errors.displayName) {
31
34
  errors.displayName = t('handle.validation.error', {
@@ -15,9 +15,5 @@ export const lastLongestPathSelector = (thread) => {
15
15
  export const collectPath = (thread, currentPath = []) => {
16
16
  if (!thread)
17
17
  return currentPath;
18
- return [
19
- ...currentPath,
20
- thread,
21
- ...collectPath(thread.children[0]),
22
- ];
18
+ return [...currentPath, thread, ...collectPath(thread.children[0])];
23
19
  };
@@ -1,3 +1,4 @@
1
+ const navTooltip = (id) => `navigation.tooltips.${id}`;
1
2
  /** Default main-menu targets for hosts to render with their own icons/labels. */
2
3
  export const buildMainNavItems = (caps) => {
3
4
  const items = [
@@ -5,24 +6,28 @@ export const buildMainNavItems = (caps) => {
5
6
  id: 'community',
6
7
  target: { type: 'feed', feed: 'local' },
7
8
  labelKey: 'navigation.community',
9
+ tooltipKey: navTooltip('community'),
8
10
  icon: 'Home',
9
11
  },
10
12
  {
11
13
  id: 'welcome',
12
14
  target: { type: 'welcome' },
13
15
  labelKey: 'navigation.goToWelcomePage',
16
+ tooltipKey: navTooltip('welcome'),
14
17
  icon: 'BookCheck',
15
18
  },
16
19
  {
17
20
  id: 'explore',
18
21
  target: { type: 'explore' },
19
22
  labelKey: 'navigation.explore',
23
+ tooltipKey: navTooltip('explore'),
20
24
  icon: 'Search',
21
25
  },
22
26
  {
23
27
  id: 'myFeed',
24
28
  target: { type: 'feed', feed: 'my' },
25
29
  labelKey: 'navigation.myFeed',
30
+ tooltipKey: navTooltip('myFeed'),
26
31
  icon: 'Newspaper',
27
32
  },
28
33
  ];
@@ -31,6 +36,7 @@ export const buildMainNavItems = (caps) => {
31
36
  id: 'jams',
32
37
  target: { type: 'jams' },
33
38
  labelKey: 'navigation.jams',
39
+ tooltipKey: navTooltip('jams'),
34
40
  icon: 'PhoneCall',
35
41
  });
36
42
  }
@@ -38,41 +44,49 @@ export const buildMainNavItems = (caps) => {
38
44
  id: 'groups',
39
45
  target: { type: 'groups' },
40
46
  labelKey: 'navigation.groups',
47
+ tooltipKey: navTooltip('groups'),
41
48
  icon: 'Users',
42
49
  }, {
43
50
  id: 'events',
44
51
  target: { type: 'events' },
45
52
  labelKey: 'navigation.events',
53
+ tooltipKey: navTooltip('events'),
46
54
  icon: 'CalendarDays',
47
55
  }, {
48
56
  id: 'articles',
49
57
  target: { type: 'articles' },
50
58
  labelKey: 'navigation.articles',
59
+ tooltipKey: navTooltip('articles'),
51
60
  icon: 'ScrollText',
52
61
  }, {
53
62
  id: 'resources',
54
63
  target: { type: 'resources' },
55
64
  labelKey: 'navigation.resources',
65
+ tooltipKey: navTooltip('resources'),
56
66
  icon: 'Library',
57
67
  }, {
58
68
  id: 'messages',
59
69
  target: { type: 'conversation' },
60
70
  labelKey: 'navigation.messages',
71
+ tooltipKey: navTooltip('messages'),
61
72
  icon: 'MessageSquareText',
62
73
  }, {
63
74
  id: 'members',
64
75
  target: { type: 'members' },
65
76
  labelKey: 'navigation.members',
77
+ tooltipKey: navTooltip('members'),
66
78
  icon: 'BookUser',
67
79
  }, {
68
80
  id: 'bookmarks',
69
81
  target: { type: 'feed', feed: 'bookmarks' },
70
82
  labelKey: 'navigation.bookmarks',
83
+ tooltipKey: navTooltip('bookmarks'),
71
84
  icon: 'Bookmark',
72
85
  }, {
73
86
  id: 'settings',
74
87
  target: { type: 'settings' },
75
88
  labelKey: 'navigation.settings',
89
+ tooltipKey: navTooltip('settings'),
76
90
  icon: 'Settings',
77
91
  });
78
92
  if (caps.showAdmin) {
@@ -80,6 +94,7 @@ export const buildMainNavItems = (caps) => {
80
94
  id: 'admin',
81
95
  target: { type: 'admin' },
82
96
  labelKey: 'navigation.administration',
97
+ tooltipKey: navTooltip('administration'),
83
98
  icon: 'Bolt',
84
99
  });
85
100
  }
@@ -89,6 +89,8 @@ export type NavItemDef = {
89
89
  id: string;
90
90
  target: NavTarget;
91
91
  labelKey: string;
92
+ /** i18n key describing what happens when the item is activated. */
93
+ tooltipKey?: string;
92
94
  /** Lucide (or similar) icon component name — host maps to actual icon. */
93
95
  icon?: string;
94
96
  end?: boolean;
@@ -3,5 +3,5 @@ import { useSetPageHeader } from '../../index.js';
3
3
  import { ConfigMenuButton } from '../../components/index.js';
4
4
  export function AdminConfigurationCommunity() {
5
5
  useSetPageHeader('Community Customization');
6
- return (_jsxs("div", { className: "p-4", children: [_jsx(ConfigMenuButton, { translationPrefix: "configuration.community.info", action: "/admin/configuration/community/info" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.favicons", action: "/admin/configuration/community/favicons" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.theme", action: "/admin/configuration/community/theme" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.welcomePage", action: "/admin/configuration/community/welcome-page" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.codeOfConduct", action: "/admin/configuration/community/code-of-conduct" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.welcomeEmail", action: "/admin/configuration/community/welcome-email" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.aboutPage", action: "/admin/configuration/community/about-page" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.links", action: "/admin/configuration/community/links" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.profileFields", action: "/admin/configuration/community/profile-fields" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.roles", action: "/admin/configuration/community/roles" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.language", action: "/admin/configuration/community/language" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.timezone", action: "/admin/configuration/community/timezone" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.feed", action: "/admin/configuration/community/feed" })] }));
6
+ return (_jsxs("div", { className: "p-4", children: [_jsx(ConfigMenuButton, { translationPrefix: "configuration.community.info", action: "/admin/configuration/community/info" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.favicons", action: "/admin/configuration/community/favicons" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.theme", action: "/admin/configuration/community/theme" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.welcomePage", action: "/admin/configuration/community/welcome-page" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.codeOfConduct", action: "/admin/configuration/community/code-of-conduct" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.welcomeEmail", action: "/admin/configuration/community/welcome-email" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.aboutPage", action: "/admin/configuration/community/about-page" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.links", action: "/admin/configuration/community/links" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.profileFields", action: "/admin/configuration/community/profile-fields" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.forbiddenUsernames", action: "/admin/configuration/community/forbidden-usernames", testId: "admin-community-forbidden-usernames" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.roles", action: "/admin/configuration/community/roles" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.language", action: "/admin/configuration/community/language" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.timezone", action: "/admin/configuration/community/timezone" }), _jsx(ConfigMenuButton, { translationPrefix: "configuration.community.feed", action: "/admin/configuration/community/feed" })] }));
7
7
  }
@@ -4,5 +4,5 @@ import { ConfigMenuButton } from '../../components/index.js';
4
4
  export function AdminDiagnostics() {
5
5
  const t = useT();
6
6
  useSetPageHeader(t('diagnostics.title', { defaultValue: 'Diagnostics' }));
7
- return (_jsxs("div", { className: "p-4", children: [_jsx(ConfigMenuButton, { translationPrefix: "diagnostics.email", action: "/admin/diagnostics/email" }), _jsx(ConfigMenuButton, { translationPrefix: "diagnostics.logs", action: "/admin/diagnostics/logs" }), _jsx(ConfigMenuButton, { translationPrefix: "diagnostics.performance", action: "/admin/diagnostics/performance" })] }));
7
+ return (_jsxs("div", { className: "p-4", children: [_jsx(ConfigMenuButton, { translationPrefix: "diagnostics.email", action: "/admin/diagnostics/email" }), _jsx(ConfigMenuButton, { translationPrefix: "diagnostics.livekit", action: "/admin/diagnostics/livekit" }), _jsx(ConfigMenuButton, { translationPrefix: "diagnostics.logs", action: "/admin/diagnostics/logs" }), _jsx(ConfigMenuButton, { translationPrefix: "diagnostics.performance", action: "/admin/diagnostics/performance" })] }));
8
8
  }
@@ -0,0 +1 @@
1
+ export declare const AdminDiagnosticsLivekit: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useT, useOpenpeeps, useSetPageHeader } from '../../index.js';
3
+ import { Button } from '@openpeepshq/react-ui';
4
+ const checkLabelKey = {
5
+ url: 'diagnostics.livekit.url',
6
+ apiKey: 'diagnostics.livekit.apiKey',
7
+ apiSecret: 'diagnostics.livekit.apiSecret',
8
+ reachable: 'diagnostics.livekit.reachable',
9
+ };
10
+ export const AdminDiagnosticsLivekit = () => {
11
+ const t = useT();
12
+ const { openpeepsApi } = useOpenpeeps();
13
+ const diagnosisQuery = openpeepsApi.admin.useLivekitDiagnosis();
14
+ useSetPageHeader(t('diagnostics.livekit.title', { defaultValue: 'LiveKit' }));
15
+ const diagnosis = diagnosisQuery.data;
16
+ return (_jsxs("div", { className: "space-y-4 p-4", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: t('diagnostics.livekit.description', {
17
+ defaultValue: 'Check whether jams can reach the LiveKit server. Missing or invalid credentials disable live jams.',
18
+ }) }), _jsx(Button, { variant: "outline", title: t('diagnostics.livekit.refresh', { defaultValue: 'Refresh' }), action: () => void diagnosisQuery.refetch(), children: t('diagnostics.livekit.refresh', { defaultValue: 'Refresh' }) }), diagnosisQuery.isPending ? (_jsx("p", { className: "text-muted-foreground text-sm", children: t('common.form.loading', { defaultValue: 'Loading…' }) })) : null, diagnosisQuery.isError ? (_jsx("p", { className: "text-error text-sm", children: t('diagnostics.livekit.loadError', {
19
+ defaultValue: 'Could not load the LiveKit diagnosis.',
20
+ }) })) : null, diagnosis ? _jsx(DiagnosisReport, { diagnosis: diagnosis }) : null] }));
21
+ };
22
+ const DiagnosisReport = ({ diagnosis }) => {
23
+ const t = useT();
24
+ return (_jsxs("div", { className: "space-y-4", children: [_jsx("p", { className: `font-medium ${diagnosis.connected ? 'text-success' : 'text-error'}`, role: "status", children: diagnosis.connected
25
+ ? t('diagnostics.livekit.connected', { defaultValue: 'Connected' })
26
+ : t('diagnostics.livekit.notConnected', {
27
+ defaultValue: 'Not connected',
28
+ }) }), _jsx("ul", { className: "border-border divide-border divide-y rounded-md border", children: diagnosis.checks.map((check) => {
29
+ const status = check.id === 'reachable'
30
+ ? check.ok
31
+ ? t('diagnostics.livekit.ok', { defaultValue: 'OK' })
32
+ : t('diagnostics.livekit.failed', { defaultValue: 'Failed' })
33
+ : check.ok
34
+ ? t('diagnostics.livekit.set', { defaultValue: 'Set' })
35
+ : t('diagnostics.livekit.missing', {
36
+ defaultValue: 'Missing',
37
+ });
38
+ return (_jsxs("li", { className: "flex items-start justify-between gap-4 p-3 text-sm", children: [_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t(checkLabelKey[check.id], {
39
+ defaultValue: check.id,
40
+ }) }), check.id === 'url' && diagnosis.url ? (_jsx("p", { className: "text-muted-foreground font-mono text-xs", children: diagnosis.url })) : null] }), _jsx("span", { className: `rounded px-2 py-0.5 text-xs font-medium ${check.ok ? 'bg-success/20 text-success' : 'bg-error/20 text-error'}`, children: status })] }, check.id));
41
+ }) }), _jsxs("p", { className: "text-sm", children: [t('diagnostics.livekit.recording', { defaultValue: 'Recording' }), ': ', _jsx("strong", { children: diagnosis.recordingEnabled
42
+ ? t('diagnostics.livekit.recordingOn', {
43
+ defaultValue: 'Enabled',
44
+ })
45
+ : t('diagnostics.livekit.recordingOff', {
46
+ defaultValue: 'Disabled',
47
+ }) })] }), diagnosis.error ? (_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t('diagnostics.livekit.error', { defaultValue: 'Last error' }) }), _jsx("pre", { className: "bg-surface mt-2 overflow-x-auto whitespace-pre-wrap break-words rounded-md p-3 font-mono text-xs", children: diagnosis.error })] })) : null, !diagnosis.connected ? (_jsx("p", { className: "text-muted-foreground text-sm", children: t('diagnostics.livekit.envHint', {
48
+ defaultValue: 'Set JAMS_LIVEKIT_URL, JAMS_LIVEKIT_API_KEY, and JAMS_LIVEKIT_API_SECRET on the server, then refresh.',
49
+ }) })) : null] }));
50
+ };
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useMemo, useState } from 'react';
3
- import { CheckCheck, Copy, MoreVertical, QrCode, Users, X } from 'lucide-react';
3
+ import { CheckCheck, Copy, MoreVertical, Pencil, QrCode, Users, X, } from 'lucide-react';
4
4
  import { inviteLinkMatchesQuery } from '@openpeepshq/common/lib';
5
5
  import { useT, useOpenpeeps, useServerInfo, useSetPageHeader, } from '../../index.js';
6
6
  import { Avatar } from '../../components/index.js';
7
7
  import { UpdatingDate } from '@openpeepshq/react-ui';
8
8
  import { Dialog, DialogContent, DialogHeader, DialogTitle, Input, PopupMenu, PopupMenuButton, } from '@openpeepshq/react-ui';
9
9
  import { AdminInviteActions } from './components/AdminInviteActions.js';
10
+ import { EditInviteLinkModal } from './components/EditInviteLinkModal.js';
10
11
  import { communityQrLogoSrc, downloadInviteQr, inviteUrl, } from './components/inviteQr.js';
11
12
  export function AdminInvites() {
12
13
  const t = useT();
@@ -49,13 +50,14 @@ function InvitesTablePopup({ invite }) {
49
50
  const activate = openpeepsApi.admin.activateInviteAction();
50
51
  const deactivate = openpeepsApi.admin.deactivateInviteAction();
51
52
  const [showInvited, setShowInvited] = useState(false);
53
+ const [showEdit, setShowEdit] = useState(false);
52
54
  const active = invite.active && new Date(invite.expiresAt) > new Date();
53
55
  const expired = new Date(invite.expiresAt) <= new Date();
54
56
  return (_jsxs(_Fragment, { children: [_jsxs(PopupMenu, { placement: "bottom-end", width: "w-56", icon: MoreVertical, children: [_jsx(PopupMenuButton, { icon: Users, title: t('admin.invites.seeInvitedAccounts', {
55
57
  defaultValue: 'See invited accounts',
56
58
  }), text: t('admin.invites.seeInvitedAccounts', {
57
59
  defaultValue: 'See invited accounts',
58
- }), action: () => setShowInvited(true) }), active ? (_jsxs(_Fragment, { children: [_jsx(PopupMenuButton, { icon: Copy, title: t('admin.invites.copyLink', {
60
+ }), action: () => setShowInvited(true) }), _jsx(PopupMenuButton, { icon: Pencil, title: t('admin.invites.edit', { defaultValue: 'Edit' }), text: t('admin.invites.edit', { defaultValue: 'Edit' }), action: () => setShowEdit(true) }), active ? (_jsxs(_Fragment, { children: [_jsx(PopupMenuButton, { icon: Copy, title: t('admin.invites.copyLink', {
59
61
  defaultValue: 'Copy link',
60
62
  }), text: t('admin.invites.copyLink', { defaultValue: 'Copy link' }), action: () => void navigator.clipboard.writeText(inviteUrl(invite.slug)) }), _jsx(PopupMenuButton, { icon: QrCode, title: t('admin.invites.saveAsQrCode', {
61
63
  defaultValue: 'Save as QR code',
@@ -65,7 +67,7 @@ function InvitesTablePopup({ invite }) {
65
67
  defaultValue: 'Deactivate',
66
68
  }), text: t('admin.invites.deactivate', {
67
69
  defaultValue: 'Deactivate',
68
- }), action: () => deactivate({ id: invite.id }) })] })) : !expired ? (_jsx(PopupMenuButton, { icon: CheckCheck, title: t('admin.invites.activate', { defaultValue: 'Activate' }), text: t('admin.invites.activate', { defaultValue: 'Activate' }), action: () => activate({ id: invite.id }) })) : null] }), showInvited ? (_jsx(ListOfInvitedMembers, { invite: invite, onClose: () => setShowInvited(false) })) : null] }));
70
+ }), action: () => deactivate({ id: invite.id }) })] })) : !expired ? (_jsx(PopupMenuButton, { icon: CheckCheck, title: t('admin.invites.activate', { defaultValue: 'Activate' }), text: t('admin.invites.activate', { defaultValue: 'Activate' }), action: () => activate({ id: invite.id }) })) : null] }), showInvited ? (_jsx(ListOfInvitedMembers, { invite: invite, onClose: () => setShowInvited(false) })) : null, showEdit ? (_jsx(EditInviteLinkModal, { invite: invite, onClose: () => setShowEdit(false) })) : null] }));
69
71
  }
70
72
  function ListOfInvitedMembers({ invite, onClose, }) {
71
73
  const t = useT();
@@ -0,0 +1 @@
1
+ export declare const AdminMedia: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,135 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import { Images } from 'lucide-react';
4
+ import { checkRoleCapabilities } from '@openpeepshq/common';
5
+ import { Button, Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, } from '@openpeepshq/react-ui';
6
+ import { useOpenpeeps, useSetPageHeader, useT } from '../../index.js';
7
+ import { useCurrentProfile } from '../../components/index.js';
8
+ const formatBytes = (size) => {
9
+ if (size < 1024)
10
+ return `${size} B`;
11
+ if (size < 1024 * 1024)
12
+ return `${(size / 1024).toFixed(1)} KB`;
13
+ if (size < 1024 * 1024 * 1024) {
14
+ return `${(size / (1024 * 1024)).toFixed(1)} MB`;
15
+ }
16
+ return `${(size / (1024 * 1024 * 1024)).toFixed(1)} GB`;
17
+ };
18
+ const formatWhen = (iso) => iso ? new Date(iso).toLocaleString() : '';
19
+ export const AdminMedia = () => {
20
+ const t = useT();
21
+ const { openpeepsApi } = useOpenpeeps();
22
+ const me = useCurrentProfile();
23
+ const canDeleteMedia = checkRoleCapabilities(me?.roles ?? [], [
24
+ 'core-media-delete',
25
+ ]).success;
26
+ const mediaQuery = openpeepsApi.admin.useMediaList();
27
+ const deleteMedia = openpeepsApi.admin.deleteMediaAction();
28
+ const [filter, setFilter] = useState('all');
29
+ const [query, setQuery] = useState('');
30
+ const [pending, setPending] = useState(null);
31
+ const [deleting, setDeleting] = useState(false);
32
+ const [deleteError, setDeleteError] = useState(null);
33
+ const files = mediaQuery.data?.files ?? [];
34
+ const graceDays = Math.round((mediaQuery.data?.graceMs ?? 0) / 86_400_000);
35
+ const needle = query.trim().toLowerCase();
36
+ const visible = useMemo(() => files.filter((file) => {
37
+ if (filter === 'unused' && file.status === 'referenced')
38
+ return false;
39
+ if (filter === 'referenced' && file.status !== 'referenced') {
40
+ return false;
41
+ }
42
+ return (needle.length === 0 || file.storageId.toLowerCase().includes(needle));
43
+ }), [files, filter, needle]);
44
+ const unusedCount = files.filter((file) => file.status !== 'referenced').length;
45
+ useSetPageHeader(t('admin.media.title', { defaultValue: 'Media' }));
46
+ const statusLabel = (status) => t(`admin.media.status.${status}`, {
47
+ defaultValue: status === 'referenced'
48
+ ? 'In use'
49
+ : status === 'due'
50
+ ? 'Ready to collect'
51
+ : 'Unused',
52
+ });
53
+ const collectionLabel = (file) => {
54
+ if (file.status === 'referenced') {
55
+ return t('admin.media.collects.referenced', {
56
+ defaultValue: 'Kept — still linked',
57
+ });
58
+ }
59
+ if (file.status === 'pending') {
60
+ return t('admin.media.collects.pending', {
61
+ defaultValue: 'Deletes {{date}}',
62
+ date: formatWhen(file.deletesAt),
63
+ });
64
+ }
65
+ if (file.status === 'due') {
66
+ return t('admin.media.collects.due', {
67
+ defaultValue: 'Deletes on the next run',
68
+ });
69
+ }
70
+ return t('admin.media.collects.unseen', {
71
+ defaultValue: 'Recorded on the next run',
72
+ });
73
+ };
74
+ const confirmDelete = async () => {
75
+ if (!pending)
76
+ return;
77
+ setDeleting(true);
78
+ setDeleteError(null);
79
+ try {
80
+ await deleteMedia({ storageId: pending.storageId });
81
+ setPending(null);
82
+ void mediaQuery.refetch();
83
+ }
84
+ catch (error) {
85
+ setDeleteError(error.message);
86
+ }
87
+ finally {
88
+ setDeleting(false);
89
+ }
90
+ };
91
+ const filters = [
92
+ { id: 'all', label: t('admin.media.filter.all', { defaultValue: 'All' }) },
93
+ {
94
+ id: 'unused',
95
+ label: t('admin.media.filter.unused', { defaultValue: 'Unused' }),
96
+ },
97
+ {
98
+ id: 'referenced',
99
+ label: t('admin.media.filter.inUse', { defaultValue: 'In use' }),
100
+ },
101
+ ];
102
+ return (_jsxs("div", { className: "space-y-4 p-4", children: [_jsx("div", { className: "rounded-md border p-4 text-sm", children: t('admin.media.description', {
103
+ defaultValue: 'Removing a post or jam recording leaves the file on the server, because another post, the welcome page, the about page, the code of conduct, a profile, or a custom field may still link to it. Garbage collection deletes a file {{days}} days after it first has no live link. Delete now removes a file immediately.',
104
+ days: graceDays || 7,
105
+ }) }), _jsx("p", { className: "text-muted-foreground text-sm", children: t('admin.media.counts', {
106
+ defaultValue: '{{total}} files · {{unused}} unused · {{inUse}} in use',
107
+ total: files.length,
108
+ unused: unusedCount,
109
+ inUse: files.length - unusedCount,
110
+ }) }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [filters.map((item) => (_jsx(Button, { title: item.label, variant: filter === item.id ? 'default' : 'outline', action: () => setFilter(item.id), children: item.label }, item.id))), _jsx("input", { value: query, onChange: (event) => setQuery(event.target.value), placeholder: t('admin.media.search', {
111
+ defaultValue: 'Search by file id',
112
+ }), className: "border-border bg-background min-w-48 flex-1 rounded-md border px-3 py-2 text-sm" })] }), mediaQuery.isLoading ? (_jsx("p", { className: "text-muted-foreground text-sm", children: t('admin.media.loading', { defaultValue: 'Loading…' }) })) : null, mediaQuery.isError ? (_jsx("p", { className: "text-error text-sm", children: t('admin.media.error', {
113
+ defaultValue: 'Could not load media files',
114
+ }) })) : null, !mediaQuery.isLoading && !mediaQuery.isError && visible.length === 0 ? (_jsxs("div", { className: "text-muted-foreground flex flex-col items-center pt-16", children: [_jsx(Images, { size: 48 }), _jsx("p", { className: "mt-2 text-sm", children: t('admin.media.empty', { defaultValue: 'No media files' }) })] })) : null, visible.length > 0 ? (_jsx("ul", { className: "space-y-2", children: visible.map((file) => (_jsx("li", { className: "rounded-md border p-3", children: _jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("p", { className: "break-all font-mono text-xs", children: file.storageId }), _jsxs("p", { className: "text-muted-foreground mt-1 text-sm", children: [formatBytes(file.size), " \u00B7 ", formatWhen(file.modifiedAt)] }), _jsxs("p", { className: "mt-1 text-sm", children: [_jsx("span", { className: "font-medium", children: statusLabel(file.status) }), _jsxs("span", { className: "text-muted-foreground", children: [' ', "\u00B7 ", collectionLabel(file)] })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("a", { href: file.url, target: "_blank", rel: "noreferrer", className: "text-primary text-sm", children: t('admin.media.open', { defaultValue: 'Open' }) }), canDeleteMedia ? (_jsx(Button, { title: t('admin.media.delete', {
115
+ defaultValue: 'Delete now',
116
+ }), variant: "outline", action: () => {
117
+ setDeleteError(null);
118
+ setPending(file);
119
+ }, children: t('admin.media.delete', { defaultValue: 'Delete now' }) })) : null] })] }) }, file.storageId))) })) : null, pending ? (_jsx(Dialog, { open: true, onOpenChange: (open) => {
120
+ if (!open && !deleting)
121
+ setPending(null);
122
+ }, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('admin.media.confirm.title', {
123
+ defaultValue: 'Delete this file?',
124
+ }) }) }), _jsx("p", { className: "px-1 text-sm", children: pending.status === 'referenced'
125
+ ? t('admin.media.confirm.referenced', {
126
+ defaultValue: 'This file is still linked from a post, page, or profile. Deleting it now removes it from the server, and those links will stop working.',
127
+ })
128
+ : t('admin.media.confirm.unused', {
129
+ defaultValue: 'This file is unused. Deleting it now removes it from the server instead of waiting for garbage collection.',
130
+ }) }), deleteError ? (_jsx("p", { className: "border-error/40 text-error rounded-md border p-2 text-sm", children: deleteError })) : null, _jsx(DialogActions, { cancelLabel: t('admin.media.confirm.cancel', {
131
+ defaultValue: 'Cancel',
132
+ }), onCancel: () => setPending(null), actionLabel: t('admin.media.confirm.action', {
133
+ defaultValue: 'Delete file',
134
+ }), onAction: confirmDelete, disabled: deleting })] }) })) : null] }));
135
+ };
@@ -0,0 +1 @@
1
+ export declare function AdminConfigurationCommunityForbiddenUsernames(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,106 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { Lock, X } from 'lucide-react';
4
+ import { classifyAdditionalForbiddenHandle, collectAdditionalForbiddenHandles, forbiddenHandles, normalizeForbiddenHandle, } from '@openpeepshq/common/types';
5
+ import { useT, useSetPageHeader, useOpenpeeps } from '../../../index.js';
6
+ import { Button, Input, Toast } from '@openpeepshq/react-ui';
7
+ const sameHandles = (left, right) => left.length === right.length &&
8
+ left.every((handle, i) => handle === right[i]);
9
+ export function AdminConfigurationCommunityForbiddenUsernames() {
10
+ const t = useT();
11
+ const { openpeepsApi } = useOpenpeeps();
12
+ const configQuery = openpeepsApi.admin.useConfigRead('openpeeps', 'community');
13
+ const updateConfig = openpeepsApi.admin.updateConfigAction({
14
+ namespace: 'openpeeps',
15
+ name: 'community',
16
+ });
17
+ const [custom, setCustom] = useState([]);
18
+ const [draft, setDraft] = useState('');
19
+ const [fieldError, setFieldError] = useState(null);
20
+ const [saving, setSaving] = useState(false);
21
+ const [status, setStatus] = useState(null);
22
+ useSetPageHeader(t('configuration.community.forbiddenUsernames.title', {
23
+ defaultValue: 'Forbidden usernames',
24
+ }));
25
+ const base = configQuery.data?.config;
26
+ const saved = collectAdditionalForbiddenHandles(base?.settings?.additionalForbiddenHandles ?? []).handles;
27
+ const savedKey = saved.join('\n');
28
+ useEffect(() => {
29
+ setCustom(savedKey ? savedKey.split('\n') : []);
30
+ }, [savedKey]);
31
+ const issueMessage = (issue) => {
32
+ if (issue === 'empty') {
33
+ return t('configuration.community.forbiddenUsernames.empty', {
34
+ defaultValue: 'Enter a username to add.',
35
+ });
36
+ }
37
+ if (issue === 'invalid') {
38
+ return t('configuration.community.forbiddenUsernames.invalid', {
39
+ defaultValue: 'Usernames must be 1–16 characters: letters, numbers, underscores, or hyphens.',
40
+ });
41
+ }
42
+ if (issue === 'builtIn') {
43
+ return t('configuration.community.forbiddenUsernames.builtInError', {
44
+ defaultValue: 'Built-in usernames are always reserved and cannot be changed.',
45
+ });
46
+ }
47
+ return t('configuration.community.forbiddenUsernames.duplicate', {
48
+ defaultValue: 'That username is already on the list.',
49
+ });
50
+ };
51
+ const addUsername = () => {
52
+ const issue = classifyAdditionalForbiddenHandle(draft, custom);
53
+ if (issue) {
54
+ setFieldError(issueMessage(issue));
55
+ return;
56
+ }
57
+ setCustom((prev) => [...prev, normalizeForbiddenHandle(draft)]);
58
+ setDraft('');
59
+ setFieldError(null);
60
+ };
61
+ const save = async () => {
62
+ setStatus(null);
63
+ setSaving(true);
64
+ try {
65
+ await updateConfig({
66
+ config: { settings: { additionalForbiddenHandles: custom } },
67
+ });
68
+ setStatus({
69
+ type: 'success',
70
+ message: t('configuration.community.updateSuccess', {
71
+ defaultValue: 'Community settings updated',
72
+ }),
73
+ });
74
+ }
75
+ catch (err) {
76
+ setStatus({ type: 'error', message: err.message });
77
+ }
78
+ finally {
79
+ setSaving(false);
80
+ }
81
+ };
82
+ if (configQuery.isLoading) {
83
+ return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.form.loading', { defaultValue: 'Loading…' }) }));
84
+ }
85
+ return (_jsxs("div", { className: "flex flex-col gap-4 p-4", "data-testid": "admin-forbidden-usernames", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: t('configuration.community.forbiddenUsernames.description', {
86
+ defaultValue: 'Block usernames your community does not allow, such as slurs or hate speech. Each entry is a full username, ignoring capitalization. Built-in usernames stay reserved and cannot be removed.',
87
+ }) }), _jsxs("ul", { className: "border-border divide-border divide-y border", children: [forbiddenHandles.map((handle) => (_jsxs("li", { className: "flex items-center justify-between gap-3 px-3 py-2", "data-testid": `admin-forbidden-username-${handle}`, children: [_jsx("span", { children: handle }), _jsxs("span", { className: "text-muted-foreground flex items-center gap-1 text-xs", children: [_jsx(Lock, { className: "size-3", "aria-hidden": "true" }), t('configuration.community.forbiddenUsernames.builtIn', {
88
+ defaultValue: 'Built-in',
89
+ })] })] }, handle))), custom.map((handle) => (_jsxs("li", { className: "flex items-center justify-between gap-3 px-3 py-2", "data-testid": `admin-forbidden-username-${handle}`, children: [_jsx("span", { children: handle }), _jsxs(Button, { variant: "ghost", title: t('configuration.community.forbiddenUsernames.remove', {
90
+ defaultValue: 'Remove',
91
+ }), action: () => setCustom((prev) => prev.filter((item) => item !== handle)), "data-testid": `admin-forbidden-username-remove-${handle}`, children: [_jsx(X, { className: "size-4", "aria-hidden": "true" }), t('configuration.community.forbiddenUsernames.remove', {
92
+ defaultValue: 'Remove',
93
+ })] })] }, handle)))] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Input, { value: draft, placeholder: t('configuration.community.forbiddenUsernames.placeholder', { defaultValue: 'username' }), "aria-invalid": Boolean(fieldError), onChange: (event) => {
94
+ setDraft(event.target.value);
95
+ setFieldError(null);
96
+ }, onKeyDown: (event) => {
97
+ if (event.key !== 'Enter')
98
+ return;
99
+ event.preventDefault();
100
+ addUsername();
101
+ }, "data-testid": "admin-forbidden-usernames-input" }), _jsx(Button, { variant: "outline", title: t('configuration.community.forbiddenUsernames.add', {
102
+ defaultValue: 'Add username',
103
+ }), action: addUsername, "data-testid": "admin-forbidden-usernames-add", children: t('configuration.community.forbiddenUsernames.add', {
104
+ defaultValue: 'Add username',
105
+ }) })] }), fieldError ? (_jsx("p", { className: "text-error text-sm", role: "alert", children: fieldError })) : null] }), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null, _jsx(Button, { variant: "default", action: save, disabled: saving || sameHandles(custom, saved), "data-testid": "admin-forbidden-usernames-save", children: t('common.form.save', { defaultValue: 'Save' }) })] }));
106
+ }