@openpeepshq/react 0.10.0 → 0.11.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.
- package/dist/components/RelationCapabilitiesEditor.js +3 -3
- package/dist/components/RoleCapabilityMatrix.js +2 -2
- package/dist/components/accounts/SignUpLoginModal.js +1 -1
- package/dist/components/configuration/ConfigurationList.js +2 -2
- package/dist/components/conversations/ConversationMessageBubble.js +8 -1
- package/dist/components/conversations/CreateNewConversation.js +34 -17
- package/dist/components/form/ImageEditModal.js +2 -2
- package/dist/components/groups/ChangeGroupRolesModal.js +1 -1
- package/dist/components/groups/ConfirmGroupExitModal.js +1 -1
- package/dist/components/groups/ConfirmMemberRemovalModal.js +1 -1
- package/dist/components/groups/DeleteGroupModal.js +1 -1
- package/dist/components/groups/GroupForm.js +2 -2
- package/dist/components/groups/GroupNotificationSettingsModal.js +2 -2
- package/dist/components/jams/JamCallParticipant.js +4 -3
- package/dist/components/jams/JamGuestForm.js +1 -1
- package/dist/components/jams/jamEventActions.d.ts +10 -0
- package/dist/components/jams/jamEventActions.js +13 -0
- package/dist/components/navigation/ContentHeader.js +1 -1
- package/dist/components/navigation/FooterMobile.js +1 -1
- package/dist/components/navigation/SideBar.js +1 -1
- package/dist/components/post/FullPostLayout.js +1 -1
- package/dist/components/post/index.d.ts +1 -0
- package/dist/components/post/index.js +1 -0
- package/dist/components/post/pieces/EventRsvpList.js +1 -1
- package/dist/components/post/pieces/EventRsvpScopeDialog.js +2 -2
- package/dist/components/post/pieces/EventWaitlistJoinDialog.js +1 -1
- package/dist/components/post/pieces/GalleryModal.js +1 -1
- package/dist/components/post/pieces/modals/DeletePostModal.js +2 -2
- package/dist/components/post/post-form/ComposeAttachments.d.ts +2 -0
- package/dist/components/post/post-form/ComposeAttachments.js +8 -0
- package/dist/components/post/post-form/DescriptionEditModal.js +1 -1
- package/dist/components/post/post-form/EditPostModal.js +2 -2
- package/dist/components/post/post-form/EventForm.js +4 -26
- package/dist/components/post/post-form/PostAudienceSelector.js +2 -2
- package/dist/components/post/post-form/ReplyModal.js +1 -1
- package/dist/components/post/types/event/FullEvent.js +3 -3
- package/dist/components/post/types/resource/FullResource.js +2 -1
- package/dist/components/preview-link/RemotePreviewLink.js +32 -4
- package/dist/components/preview-link/RemotePreviewLink.test.d.ts +1 -0
- package/dist/components/preview-link/RemotePreviewLink.test.js +118 -0
- package/dist/components/profile/ProfileActivitySummary.js +4 -4
- package/dist/components/profile/ProfileBadge.js +1 -1
- package/dist/components/profile/ProfilePageAction.js +1 -1
- package/dist/components/profile/ProfilePostsAndReplies.js +1 -1
- package/dist/components/profile/ProfileSelector.js +1 -1
- package/dist/components/profile/ReportProfileOrPostModal.js +4 -2
- package/dist/components/resources/CategoryPathPicker.js +1 -1
- package/dist/components/resources/ResourceCard.js +5 -3
- package/dist/components/resources/ResourceLibrary.js +61 -8
- package/dist/components/resources/ResourceLibrary.test.d.ts +1 -0
- package/dist/components/resources/ResourceLibrary.test.js +122 -0
- package/dist/components/server-data/context.d.ts +24 -16
- package/dist/contexts/openpeeps/hooks/admin.d.ts +2 -2
- package/dist/contexts/openpeeps/hooks/auth.d.ts +1 -1
- package/dist/contexts/router/index.d.ts +8 -0
- package/dist/contexts/router/index.js +27 -2
- package/dist/hooks/conversations/dmMessage.d.ts +15 -0
- package/dist/hooks/conversations/dmMessage.js +12 -0
- package/dist/hooks/conversations/useCreateConversation.d.ts +40 -0
- package/dist/hooks/conversations/useCreateConversation.js +6 -0
- package/dist/hooks/events/useEventForm.d.ts +3 -0
- package/dist/hooks/events/useEventForm.js +31 -2
- package/dist/hooks/events/useEventForm.test.d.ts +1 -0
- package/dist/hooks/events/useEventForm.test.js +107 -0
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/posts/useFeedPostActions.js +4 -15
- package/dist/hooks/posts/usePostReactionToggle.d.ts +14 -0
- package/dist/hooks/posts/usePostReactionToggle.js +46 -0
- package/dist/hooks/resources/useResourceLibrary.d.ts +8 -1
- package/dist/hooks/resources/useResourceLibrary.js +5 -5
- package/dist/hooks/settings/useAccessTokens.d.ts +3 -3
- package/dist/hooks/settings/useAccessTokens.js +1 -0
- package/dist/lib/downloadUrl.d.ts +6 -0
- package/dist/lib/downloadUrl.js +6 -0
- package/dist/navigation/menuItems.js +4 -4
- package/dist/pages/Explore.js +1 -1
- package/dist/pages/admin/ApiKeys.js +3 -3
- package/dist/pages/admin/ConfigEditor.js +1 -1
- package/dist/pages/admin/ConfigurationCommunityFeed.js +2 -2
- package/dist/pages/admin/ConfigurationCommunityLanguage.js +2 -2
- package/dist/pages/admin/ConfigurationCommunityTimezone.js +2 -2
- package/dist/pages/admin/ConfigurationEmail.js +2 -2
- package/dist/pages/admin/ConfigurationI18n.js +1 -1
- package/dist/pages/admin/ConfigurationSso.js +1 -1
- package/dist/pages/admin/ConfigurationSsoNew.js +1 -1
- package/dist/pages/admin/Dashboard.js +1 -1
- package/dist/pages/admin/Db.js +4 -4
- package/dist/pages/admin/DiagnosticsEmail.js +3 -3
- package/dist/pages/admin/DiagnosticsJob.js +2 -2
- package/dist/pages/admin/DiagnosticsLivekit.js +1 -1
- package/dist/pages/admin/DiagnosticsLogs.js +2 -2
- package/dist/pages/admin/DiagnosticsPerformance.js +1 -1
- package/dist/pages/admin/GroupMembers.js +5 -5
- package/dist/pages/admin/Groups.js +2 -2
- package/dist/pages/admin/Invites.js +3 -3
- package/dist/pages/admin/Media.js +2 -2
- package/dist/pages/admin/MemberDetail.js +7 -7
- package/dist/pages/admin/Members.js +2 -2
- package/dist/pages/admin/analytics/AnalyticsLayout.js +3 -1
- package/dist/pages/admin/analytics/Content.js +1 -1
- package/dist/pages/admin/analytics/Engagement.js +1 -1
- package/dist/pages/admin/analytics/Groups.js +1 -1
- package/dist/pages/admin/analytics/ReportSettings.js +1 -1
- package/dist/pages/admin/community/CommunityAccess.js +1 -1
- package/dist/pages/admin/community/CommunityFavicons.js +1 -1
- package/dist/pages/admin/community/CommunityForbiddenUsernames.js +2 -2
- package/dist/pages/admin/community/CommunityInfo.js +1 -1
- package/dist/pages/admin/community/CommunityLinks.js +1 -1
- package/dist/pages/admin/community/CommunityMarkdownPage.js +1 -1
- package/dist/pages/admin/community/CommunityProfileFields.js +2 -2
- package/dist/pages/admin/community/CommunityRoles.js +7 -7
- package/dist/pages/admin/community/CommunityTheme.js +3 -2
- package/dist/pages/admin/community/ThemeColorPreview.d.ts +8 -0
- package/dist/pages/admin/community/ThemeColorPreview.js +46 -0
- package/dist/pages/admin/community/ThemeColorPreview.test.d.ts +1 -0
- package/dist/pages/admin/community/ThemeColorPreview.test.js +49 -0
- package/dist/pages/admin/components/AdminGroupCard.js +1 -1
- package/dist/pages/admin/components/EditInviteLinkModal.js +1 -1
- package/dist/pages/admin/components/InviteWithEmailModal.js +2 -2
- package/dist/pages/admin/components/InviteWithLinkModal.js +3 -3
- package/dist/pages/admin/components/ProfileRowActions.js +4 -4
- package/dist/pages/admin/components/RestoreBackupModal.js +2 -2
- package/dist/pages/admin/components/RestoreTestBackupModal.js +1 -1
- package/dist/pages/auth/Login.js +1 -1
- package/dist/pages/auth/Register.js +3 -3
- package/dist/pages/auth/RequestResetPassword.js +1 -1
- package/dist/pages/conversations/Info.js +1 -1
- package/dist/pages/conversations/Show.js +45 -15
- package/dist/pages/events/Index.js +1 -1
- package/dist/pages/feeds/Bookmarks.js +1 -1
- package/dist/pages/groups/EditInfo.js +1 -1
- package/dist/pages/groups/EditRoles.js +1 -1
- package/dist/pages/groups/Index.js +1 -1
- package/dist/pages/groups/Members.js +2 -2
- package/dist/pages/groups/New.js +1 -1
- package/dist/pages/groups/Show.js +2 -2
- package/dist/pages/settings/AccessTokens.js +4 -4
- package/dist/pages/settings/Account.js +1 -1
- package/dist/pages/settings/Feed.js +1 -1
- package/dist/pages/settings/Language.js +1 -1
- package/dist/pages/settings/PublicProfile.js +3 -3
- package/dist/pages/settings/PushEnabledDevices.js +1 -1
- package/dist/pages/settings/Theme.js +1 -1
- package/dist/pages/settings/Timezone.js +1 -1
- package/dist/react-native.d.ts +1 -1
- package/dist/react-native.js +1 -1
- package/package.json +9 -9
- package/src/components/RelationCapabilitiesEditor.tsx +3 -3
- package/src/components/RoleCapabilityMatrix.tsx +2 -2
- package/src/components/accounts/SignUpLoginModal.tsx +1 -1
- package/src/components/configuration/ConfigurationList.tsx +2 -2
- package/src/components/conversations/ConversationMessageBubble.tsx +24 -0
- package/src/components/conversations/CreateNewConversation.tsx +114 -78
- package/src/components/form/ImageEditModal.tsx +2 -2
- package/src/components/groups/ChangeGroupRolesModal.tsx +1 -1
- package/src/components/groups/ConfirmGroupExitModal.tsx +1 -1
- package/src/components/groups/ConfirmMemberRemovalModal.tsx +2 -2
- package/src/components/groups/DeleteGroupModal.tsx +2 -2
- package/src/components/groups/GroupForm.tsx +2 -2
- package/src/components/groups/GroupNotificationSettingsModal.tsx +2 -2
- package/src/components/jams/JamCallParticipant.tsx +4 -3
- package/src/components/jams/JamGuestForm.tsx +1 -1
- package/src/components/jams/jamEventActions.ts +21 -0
- package/src/components/navigation/ContentHeader.tsx +3 -3
- package/src/components/navigation/FooterMobile.tsx +1 -1
- package/src/components/navigation/SideBar.tsx +3 -3
- package/src/components/post/FullPostLayout.tsx +1 -1
- package/src/components/post/index.ts +1 -0
- package/src/components/post/pieces/EventRsvpList.tsx +1 -1
- package/src/components/post/pieces/EventRsvpScopeDialog.tsx +2 -2
- package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +1 -1
- package/src/components/post/pieces/GalleryModal.tsx +1 -1
- package/src/components/post/pieces/modals/DeletePostModal.tsx +2 -2
- package/src/components/post/post-form/ComposeAttachments.tsx +10 -0
- package/src/components/post/post-form/DescriptionEditModal.tsx +1 -1
- package/src/components/post/post-form/EditPostModal.tsx +2 -2
- package/src/components/post/post-form/EventForm.tsx +8 -26
- package/src/components/post/post-form/PostAudienceSelector.tsx +2 -2
- package/src/components/post/post-form/ReplyModal.tsx +1 -1
- package/src/components/post/types/event/FullEvent.tsx +3 -3
- package/src/components/post/types/resource/FullResource.tsx +2 -1
- package/src/components/preview-link/RemotePreviewLink.tsx +92 -25
- package/src/components/profile/ProfileActivitySummary.tsx +4 -4
- package/src/components/profile/ProfileBadge.tsx +1 -1
- package/src/components/profile/ProfilePageAction.tsx +1 -1
- package/src/components/profile/ProfilePostsAndReplies.tsx +2 -2
- package/src/components/profile/ProfileSelector.tsx +1 -1
- package/src/components/profile/ReportProfileOrPostModal.tsx +4 -2
- package/src/components/resources/CategoryPathPicker.tsx +1 -1
- package/src/components/resources/ResourceCard.tsx +5 -3
- package/src/components/resources/ResourceLibrary.tsx +79 -4
- package/src/contexts/router/index.tsx +40 -1
- package/src/hooks/conversations/dmMessage.ts +26 -0
- package/src/hooks/conversations/useCreateConversation.ts +7 -0
- package/src/hooks/events/useEventForm.ts +32 -1
- package/src/hooks/index.ts +10 -1
- package/src/hooks/posts/useFeedPostActions.ts +4 -18
- package/src/hooks/posts/usePostReactionToggle.ts +60 -0
- package/src/hooks/resources/useResourceLibrary.ts +20 -5
- package/src/hooks/settings/useAccessTokens.ts +1 -0
- package/src/lib/downloadUrl.ts +7 -0
- package/src/navigation/menuItems.ts +4 -4
- package/src/pages/Explore.tsx +4 -4
- package/src/pages/admin/ApiKeys.tsx +4 -4
- package/src/pages/admin/ConfigEditor.tsx +1 -1
- package/src/pages/admin/ConfigurationCommunityFeed.tsx +2 -2
- package/src/pages/admin/ConfigurationCommunityLanguage.tsx +2 -2
- package/src/pages/admin/ConfigurationCommunityTimezone.tsx +2 -2
- package/src/pages/admin/ConfigurationEmail.tsx +2 -2
- package/src/pages/admin/ConfigurationI18n.tsx +1 -1
- package/src/pages/admin/ConfigurationSso.tsx +1 -1
- package/src/pages/admin/ConfigurationSsoNew.tsx +1 -1
- package/src/pages/admin/Dashboard.tsx +1 -1
- package/src/pages/admin/Db.tsx +6 -6
- package/src/pages/admin/DiagnosticsEmail.tsx +5 -5
- package/src/pages/admin/DiagnosticsJob.tsx +2 -2
- package/src/pages/admin/DiagnosticsLivekit.tsx +3 -3
- package/src/pages/admin/DiagnosticsLogs.tsx +4 -4
- package/src/pages/admin/DiagnosticsPerformance.tsx +1 -1
- package/src/pages/admin/GroupMembers.tsx +6 -6
- package/src/pages/admin/Groups.tsx +2 -2
- package/src/pages/admin/Invites.tsx +4 -4
- package/src/pages/admin/Media.tsx +2 -2
- package/src/pages/admin/MemberDetail.tsx +7 -7
- package/src/pages/admin/Members.tsx +2 -2
- package/src/pages/admin/analytics/AnalyticsLayout.tsx +5 -1
- package/src/pages/admin/analytics/Content.tsx +1 -1
- package/src/pages/admin/analytics/Engagement.tsx +1 -1
- package/src/pages/admin/analytics/Groups.tsx +1 -1
- package/src/pages/admin/analytics/ReportSettings.tsx +1 -1
- package/src/pages/admin/community/CommunityAccess.tsx +1 -1
- package/src/pages/admin/community/CommunityFavicons.tsx +1 -1
- package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +2 -2
- package/src/pages/admin/community/CommunityInfo.tsx +1 -1
- package/src/pages/admin/community/CommunityLinks.tsx +1 -1
- package/src/pages/admin/community/CommunityMarkdownPage.tsx +1 -1
- package/src/pages/admin/community/CommunityProfileFields.tsx +5 -5
- package/src/pages/admin/community/CommunityRoles.tsx +9 -9
- package/src/pages/admin/community/CommunityTheme.tsx +26 -23
- package/src/pages/admin/community/ThemeColorPreview.tsx +141 -0
- package/src/pages/admin/components/AdminGroupCard.tsx +2 -2
- package/src/pages/admin/components/EditInviteLinkModal.tsx +2 -2
- package/src/pages/admin/components/InviteWithEmailModal.tsx +2 -2
- package/src/pages/admin/components/InviteWithLinkModal.tsx +3 -3
- package/src/pages/admin/components/ProfileRowActions.tsx +6 -6
- package/src/pages/admin/components/RestoreBackupModal.tsx +2 -2
- package/src/pages/admin/components/RestoreTestBackupModal.tsx +1 -1
- package/src/pages/auth/Login.tsx +1 -1
- package/src/pages/auth/Register.tsx +3 -3
- package/src/pages/auth/RequestResetPassword.tsx +1 -1
- package/src/pages/conversations/Info.tsx +1 -1
- package/src/pages/conversations/Show.tsx +94 -33
- package/src/pages/events/Index.tsx +1 -1
- package/src/pages/feeds/Bookmarks.tsx +3 -1
- package/src/pages/groups/EditInfo.tsx +1 -1
- package/src/pages/groups/EditRoles.tsx +1 -1
- package/src/pages/groups/Index.tsx +1 -1
- package/src/pages/groups/Members.tsx +2 -2
- package/src/pages/groups/New.tsx +1 -1
- package/src/pages/groups/Show.tsx +4 -4
- package/src/pages/settings/AccessTokens.tsx +4 -4
- package/src/pages/settings/Account.tsx +1 -1
- package/src/pages/settings/Feed.tsx +1 -1
- package/src/pages/settings/Language.tsx +1 -1
- package/src/pages/settings/PublicProfile.tsx +3 -3
- package/src/pages/settings/PushEnabledDevices.tsx +3 -6
- package/src/pages/settings/Theme.tsx +1 -1
- package/src/pages/settings/Timezone.tsx +1 -1
- package/src/react-native.ts +1 -0
|
@@ -45,6 +45,8 @@ export interface ComposeAttachmentsApi {
|
|
|
45
45
|
openImagePicker: () => void;
|
|
46
46
|
openAudioPicker: () => void;
|
|
47
47
|
openDocumentPicker: () => void;
|
|
48
|
+
/** Drop in-flight and ready items. Used after a message is sent. */
|
|
49
|
+
clear: () => void;
|
|
48
50
|
/** True while any attachment is still uploading or processing. */
|
|
49
51
|
pending: boolean;
|
|
50
52
|
/** Attachment cards — render where the previews should appear. */
|
|
@@ -280,6 +282,14 @@ export function useComposeAttachments({
|
|
|
280
282
|
openImagePicker: () => imageInputRef.current?.click(),
|
|
281
283
|
openAudioPicker: () => audioInputRef.current?.click(),
|
|
282
284
|
openDocumentPicker: () => documentInputRef.current?.click(),
|
|
285
|
+
clear: () => {
|
|
286
|
+
items.forEach((item) => {
|
|
287
|
+
if (item.previewUrl && isBlobUrl(item.previewUrl)) {
|
|
288
|
+
revokeBlobUrl(item.previewUrl);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
setItems([]);
|
|
292
|
+
},
|
|
283
293
|
pending,
|
|
284
294
|
previews,
|
|
285
295
|
inputs,
|
|
@@ -64,7 +64,7 @@ export function DescriptionEditModal({
|
|
|
64
64
|
</div>
|
|
65
65
|
|
|
66
66
|
<DialogActions
|
|
67
|
-
cancelLabel={t('common.back', { defaultValue: 'Back' })}
|
|
67
|
+
cancelLabel={t('common.actions.back', { defaultValue: 'Back' })}
|
|
68
68
|
onCancel={onClose}
|
|
69
69
|
actionLabel={t('common.done', { defaultValue: 'Done' })}
|
|
70
70
|
onAction={saveAndClose}
|
|
@@ -179,12 +179,12 @@ export function EditPostModal({ post, onClose }: EditPostModalProps) {
|
|
|
179
179
|
{error ? <p className="text-error text-sm">{error}</p> : null}
|
|
180
180
|
|
|
181
181
|
<DialogActions
|
|
182
|
-
cancelLabel={t('common.cancel', { defaultValue: 'Cancel' })}
|
|
182
|
+
cancelLabel={t('common.actions.cancel', { defaultValue: 'Cancel' })}
|
|
183
183
|
onCancel={onClose}
|
|
184
184
|
actionLabel={
|
|
185
185
|
submitting
|
|
186
186
|
? t('common.saving', { defaultValue: 'Saving…' })
|
|
187
|
-
: t('common.save', { defaultValue: 'Save' })
|
|
187
|
+
: t('common.actions.save', { defaultValue: 'Save' })
|
|
188
188
|
}
|
|
189
189
|
onAction={publish}
|
|
190
190
|
disabled={submitting || !canSave}
|
|
@@ -57,7 +57,6 @@ export const EventForm = ({
|
|
|
57
57
|
}: EventFormProps) => {
|
|
58
58
|
const t = useT();
|
|
59
59
|
const [audienceOpen, setAudienceOpen] = useState(false);
|
|
60
|
-
const [endBeforeStart, setEndBeforeStart] = useState(false);
|
|
61
60
|
const {
|
|
62
61
|
event,
|
|
63
62
|
eventTimeZone,
|
|
@@ -65,6 +64,9 @@ export const EventForm = ({
|
|
|
65
64
|
repeatFreq,
|
|
66
65
|
repeatEnd,
|
|
67
66
|
preview,
|
|
67
|
+
endBeforeStart,
|
|
68
|
+
changeStart,
|
|
69
|
+
changeEnd,
|
|
68
70
|
patchEvent,
|
|
69
71
|
setEvent,
|
|
70
72
|
setAudience,
|
|
@@ -145,17 +147,7 @@ export const EventForm = ({
|
|
|
145
147
|
type="datetime-local"
|
|
146
148
|
step={60}
|
|
147
149
|
value={dateToInputValue(event.start, eventTimeZone)}
|
|
148
|
-
onChange={(e) =>
|
|
149
|
-
const start = toIso(e.target.value, eventTimeZone);
|
|
150
|
-
if (start) {
|
|
151
|
-
if (event.end && new Date(event.end) <= new Date(start)) {
|
|
152
|
-
setEndBeforeStart(true);
|
|
153
|
-
} else {
|
|
154
|
-
setEndBeforeStart(false);
|
|
155
|
-
}
|
|
156
|
-
patchEvent({ start });
|
|
157
|
-
}
|
|
158
|
-
}}
|
|
150
|
+
onChange={(e) => changeStart(toIso(e.target.value, eventTimeZone))}
|
|
159
151
|
data-testid="events-start-input"
|
|
160
152
|
/>
|
|
161
153
|
</Label>
|
|
@@ -184,19 +176,9 @@ export const EventForm = ({
|
|
|
184
176
|
type="datetime-local"
|
|
185
177
|
step={60}
|
|
186
178
|
value={dateToInputValue(event.end, eventTimeZone)}
|
|
187
|
-
onChange={(e) =>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
newEnd &&
|
|
191
|
-
event.start &&
|
|
192
|
-
new Date(newEnd) <= new Date(event.start)
|
|
193
|
-
) {
|
|
194
|
-
setEndBeforeStart(true);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
setEndBeforeStart(false);
|
|
198
|
-
patchEvent({ end: newEnd });
|
|
199
|
-
}}
|
|
179
|
+
onChange={(e) =>
|
|
180
|
+
changeEnd(toIso(e.target.value, eventTimeZone))
|
|
181
|
+
}
|
|
200
182
|
/>
|
|
201
183
|
</Label>
|
|
202
184
|
{endBeforeStart ? (
|
|
@@ -394,7 +376,7 @@ export const EventForm = ({
|
|
|
394
376
|
</h2>
|
|
395
377
|
|
|
396
378
|
<Label
|
|
397
|
-
title={t('
|
|
379
|
+
title={t('common.labels.visibility', { defaultValue: 'Visibility' })}
|
|
398
380
|
description={t('events.form.visibilityNotChangeable', {
|
|
399
381
|
defaultValue:
|
|
400
382
|
"Note: The event visibility cannot be changed once the event is published. Make sure you're adding the right people or group.",
|
|
@@ -205,8 +205,8 @@ export const PostAudienceSelector = ({
|
|
|
205
205
|
<DialogActions
|
|
206
206
|
cancelLabel={
|
|
207
207
|
view !== 'main'
|
|
208
|
-
? t('
|
|
209
|
-
: t('common.cancel', { defaultValue: 'Cancel' })
|
|
208
|
+
? t('common.actions.back', { defaultValue: 'Back' })
|
|
209
|
+
: t('common.actions.cancel', { defaultValue: 'Cancel' })
|
|
210
210
|
}
|
|
211
211
|
onCancel={view !== 'main' ? () => setView('main') : onClose}
|
|
212
212
|
actionLabel={t('common.done', { defaultValue: 'Done' })}
|
|
@@ -330,7 +330,7 @@ export function ReplyModal({ post, onClose }: ReplyModalProps) {
|
|
|
330
330
|
</div>
|
|
331
331
|
<div className="flex gap-2">
|
|
332
332
|
<Button variant="ghost" action={onClose}>
|
|
333
|
-
{t('common.cancel', { defaultValue: 'Cancel' })}
|
|
333
|
+
{t('common.actions.cancel', { defaultValue: 'Cancel' })}
|
|
334
334
|
</Button>
|
|
335
335
|
<Button
|
|
336
336
|
variant="default"
|
|
@@ -289,7 +289,7 @@ export function FullEvent({ post, occurrence }: FullEventProps) {
|
|
|
289
289
|
active={tab === 'description'}
|
|
290
290
|
onClick={() => setTab('description')}
|
|
291
291
|
>
|
|
292
|
-
{t('
|
|
292
|
+
{t('common.labels.description', { defaultValue: 'Description' })}
|
|
293
293
|
</TabButton>
|
|
294
294
|
) : null}
|
|
295
295
|
<TabButton active={tab === 'replies'} onClick={() => setTab('replies')}>
|
|
@@ -571,11 +571,11 @@ function JamRecordingItem({
|
|
|
571
571
|
})}
|
|
572
572
|
</p>
|
|
573
573
|
<DialogActions
|
|
574
|
-
cancelLabel={t('
|
|
574
|
+
cancelLabel={t('common.actions.cancel', {
|
|
575
575
|
defaultValue: 'Cancel',
|
|
576
576
|
})}
|
|
577
577
|
onCancel={() => setConfirmOpen(false)}
|
|
578
|
-
actionLabel={t('
|
|
578
|
+
actionLabel={t('common.actions.delete', {
|
|
579
579
|
defaultValue: 'Delete',
|
|
580
580
|
})}
|
|
581
581
|
onAction={handleDelete}
|
|
@@ -10,6 +10,7 @@ import { ResourceCard } from '../../../resources/ResourceCard';
|
|
|
10
10
|
import { VideoPlayer } from '../../pieces/VideoPlayer';
|
|
11
11
|
import { AudioAttachment } from '../../pieces/AudioAttachment';
|
|
12
12
|
import { GalleryModal } from '../../pieces/GalleryModal';
|
|
13
|
+
import { asDownloadUrl } from '../../../../lib/downloadUrl';
|
|
13
14
|
|
|
14
15
|
export interface FullResourceProps {
|
|
15
16
|
post: PublicPost;
|
|
@@ -36,7 +37,7 @@ export const FullResource = ({ post }: FullResourceProps) => {
|
|
|
36
37
|
const att = resource.attachments?.find(
|
|
37
38
|
(a) => attachmentMediaKind(a) === 'file',
|
|
38
39
|
);
|
|
39
|
-
if (att?.url) window.
|
|
40
|
+
if (att?.url) window.location.assign(asDownloadUrl(att.url));
|
|
40
41
|
break;
|
|
41
42
|
}
|
|
42
43
|
case 'link':
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Play } from 'lucide-react';
|
|
3
|
+
import { videoEmbedForUrl } from '@openpeepshq/common/lib';
|
|
1
4
|
import { LoadingSpinner } from '@openpeepshq/react-ui';
|
|
5
|
+
import { useT } from '../../i18n';
|
|
2
6
|
import { useOpenpeeps } from '../../contexts/openpeeps';
|
|
3
7
|
import { recordOutboundClick } from '../../lib/analyticsClicks';
|
|
4
8
|
|
|
@@ -6,10 +10,40 @@ export interface RemotePreviewLinkProps {
|
|
|
6
10
|
url: string;
|
|
7
11
|
}
|
|
8
12
|
|
|
13
|
+
// Same safety set as the markdown iframe path (see
|
|
14
|
+
// injectIframeSafetyAttrs in @openpeepshq/common/lib); `allow` is trimmed
|
|
15
|
+
// to what video players need.
|
|
16
|
+
const EMBED_SANDBOX =
|
|
17
|
+
'allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-presentation';
|
|
18
|
+
const EMBED_ALLOW = 'autoplay; encrypted-media; picture-in-picture; fullscreen';
|
|
19
|
+
|
|
9
20
|
export function RemotePreviewLink({ url }: RemotePreviewLinkProps) {
|
|
21
|
+
const t = useT();
|
|
10
22
|
const { openpeepsApi } = useOpenpeeps();
|
|
23
|
+
const embed = videoEmbedForUrl(url);
|
|
24
|
+
// Click-to-load: the server-fetched OG card (no third-party request) is
|
|
25
|
+
// the default view; the player mounts only after an explicit action.
|
|
26
|
+
const [loadedUrl, setLoadedUrl] = useState<string | null>(null);
|
|
11
27
|
const previewQuery = openpeepsApi.usePreviewLink(url);
|
|
12
28
|
|
|
29
|
+
if (embed && loadedUrl === url) {
|
|
30
|
+
return (
|
|
31
|
+
<div className="mb-2 w-full">
|
|
32
|
+
<iframe
|
|
33
|
+
src={embed.embedUrl}
|
|
34
|
+
title={t('previewLink.embeddedVideo', {
|
|
35
|
+
defaultValue: 'Embedded video',
|
|
36
|
+
})}
|
|
37
|
+
className="aspect-video w-full rounded-md border-0"
|
|
38
|
+
sandbox={EMBED_SANDBOX}
|
|
39
|
+
allow={EMBED_ALLOW}
|
|
40
|
+
allowFullScreen
|
|
41
|
+
referrerPolicy="no-referrer"
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
13
47
|
if (previewQuery.isLoading) {
|
|
14
48
|
return (
|
|
15
49
|
<div className="text-muted-foreground py-2 text-sm">
|
|
@@ -28,39 +62,72 @@ export function RemotePreviewLink({ url }: RemotePreviewLinkProps) {
|
|
|
28
62
|
/* keep url */
|
|
29
63
|
}
|
|
30
64
|
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
className="hover:bg-surface mb-2 block w-full min-w-0 max-w-full overflow-hidden rounded-md border no-underline"
|
|
37
|
-
onClick={(e) => {
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
recordOutboundClick(url);
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
<div className="flex w-full min-w-0 flex-row items-center gap-4 p-2">
|
|
43
|
-
{data.image ? (
|
|
44
|
-
<div className="flex h-24 w-24 shrink-0 items-center justify-center">
|
|
65
|
+
const card = (
|
|
66
|
+
<div className="flex w-full min-w-0 flex-row items-center gap-4 p-2">
|
|
67
|
+
{data.image || embed ? (
|
|
68
|
+
<div className="relative flex h-24 w-24 shrink-0 items-center justify-center">
|
|
69
|
+
{data.image ? (
|
|
45
70
|
<img
|
|
46
71
|
src={data.image}
|
|
47
72
|
alt={data.title ?? ''}
|
|
48
73
|
className="h-full w-full rounded-md object-cover"
|
|
49
74
|
/>
|
|
50
|
-
</div>
|
|
51
|
-
) : null}
|
|
52
|
-
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
53
|
-
<p className="text-muted-foreground truncate text-xs">{hostname}</p>
|
|
54
|
-
{data.title ? (
|
|
55
|
-
<p className="truncate font-semibold">{data.title}</p>
|
|
56
75
|
) : null}
|
|
57
|
-
{
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
{embed ? (
|
|
77
|
+
<div className="absolute inset-0 flex items-center justify-center">
|
|
78
|
+
<div className="flex size-10 items-center justify-center rounded-full bg-black/60">
|
|
79
|
+
<Play className="size-5 text-white" aria-hidden />
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
61
82
|
) : null}
|
|
62
83
|
</div>
|
|
84
|
+
) : null}
|
|
85
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
86
|
+
<p className="text-muted-foreground truncate text-xs">{hostname}</p>
|
|
87
|
+
{data.title ? (
|
|
88
|
+
<p className="truncate font-semibold">{data.title}</p>
|
|
89
|
+
) : null}
|
|
90
|
+
{data.description ? (
|
|
91
|
+
<p className="text-muted-foreground truncate text-sm">
|
|
92
|
+
{data.description}
|
|
93
|
+
</p>
|
|
94
|
+
) : null}
|
|
63
95
|
</div>
|
|
64
|
-
</
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (!embed) {
|
|
100
|
+
return (
|
|
101
|
+
<a
|
|
102
|
+
href={url}
|
|
103
|
+
target="_blank"
|
|
104
|
+
rel="noreferrer"
|
|
105
|
+
className="hover:bg-surface mb-2 block w-full min-w-0 max-w-full overflow-hidden rounded-md border no-underline"
|
|
106
|
+
onClick={(e) => {
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
recordOutboundClick(url);
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{card}
|
|
112
|
+
</a>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
role="button"
|
|
119
|
+
tabIndex={0}
|
|
120
|
+
aria-label={t('previewLink.playVideo', { defaultValue: 'Play video' })}
|
|
121
|
+
className="hover:bg-surface mb-2 block w-full min-w-0 max-w-full cursor-pointer overflow-hidden rounded-md border"
|
|
122
|
+
onClick={() => setLoadedUrl(url)}
|
|
123
|
+
onKeyDown={(e) => {
|
|
124
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
setLoadedUrl(url);
|
|
127
|
+
}
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
{card}
|
|
131
|
+
</div>
|
|
65
132
|
);
|
|
66
133
|
}
|
|
@@ -58,7 +58,7 @@ const SummaryBody = ({ summary }: { summary: ProfileActivitySummaryData }) => {
|
|
|
58
58
|
>
|
|
59
59
|
<CountCard
|
|
60
60
|
value={summary.postsCount}
|
|
61
|
-
label={t('
|
|
61
|
+
label={t('common.entities.posts', { defaultValue: 'Posts' })}
|
|
62
62
|
testId="profile-activity-posts-count"
|
|
63
63
|
/>
|
|
64
64
|
<CountCard
|
|
@@ -70,7 +70,7 @@ const SummaryBody = ({ summary }: { summary: ProfileActivitySummaryData }) => {
|
|
|
70
70
|
/>
|
|
71
71
|
<CountCard
|
|
72
72
|
value={summary.eventsCount}
|
|
73
|
-
label={t('
|
|
73
|
+
label={t('common.entities.events', { defaultValue: 'Events' })}
|
|
74
74
|
testId="profile-activity-events-count"
|
|
75
75
|
/>
|
|
76
76
|
</CountSection>
|
|
@@ -101,14 +101,14 @@ const SummaryBody = ({ summary }: { summary: ProfileActivitySummaryData }) => {
|
|
|
101
101
|
/>
|
|
102
102
|
<CountCard
|
|
103
103
|
value={summary.bookmarksCount}
|
|
104
|
-
label={t('
|
|
104
|
+
label={t('common.entities.bookmarks', {
|
|
105
105
|
defaultValue: 'Bookmarks',
|
|
106
106
|
})}
|
|
107
107
|
testId="profile-activity-bookmarks-count"
|
|
108
108
|
/>
|
|
109
109
|
<CountCard
|
|
110
110
|
value={summary.groupsCount}
|
|
111
|
-
label={t('
|
|
111
|
+
label={t('common.entities.groups', { defaultValue: 'Groups' })}
|
|
112
112
|
testId="profile-activity-groups-count"
|
|
113
113
|
/>
|
|
114
114
|
</CountSection>
|
|
@@ -29,7 +29,7 @@ export const ProfileBadge = ({
|
|
|
29
29
|
<button
|
|
30
30
|
type="button"
|
|
31
31
|
className="hover:bg-secondary ml-0.5 rounded-full p-0.5 transition-colors"
|
|
32
|
-
title={t('
|
|
32
|
+
title={t('common.actions.remove', { defaultValue: 'Remove' })}
|
|
33
33
|
onClick={(e) => {
|
|
34
34
|
e.stopPropagation();
|
|
35
35
|
onRemove();
|
|
@@ -181,7 +181,7 @@ export function ProfilePageAction({
|
|
|
181
181
|
})}
|
|
182
182
|
</p>
|
|
183
183
|
<DialogActions
|
|
184
|
-
cancelLabel={t('common.cancel', { defaultValue: 'Cancel' })}
|
|
184
|
+
cancelLabel={t('common.actions.cancel', { defaultValue: 'Cancel' })}
|
|
185
185
|
onCancel={() => setBlockOpen(false)}
|
|
186
186
|
actionLabel={t('profile.block.confirm', { defaultValue: 'Block' })}
|
|
187
187
|
onAction={() => void confirmBlock()}
|
|
@@ -49,7 +49,7 @@ export function ProfilePostsAndReplies({
|
|
|
49
49
|
className={`flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'posts' ? 'border-primary border-b-2' : 'text-muted-foreground'}`}
|
|
50
50
|
onClick={() => setTab('posts')}
|
|
51
51
|
>
|
|
52
|
-
{t('
|
|
52
|
+
{t('common.entities.posts', { defaultValue: 'Posts' })}
|
|
53
53
|
</button>
|
|
54
54
|
{isCurrentProfile ? (
|
|
55
55
|
<button
|
|
@@ -66,7 +66,7 @@ export function ProfilePostsAndReplies({
|
|
|
66
66
|
className={`flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'groups' ? 'border-primary border-b-2' : 'text-muted-foreground'}`}
|
|
67
67
|
onClick={() => setTab('groups')}
|
|
68
68
|
>
|
|
69
|
-
{t('
|
|
69
|
+
{t('common.entities.groups', { defaultValue: 'Groups' })}
|
|
70
70
|
</button>
|
|
71
71
|
</nav>
|
|
72
72
|
|
|
@@ -194,7 +194,7 @@ export const ProfileSelector = ({
|
|
|
194
194
|
|
|
195
195
|
{mode === 'multiple' ? (
|
|
196
196
|
<DialogActions
|
|
197
|
-
cancelLabel={t('common.cancel', { defaultValue: 'Cancel' })}
|
|
197
|
+
cancelLabel={t('common.actions.cancel', { defaultValue: 'Cancel' })}
|
|
198
198
|
onCancel={() => onOpenChange(false)}
|
|
199
199
|
actionLabel={t('profile.selector.confirm', { defaultValue: 'OK' })}
|
|
200
200
|
onAction={confirmMultiple}
|
|
@@ -129,7 +129,9 @@ export function ReportProfileOrPostModal({
|
|
|
129
129
|
})}
|
|
130
130
|
/>
|
|
131
131
|
<DialogActions
|
|
132
|
-
cancelLabel={t('common.cancel', {
|
|
132
|
+
cancelLabel={t('common.actions.cancel', {
|
|
133
|
+
defaultValue: 'Cancel',
|
|
134
|
+
})}
|
|
133
135
|
onCancel={onClose}
|
|
134
136
|
actionLabel={t(`reports.create.${reportType}.continue`, {
|
|
135
137
|
defaultValue: 'Continue',
|
|
@@ -156,7 +158,7 @@ export function ReportProfileOrPostModal({
|
|
|
156
158
|
</p>
|
|
157
159
|
) : null}
|
|
158
160
|
<DialogActions
|
|
159
|
-
cancelLabel={t('
|
|
161
|
+
cancelLabel={t('common.actions.back', { defaultValue: 'Back' })}
|
|
160
162
|
onCancel={() => setStep(1)}
|
|
161
163
|
actionLabel={t('reports.create.sendReport', {
|
|
162
164
|
defaultValue: 'Send report',
|
|
@@ -82,7 +82,7 @@ export const CategoryPathPicker = ({
|
|
|
82
82
|
setLevel('');
|
|
83
83
|
}}
|
|
84
84
|
>
|
|
85
|
-
{t('
|
|
85
|
+
{t('common.actions.add', { defaultValue: 'Add' })}
|
|
86
86
|
</Button>
|
|
87
87
|
{path.length ? (
|
|
88
88
|
<Button variant="ghost" action={() => onChange([])}>
|
|
@@ -26,6 +26,7 @@ import { useOpenpeeps } from '../../contexts/openpeeps';
|
|
|
26
26
|
import { useCurrentProfile } from '../layout/IdentityContext';
|
|
27
27
|
import { VideoPlayOverlay } from '../post/VideoPlayOverlay';
|
|
28
28
|
import { TruncatedMarkdown } from '../post/TruncatedMarkdown';
|
|
29
|
+
import { asDownloadUrl } from '../../lib/downloadUrl';
|
|
29
30
|
|
|
30
31
|
export interface ResourceCardProps {
|
|
31
32
|
post: PublicPost;
|
|
@@ -107,7 +108,7 @@ const ResourceSaveButton = ({
|
|
|
107
108
|
title={
|
|
108
109
|
isBookmarked
|
|
109
110
|
? t('resources.actions.saved', { defaultValue: 'Saved' })
|
|
110
|
-
: t('
|
|
111
|
+
: t('common.actions.save', { defaultValue: 'Save' })
|
|
111
112
|
}
|
|
112
113
|
>
|
|
113
114
|
{isBookmarked ? (
|
|
@@ -272,10 +273,11 @@ export const ResourceCard = ({
|
|
|
272
273
|
|
|
273
274
|
if (!resource) return null;
|
|
274
275
|
|
|
275
|
-
const
|
|
276
|
+
const fileUrl =
|
|
276
277
|
resource.resourceKind === 'file'
|
|
277
278
|
? attachments.find((att) => attachmentMediaKind(att) === 'file')?.url
|
|
278
|
-
:
|
|
279
|
+
: undefined;
|
|
280
|
+
const downloadUrl = fileUrl ? asDownloadUrl(fileUrl) : null;
|
|
279
281
|
|
|
280
282
|
const renderSaveButton = (className: string) =>
|
|
281
283
|
staticRender ? null : (
|
|
@@ -8,10 +8,13 @@ import {
|
|
|
8
8
|
import type { ResourceKind } from '@openpeepshq/common/types';
|
|
9
9
|
import { RESOURCE_KINDS } from '@openpeepshq/common/lib';
|
|
10
10
|
import { Button, Input, LoadingSpinner } from '@openpeepshq/react-ui';
|
|
11
|
-
import { useMemo, useState } from 'react';
|
|
11
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
12
12
|
import { useT } from '../../i18n';
|
|
13
|
-
import { useHrefOf } from '../../contexts/router';
|
|
14
|
-
import {
|
|
13
|
+
import { useHrefOf, useRouter, useSearchParams } from '../../contexts/router';
|
|
14
|
+
import {
|
|
15
|
+
useResourceLibrary,
|
|
16
|
+
type ResourceLibraryInitialFilters,
|
|
17
|
+
} from '../../hooks';
|
|
15
18
|
import { ResourceCard } from './ResourceCard';
|
|
16
19
|
import type { CategoryNode } from '@openpeepshq/common/lib';
|
|
17
20
|
|
|
@@ -21,6 +24,11 @@ export interface ResourceLibraryProps {
|
|
|
21
24
|
|
|
22
25
|
const COLLECTION_LIMIT = 5;
|
|
23
26
|
|
|
27
|
+
const parseKindFilter = (value: string | null): ResourceKind | 'all' =>
|
|
28
|
+
value && (RESOURCE_KINDS as readonly string[]).includes(value)
|
|
29
|
+
? (value as ResourceKind)
|
|
30
|
+
: 'all';
|
|
31
|
+
|
|
24
32
|
const Tree = ({
|
|
25
33
|
nodes,
|
|
26
34
|
selected,
|
|
@@ -28,6 +36,7 @@ const Tree = ({
|
|
|
28
36
|
counts,
|
|
29
37
|
expanded,
|
|
30
38
|
onToggle,
|
|
39
|
+
t,
|
|
31
40
|
}: {
|
|
32
41
|
nodes: CategoryNode[];
|
|
33
42
|
selected: string[];
|
|
@@ -35,6 +44,7 @@ const Tree = ({
|
|
|
35
44
|
counts: Map<string, number>;
|
|
36
45
|
expanded: Set<string>;
|
|
37
46
|
onToggle: (nodeKey: string) => void;
|
|
47
|
+
t: ReturnType<typeof useT>;
|
|
38
48
|
}) => (
|
|
39
49
|
<ul className="space-y-1">
|
|
40
50
|
{nodes.map((node) => {
|
|
@@ -52,6 +62,15 @@ const Tree = ({
|
|
|
52
62
|
hasChildren ? '' : 'invisible'
|
|
53
63
|
}`}
|
|
54
64
|
onClick={hasChildren ? () => onToggle(nodeKey) : undefined}
|
|
65
|
+
aria-label={
|
|
66
|
+
isExpanded
|
|
67
|
+
? t('resources.library.collapseFolder', {
|
|
68
|
+
defaultValue: 'Collapse folder',
|
|
69
|
+
})
|
|
70
|
+
: t('resources.library.expandFolder', {
|
|
71
|
+
defaultValue: 'Expand folder',
|
|
72
|
+
})
|
|
73
|
+
}
|
|
55
74
|
>
|
|
56
75
|
<ChevronRight
|
|
57
76
|
className={`size-3 transition-transform ${
|
|
@@ -83,6 +102,7 @@ const Tree = ({
|
|
|
83
102
|
counts={counts}
|
|
84
103
|
expanded={expanded}
|
|
85
104
|
onToggle={onToggle}
|
|
105
|
+
t={t}
|
|
86
106
|
/>
|
|
87
107
|
</div>
|
|
88
108
|
) : null}
|
|
@@ -95,7 +115,50 @@ const Tree = ({
|
|
|
95
115
|
export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
96
116
|
const t = useT();
|
|
97
117
|
const hrefOf = useHrefOf();
|
|
98
|
-
const
|
|
118
|
+
const router = useRouter();
|
|
119
|
+
const searchParams = useSearchParams();
|
|
120
|
+
|
|
121
|
+
// Read the URL once on mount: it seeds the filter state, after which the
|
|
122
|
+
// hook state is the source of truth and the URL a shareable mirror of it.
|
|
123
|
+
const initialFilters = useMemo<ResourceLibraryInitialFilters>(
|
|
124
|
+
() => ({
|
|
125
|
+
kind: parseKindFilter(searchParams.get('kind')),
|
|
126
|
+
tags: searchParams.get('tags')?.split(',').filter(Boolean),
|
|
127
|
+
search: searchParams.get('q') ?? undefined,
|
|
128
|
+
}),
|
|
129
|
+
[],
|
|
130
|
+
);
|
|
131
|
+
const library = useResourceLibrary(groupId, undefined, initialFilters);
|
|
132
|
+
|
|
133
|
+
// Keep a fresh view of the URL so the write-back below can skip no-ops.
|
|
134
|
+
const latestSearch = useRef(searchParams);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
latestSearch.current = searchParams;
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Shareable filters (?kind= &tags=a,b &q=): merged into the existing params
|
|
140
|
+
// so unrelated ones (e.g. ?category=) and the tab hash survive, written
|
|
141
|
+
// with replace so filter changes don't spam the history stack, and
|
|
142
|
+
// debounced so typing a search doesn't re-route on every keystroke.
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
const timer = setTimeout(() => {
|
|
145
|
+
const prev = latestSearch.current;
|
|
146
|
+
const next = new URLSearchParams(prev);
|
|
147
|
+
next.delete('kind');
|
|
148
|
+
next.delete('tags');
|
|
149
|
+
next.delete('q');
|
|
150
|
+
if (library.kind !== 'all') next.set('kind', library.kind);
|
|
151
|
+
if (library.selectedTags.length > 0) {
|
|
152
|
+
next.set('tags', library.selectedTags.join(','));
|
|
153
|
+
}
|
|
154
|
+
const q = library.search.trim();
|
|
155
|
+
if (q) next.set('q', q);
|
|
156
|
+
if (next.toString() === prev.toString()) return;
|
|
157
|
+
router.setSearchParams(next, { replace: true });
|
|
158
|
+
}, 250);
|
|
159
|
+
return () => clearTimeout(timer);
|
|
160
|
+
}, [library.kind, library.selectedTags, library.search, router]);
|
|
161
|
+
|
|
99
162
|
const [expanded, setExpanded] = useState<Set<string>>(new Set());
|
|
100
163
|
|
|
101
164
|
const toggleNode = (nodeKey: string) => {
|
|
@@ -154,6 +217,15 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
|
154
217
|
: sortedTags.slice(0, COLLECTION_LIMIT);
|
|
155
218
|
const hasMoreTags = sortedTags.length > COLLECTION_LIMIT;
|
|
156
219
|
|
|
220
|
+
const folderTreeLabel = t(
|
|
221
|
+
library.hierarchy
|
|
222
|
+
? 'resources.library.hideFolderTree'
|
|
223
|
+
: 'resources.library.showFolderTree',
|
|
224
|
+
{
|
|
225
|
+
defaultValue: library.hierarchy ? 'Hide folder tree' : 'Show folder tree',
|
|
226
|
+
},
|
|
227
|
+
);
|
|
228
|
+
|
|
157
229
|
return (
|
|
158
230
|
<div>
|
|
159
231
|
<div className="flex flex-col gap-3 p-4">
|
|
@@ -250,6 +322,8 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
|
250
322
|
type="button"
|
|
251
323
|
className="text-muted-foreground hover:text-foreground ml-auto"
|
|
252
324
|
onClick={() => library.setHierarchy(!library.hierarchy)}
|
|
325
|
+
title={folderTreeLabel}
|
|
326
|
+
aria-label={folderTreeLabel}
|
|
253
327
|
>
|
|
254
328
|
{library.hierarchy ? (
|
|
255
329
|
<ChevronDown className="size-4" />
|
|
@@ -268,6 +342,7 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
|
|
|
268
342
|
counts={collectionCounts}
|
|
269
343
|
expanded={expanded}
|
|
270
344
|
onToggle={toggleNode}
|
|
345
|
+
t={t}
|
|
271
346
|
/>
|
|
272
347
|
) : null}
|
|
273
348
|
</div>
|