@openpeepshq/react 0.9.23 → 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 +3 -3
- 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 +25 -16
- package/dist/contexts/openpeeps/hooks/admin.d.ts +2 -2
- package/dist/contexts/openpeeps/hooks/auth.d.ts +1 -1
- package/dist/contexts/openpeeps/hooks/other.d.ts +1 -0
- 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 +7 -3
- 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/community/useCommunityConfig.d.ts +2 -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 +19 -5
- 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 +30 -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
|
@@ -16,8 +16,8 @@ export function AdminGroupMembers() {
|
|
|
16
16
|
const membersQuery = openpeepsApi.useGroupMembers(groupQuery.data?.id ?? '');
|
|
17
17
|
const group = groupQuery.data;
|
|
18
18
|
const headerTitle = group
|
|
19
|
-
? `${groupName(group)} - ${t('
|
|
20
|
-
: t('
|
|
19
|
+
? `${groupName(group)} - ${t('common.entities.members', { defaultValue: 'Members' })}`
|
|
20
|
+
: t('common.entities.members', { defaultValue: 'Members' });
|
|
21
21
|
useSetPageHeader(headerTitle);
|
|
22
22
|
if (groupQuery.isLoading || membersQuery.isLoading) {
|
|
23
23
|
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: _jsx(LoadingSpinner, {}) }));
|
|
@@ -26,7 +26,7 @@ export function AdminGroupMembers() {
|
|
|
26
26
|
return (_jsx("div", { className: "p-8 text-center text-2xl", children: t('groups.notFound', { defaultValue: 'Group not found' }) }));
|
|
27
27
|
}
|
|
28
28
|
const members = membersQuery.data ?? [];
|
|
29
|
-
return (_jsx("div", { className: "p-4", children: _jsx("div", { className: "rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-surface", children: _jsxs("tr", { children: [_jsx("th", { className: "p-2 text-left", children: t('admin.members.profileColumn', { defaultValue: 'Profile' }) }), _jsx("th", { className: "p-2 text-left", children: t('
|
|
29
|
+
return (_jsx("div", { className: "p-4", children: _jsx("div", { className: "rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-surface", children: _jsxs("tr", { children: [_jsx("th", { className: "p-2 text-left", children: t('admin.members.profileColumn', { defaultValue: 'Profile' }) }), _jsx("th", { className: "p-2 text-left", children: t('common.labels.handle', { defaultValue: 'Handle' }) }), _jsx("th", { className: "p-2 text-left", children: t('admin.members.rolesColumn', { defaultValue: 'Roles' }) }), _jsx("th", { className: "p-2" })] }) }), _jsx("tbody", { children: members.map((m) => (_jsxs("tr", { className: "border-t", children: [_jsx("td", { className: "p-2", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Avatar, { profile: m.profile, size: 2 }), _jsx("span", { children: m.profile.displayName || `@${m.profile.handle}` })] }) }), _jsxs("td", { className: "text-muted-foreground p-2", children: ["@", m.profile.handle] }), _jsx("td", { className: "p-2 text-xs", children: (m.roles ?? [])
|
|
30
30
|
.map((r) => t(`groups.roles.${r}`, { defaultValue: r }))
|
|
31
31
|
.join(', ') || '—' }), _jsx("td", { className: "p-2 text-right", children: _jsx(MemberRowActions, { group: group, member: m }) })] }, m.profile.id))) })] }) }) }));
|
|
32
32
|
}
|
|
@@ -45,7 +45,7 @@ function MemberRowActions({ group, member, }) {
|
|
|
45
45
|
defaultValue: 'Change Roles',
|
|
46
46
|
}), text: t('groups.changeRoles.title', { defaultValue: 'Change Roles' }), action: () => setActiveModal('roles') }), _jsx(PopupMenuButton, { icon: Trash2, title: t('groups.removeMember.title', {
|
|
47
47
|
defaultValue: 'Remove Member',
|
|
48
|
-
}), text: t('
|
|
48
|
+
}), text: t('common.actions.remove', { defaultValue: 'Remove' }), action: () => setActiveModal('remove'), danger: true })] }), activeModal === 'roles' ? (_jsx(ChangeGroupRolesModal, { group: group, member: member, onClose: () => setActiveModal(null) })) : null, activeModal === 'remove' ? (_jsx(RemoveMemberModal, { group: group, member: member, onClose: () => setActiveModal(null) })) : null] }));
|
|
49
49
|
}
|
|
50
50
|
function RemoveMemberModal({ group, member, onClose, }) {
|
|
51
51
|
const t = useT();
|
|
@@ -70,7 +70,7 @@ function RemoveMemberModal({ group, member, onClose, }) {
|
|
|
70
70
|
return (_jsx(Dialog, { open: true, onOpenChange: (open) => !open && onClose(), children: _jsxs(DialogContent, { className: "max-w-sm", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('groups.removeMember.title', { defaultValue: 'Remove Member' }) }) }), _jsx("p", { className: "px-1 text-sm", children: t('groups.removeMember.description', {
|
|
71
71
|
defaultValue: 'Are you sure you want to remove @{{handle}} from group?',
|
|
72
72
|
handle: member.profile.handle,
|
|
73
|
-
}) }), error ? (_jsx("p", { className: "border-error/40 text-error rounded-md border p-2 text-sm", children: error })) : null, _jsx(DialogActions, { cancelLabel: t('common.cancel', { defaultValue: 'Cancel' }), onCancel: onClose, actionLabel: t('
|
|
73
|
+
}) }), error ? (_jsx("p", { className: "border-error/40 text-error rounded-md border p-2 text-sm", children: error })) : null, _jsx(DialogActions, { cancelLabel: t('common.actions.cancel', { defaultValue: 'Cancel' }), onCancel: onClose, actionLabel: t('common.actions.remove', {
|
|
74
74
|
defaultValue: 'Remove',
|
|
75
75
|
}), onAction: submit, actionVariant: "destructive", disabled: submitting })] }) }));
|
|
76
76
|
}
|
|
@@ -19,7 +19,7 @@ export function AdminGroups() {
|
|
|
19
19
|
defaultValue: 'Create Group',
|
|
20
20
|
});
|
|
21
21
|
const headerActions = useMemo(() => canCreate ? (_jsx(Button, { title: createLabel, variant: "default", action: () => navigate('/groups/new'), children: createLabel })) : undefined, [canCreate, createLabel, navigate]);
|
|
22
|
-
useSetPageHeader(t('
|
|
22
|
+
useSetPageHeader(t('common.entities.groups', { defaultValue: 'Groups' }), headerActions);
|
|
23
23
|
const groups = groupsQuery.data ?? [];
|
|
24
24
|
const filtered = search
|
|
25
25
|
? groups.filter((g) => {
|
|
@@ -59,7 +59,7 @@ function DeleteGroupModal({ group, onClose, }) {
|
|
|
59
59
|
return (_jsx(Dialog, { open: true, onOpenChange: (open) => !open && onClose(), children: _jsxs(DialogContent, { className: "max-w-sm", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('admin.groups.deleteTitle', { defaultValue: 'Delete group' }) }) }), _jsx("p", { className: "px-1 text-sm", children: t('admin.groups.deleteDescription', {
|
|
60
60
|
defaultValue: 'Are you sure you want to delete this group? This action cannot be undone.',
|
|
61
61
|
name: groupName(group),
|
|
62
|
-
}) }), error ? (_jsx("p", { className: "border-error/40 text-error rounded-md border p-2 text-sm", children: error })) : null, _jsx(DialogActions, { cancelLabel: t('common.cancel', { defaultValue: 'Cancel' }), onCancel: onClose, actionLabel: t('admin.groups.delete', {
|
|
62
|
+
}) }), error ? (_jsx("p", { className: "border-error/40 text-error rounded-md border p-2 text-sm", children: error })) : null, _jsx(DialogActions, { cancelLabel: t('common.actions.cancel', { defaultValue: 'Cancel' }), onCancel: onClose, actionLabel: t('admin.groups.delete', {
|
|
63
63
|
defaultValue: 'Delete group',
|
|
64
64
|
}), onAction: submit, actionVariant: "destructive", disabled: submitting })] }) }));
|
|
65
65
|
}
|
|
@@ -26,9 +26,9 @@ export function AdminInvites() {
|
|
|
26
26
|
defaultValue: 'Search by name or handle',
|
|
27
27
|
}), value: search, onChange: (e) => setSearch(e.target.value) }) }), filtered.length === 0 ? (_jsx("div", { className: "flex w-full items-center justify-center p-4", children: _jsx("h2", { className: "text-lg", children: t('admin.invites.noInvitesFound', {
|
|
28
28
|
defaultValue: 'No invites found',
|
|
29
|
-
}) }) })) : (_jsx("div", { className: "rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-surface", children: _jsxs("tr", { children: [_jsx("th", { className: "p-2 text-left", children: t('
|
|
29
|
+
}) }) })) : (_jsx("div", { className: "rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-surface", children: _jsxs("tr", { children: [_jsx("th", { className: "p-2 text-left", children: t('common.labels.link', { defaultValue: 'Link' }) }), _jsx("th", { className: "p-2 text-left", children: t('admin.invites.createdByColumn', {
|
|
30
30
|
defaultValue: 'Created by',
|
|
31
|
-
}) }), _jsx("th", { className: "p-2 text-left", children: t('
|
|
31
|
+
}) }), _jsx("th", { className: "p-2 text-left", children: t('common.entities.groups', { defaultValue: 'Groups' }) }), _jsx("th", { className: "p-2 text-left", children: t('admin.invites.expirationDateColumn', {
|
|
32
32
|
defaultValue: 'Expires',
|
|
33
33
|
}) }), _jsx("th", { className: "p-2 text-left", children: t('admin.invites.usesColumn', { defaultValue: 'Uses' }) }), _jsx("th", { className: "p-2 text-left", children: t('admin.invites.statusColumn', { defaultValue: 'Status' }) }), _jsx("th", { className: "p-2" })] }) }), _jsx("tbody", { children: filtered.map((invite) => {
|
|
34
34
|
const active = invite.active && new Date(invite.expiresAt) > new Date();
|
|
@@ -57,7 +57,7 @@ function InvitesTablePopup({ invite }) {
|
|
|
57
57
|
defaultValue: 'See invited accounts',
|
|
58
58
|
}), text: t('admin.invites.seeInvitedAccounts', {
|
|
59
59
|
defaultValue: 'See invited accounts',
|
|
60
|
-
}), action: () => setShowInvited(true) }), _jsx(PopupMenuButton, { icon: Pencil, title: t('
|
|
60
|
+
}), action: () => setShowInvited(true) }), _jsx(PopupMenuButton, { icon: Pencil, title: t('common.actions.edit', { defaultValue: 'Edit' }), text: t('common.actions.edit', { defaultValue: 'Edit' }), action: () => setShowEdit(true) }), active ? (_jsxs(_Fragment, { children: [_jsx(PopupMenuButton, { icon: Copy, title: t('admin.invites.copyLink', {
|
|
61
61
|
defaultValue: 'Copy link',
|
|
62
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', {
|
|
63
63
|
defaultValue: 'Save as QR code',
|
|
@@ -109,7 +109,7 @@ export const AdminMedia = () => {
|
|
|
109
109
|
inUse: files.length - unusedCount,
|
|
110
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
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('
|
|
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('common.states.loading', { defaultValue: 'Loading…' }) })) : null, mediaQuery.isError ? (_jsx("p", { className: "text-error text-sm", children: t('admin.media.error', {
|
|
113
113
|
defaultValue: 'Could not load media files',
|
|
114
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
115
|
defaultValue: 'Delete now',
|
|
@@ -127,7 +127,7 @@ export const AdminMedia = () => {
|
|
|
127
127
|
})
|
|
128
128
|
: t('admin.media.confirm.unused', {
|
|
129
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('
|
|
130
|
+
}) }), deleteError ? (_jsx("p", { className: "border-error/40 text-error rounded-md border p-2 text-sm", children: deleteError })) : null, _jsx(DialogActions, { cancelLabel: t('common.actions.cancel', {
|
|
131
131
|
defaultValue: 'Cancel',
|
|
132
132
|
}), onCancel: () => setPending(null), actionLabel: t('admin.media.confirm.action', {
|
|
133
133
|
defaultValue: 'Delete file',
|
|
@@ -11,10 +11,10 @@ export function AdminMemberDetail() {
|
|
|
11
11
|
const { profileId = '' } = useParams();
|
|
12
12
|
const summaryQuery = openpeepsApi.admin.useAdminProfileSummary(profileId);
|
|
13
13
|
useSetPageHeader(summaryQuery.data?.profile
|
|
14
|
-
? `${summaryQuery.data.profile.displayName || summaryQuery.data.profile.handle} — ${t('
|
|
15
|
-
: t('
|
|
14
|
+
? `${summaryQuery.data.profile.displayName || summaryQuery.data.profile.handle} — ${t('common.entities.members', { defaultValue: 'Members' })}`
|
|
15
|
+
: t('common.entities.members', { defaultValue: 'Members' }));
|
|
16
16
|
if (summaryQuery.isLoading) {
|
|
17
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
17
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
18
18
|
}
|
|
19
19
|
if (!summaryQuery.data) {
|
|
20
20
|
return (_jsx("div", { className: "p-4", children: t('admin.members.notFound', {
|
|
@@ -42,13 +42,13 @@ export function AdminMemberDetail() {
|
|
|
42
42
|
defaultValue: 'Followers',
|
|
43
43
|
}), value: data.followersCount }), _jsx(StatRow, { label: t('admin.members.following', {
|
|
44
44
|
defaultValue: 'Following',
|
|
45
|
-
}), value: data.followingCount }), _jsx(StatRow, { label: t('
|
|
45
|
+
}), value: data.followingCount }), _jsx(StatRow, { label: t('common.entities.posts', {
|
|
46
46
|
defaultValue: 'Posts',
|
|
47
47
|
}), value: data.activity.postsCount }), _jsx(StatRow, { label: t('admin.members.replies', {
|
|
48
48
|
defaultValue: 'Replies',
|
|
49
|
-
}), value: data.activity.repliesCount }), _jsx(StatRow, { label: t('
|
|
49
|
+
}), value: data.activity.repliesCount }), _jsx(StatRow, { label: t('common.entities.events', {
|
|
50
50
|
defaultValue: 'Events',
|
|
51
|
-
}), value: data.activity.eventsCount }), _jsx(StatRow, { label: t('
|
|
51
|
+
}), value: data.activity.eventsCount }), _jsx(StatRow, { label: t('common.entities.groups', {
|
|
52
52
|
defaultValue: 'Groups',
|
|
53
53
|
}), value: data.activity.groupsCount }), _jsx(StatRow, { label: t('admin.members.reports', {
|
|
54
54
|
defaultValue: 'Reports',
|
|
@@ -56,7 +56,7 @@ export function AdminMemberDetail() {
|
|
|
56
56
|
defaultValue: 'Blocked by',
|
|
57
57
|
}), value: data.blockedByCount }), _jsx(StatRow, { label: t('admin.members.rsvps', {
|
|
58
58
|
defaultValue: 'RSVPs',
|
|
59
|
-
}), value: data.activity.rsvpsCount }), _jsx(StatRow, { label: t('
|
|
59
|
+
}), value: data.activity.rsvpsCount }), _jsx(StatRow, { label: t('common.entities.bookmarks', {
|
|
60
60
|
defaultValue: 'Bookmarks',
|
|
61
61
|
}), value: data.activity.bookmarksCount })] })] })] }), _jsx("div", { className: "mt-6", children: _jsx(Button, { variant: "outline", compact: true, action: () => navigate({ type: 'admin', section: 'members' }), title: t('admin.members.backToMembers', {
|
|
62
62
|
defaultValue: 'Back to members',
|
|
@@ -41,7 +41,7 @@ export function AdminMembers() {
|
|
|
41
41
|
downloadCsv(csv, 'members.csv');
|
|
42
42
|
}, [client]);
|
|
43
43
|
const headerActions = useMemo(() => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", compact: true, action: handleDownload, children: [_jsx(DownloadIcon, { size: 16 }), t('admin.members.downloadCsv', { defaultValue: 'Download CSV' })] }), _jsx(AdminInviteActions, {})] })), [handleDownload, t]);
|
|
44
|
-
useSetPageHeader(t('
|
|
44
|
+
useSetPageHeader(t('common.entities.members', { defaultValue: 'Members' }), headerActions);
|
|
45
45
|
const sorted = useMemo(() => {
|
|
46
46
|
const profiles = profilesQuery.data ?? [];
|
|
47
47
|
const searched = search
|
|
@@ -66,7 +66,7 @@ export function AdminMembers() {
|
|
|
66
66
|
defaultValue: 'No users found',
|
|
67
67
|
}) }) })) : (_jsx("div", { className: "rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-surface", children: _jsxs("tr", { children: [_jsx("th", { className: "p-2 text-left", children: t('admin.members.profileColumn', {
|
|
68
68
|
defaultValue: 'Profile',
|
|
69
|
-
}) }), _jsxs("th", { className: "cursor-pointer select-none p-2 text-left", onClick: () => toggleSort('handle'), children: [t('
|
|
69
|
+
}) }), _jsxs("th", { className: "cursor-pointer select-none p-2 text-left", onClick: () => toggleSort('handle'), children: [t('common.labels.handle', {
|
|
70
70
|
defaultValue: 'Handle',
|
|
71
71
|
}), sort.column === 'handle' &&
|
|
72
72
|
(sort.direction === 'asc' ? (_jsx(ChevronUpIcon, { className: "ml-1 inline h-3 w-3" })) : (_jsx(ChevronDownIcon, { className: "ml-1 inline h-3 w-3" })))] }), _jsx("th", { className: "p-2 text-left", children: t('admin.members.rolesColumn', { defaultValue: 'Roles' }) }), _jsxs("th", { className: "cursor-pointer select-none p-2 text-left", onClick: () => toggleSort('createdAt'), children: [t('admin.members.createdColumn', {
|
|
@@ -19,6 +19,7 @@ const coreTabs = [
|
|
|
19
19
|
to: '/admin/analytics/members',
|
|
20
20
|
labelKey: 'members',
|
|
21
21
|
fallback: 'Members',
|
|
22
|
+
i18nKey: 'common.entities.members',
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
25
|
to: '/admin/analytics/content',
|
|
@@ -34,6 +35,7 @@ const coreTabs = [
|
|
|
34
35
|
to: '/admin/analytics/groups',
|
|
35
36
|
labelKey: 'groups',
|
|
36
37
|
fallback: 'Groups',
|
|
38
|
+
i18nKey: 'common.entities.groups',
|
|
37
39
|
},
|
|
38
40
|
{
|
|
39
41
|
to: '/admin/analytics/reports',
|
|
@@ -107,7 +109,7 @@ export const AnalyticsLayout = () => {
|
|
|
107
109
|
defaultValue: 'Analytics sections',
|
|
108
110
|
}), className: "border-border flex flex-wrap gap-1 border-b", children: tabs.map((tab) => (_jsx(NavLink, { to: tab.to, end: tab.end === true, className: ({ isActive }) => `-mb-px border-b-2 px-3 py-2.5 text-sm font-medium transition-colors ${isActive
|
|
109
111
|
? 'border-foreground text-foreground'
|
|
110
|
-
: 'text-muted-foreground hover:text-foreground border-transparent'}`, children: t(`admin.analytics.tabs.${tab.labelKey}`, {
|
|
112
|
+
: 'text-muted-foreground hover:text-foreground border-transparent'}`, children: t(tab.i18nKey ?? `admin.analytics.tabs.${tab.labelKey}`, {
|
|
111
113
|
defaultValue: tab.fallback,
|
|
112
114
|
}) }, tab.to))) }), _jsx(Outlet, {})] }) }));
|
|
113
115
|
};
|
|
@@ -106,7 +106,7 @@ export const AnalyticsContentPage = () => {
|
|
|
106
106
|
{
|
|
107
107
|
id: 'target',
|
|
108
108
|
type: 'text',
|
|
109
|
-
header: columnHeader(t('
|
|
109
|
+
header: columnHeader(t('common.labels.link', { defaultValue: 'Link' }), info('tableLink', 'Outbound URL origin and path (query strings stripped).')),
|
|
110
110
|
render: (row) => row.target,
|
|
111
111
|
},
|
|
112
112
|
{
|
|
@@ -86,7 +86,7 @@ export const AnalyticsGroupsPage = () => {
|
|
|
86
86
|
{
|
|
87
87
|
id: 'members',
|
|
88
88
|
type: 'text',
|
|
89
|
-
header: columnHeader(t('
|
|
89
|
+
header: columnHeader(t('common.entities.members', {
|
|
90
90
|
defaultValue: 'Members',
|
|
91
91
|
}), info('tableMembers', 'Current total members in the group, with active members underneath (distinct post authors in the group during the range).')),
|
|
92
92
|
render: (g) => (_jsxs("div", { className: "flex flex-col tabular-nums", children: [_jsx("span", { children: g.members.toLocaleString() }), _jsxs("span", { className: "text-muted-foreground text-xs", children: [g.activeMembers.toLocaleString(), ' ', t('admin.analytics.table.activeShort', {
|
|
@@ -58,5 +58,5 @@ export const AnalyticsReportSettingsPage = () => {
|
|
|
58
58
|
defaultValue: 'Recipients',
|
|
59
59
|
}) }), _jsx("textarea", { className: "border-input bg-background min-h-28 w-full rounded-md border px-3 py-2 text-sm", value: recipientsText, onChange: (e) => setRecipientsText(e.target.value), placeholder: "ops@example.com" }), _jsx("span", { className: "text-muted-foreground mt-1 block text-xs", children: t('admin.analytics.reports.recipientsHelp', {
|
|
60
60
|
defaultValue: 'One email per line, or comma-separated.',
|
|
61
|
-
}) })] }), _jsxs("div", { className: "mt-4 flex items-center gap-3", children: [_jsx(Button, { type: "button", size: "sm", disabled: busy, onClick: () => void onSave(), children: t('
|
|
61
|
+
}) })] }), _jsxs("div", { className: "mt-4 flex items-center gap-3", children: [_jsx(Button, { type: "button", size: "sm", disabled: busy, onClick: () => void onSave(), children: t('common.actions.save', { defaultValue: 'Save' }) }), message ? (_jsx("p", { className: "text-muted-foreground text-xs", children: message })) : null] })] }) }));
|
|
62
62
|
};
|
|
@@ -44,7 +44,7 @@ export function AdminConfigurationCommunityAccess() {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
if (configQuery.isLoading || !base) {
|
|
47
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
47
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
48
48
|
}
|
|
49
49
|
return (_jsxs("div", { className: "space-y-6 p-4", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: t('configuration.community.access.description', {
|
|
50
50
|
defaultValue: 'Control who can join your community and who can see it',
|
|
@@ -36,7 +36,7 @@ export function AdminConfigurationCommunityFavicons() {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
if (isLoading || !draft) {
|
|
39
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
39
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
40
40
|
}
|
|
41
41
|
return (_jsxs("div", { className: "relative mb-20 h-full w-full p-4", children: [_jsx("p", { children: t('configuration.community.favicons.title') }), _jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4", children: t('configuration.community.favicons.description') }), _jsxs("div", { className: "mb-2 flex gap-x-6", children: [_jsxs("span", { children: [t('configuration.community.currentIcon'), ":"] }), _jsx("img", { className: "size-8", alt: t('configuration.community.icon'), src: currentIcon })] }), _jsx(Button, { variant: "outline", action: () => inputRef.current?.click(), title: t('configuration.community.upload'), children: t('configuration.community.upload') }), _jsx("input", { ref: inputRef, type: "file", accept: "image/*", className: "hidden", onChange: (e) => {
|
|
42
42
|
const file = e.target.files?.[0];
|
|
@@ -80,7 +80,7 @@ export function AdminConfigurationCommunityForbiddenUsernames() {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
if (configQuery.isLoading) {
|
|
83
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
83
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
84
84
|
}
|
|
85
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
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.',
|
|
@@ -102,5 +102,5 @@ export function AdminConfigurationCommunityForbiddenUsernames() {
|
|
|
102
102
|
defaultValue: 'Add username',
|
|
103
103
|
}), action: addUsername, "data-testid": "admin-forbidden-usernames-add", children: t('configuration.community.forbiddenUsernames.add', {
|
|
104
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.
|
|
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.actions.save', { defaultValue: 'Save' }) })] }));
|
|
106
106
|
}
|
|
@@ -29,7 +29,7 @@ export function AdminConfigurationCommunityInfo() {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
if (isLoading || !draft) {
|
|
32
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
32
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
33
33
|
}
|
|
34
34
|
return (_jsxs("div", { className: "p-4", children: [_jsx(Form, { ...form, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: onSubmit, children: [_jsx(FormField, { control: form.control, name: "info.name", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.name') }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "text", "data-testid": "admin-community-info-name" }) }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "info.tagLine", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.tagline') }), _jsx(FormControl, { children: _jsx(Textarea, { ...field, "data-testid": "admin-community-info-tagline" }) }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "info.contactEmail", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.email') }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "email", value: field.value ?? '', "data-testid": "admin-community-info-email" }) }), _jsx(FormMessage, {})] })) }), _jsx(Button, { type: "submit", variant: "default", title: t('configuration.community.save'), loading: form.formState.isSubmitting, "data-testid": "admin-community-info-save", children: t('configuration.community.save') })] }) }), status ? (_jsx(Toast, { variant: status.type, testId: "admin-community-info-toast", onDismiss: () => setStatus(null), children: status.message })) : null] }));
|
|
35
35
|
}
|
|
@@ -4,7 +4,7 @@ import { useForm } from 'react-hook-form';
|
|
|
4
4
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
5
5
|
import { communityConfigSchema, } from '@openpeepshq/common/types';
|
|
6
6
|
import { useT, useSetPageHeader } from '../../../index.js';
|
|
7
|
-
import { Button, Form, FormControl, FormField, FormItem, FormLabel, FormMessage, Input, Toast, } from '@openpeepshq/react-ui';
|
|
7
|
+
import { Button, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Input, Toast, } from '@openpeepshq/react-ui';
|
|
8
8
|
import { useCommunityConfig } from './useCommunityConfig.js';
|
|
9
9
|
export function AdminConfigurationCommunityLinks() {
|
|
10
10
|
const t = useT();
|
|
@@ -29,7 +29,11 @@ export function AdminConfigurationCommunityLinks() {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
if (isLoading || !draft) {
|
|
32
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
32
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
33
33
|
}
|
|
34
|
-
return (_jsxs("div", { className: "p-4", children: [_jsx(Form, { ...form, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: onSubmit, children: [_jsx(FormField, { control: form.control, name: "info.privacyPolicy", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.privacyPolicy') }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "text", value: field.value ?? '', "data-testid": "admin-community-links-privacy" }) }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "info.termsAndConditions", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.termsAndConditions') }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "text", value: field.value ?? '', "data-testid": "admin-community-links-terms" }) }), _jsx(FormMessage, {})] })) }), _jsx(
|
|
34
|
+
return (_jsxs("div", { className: "p-4", children: [_jsx(Form, { ...form, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: onSubmit, children: [_jsx(FormField, { control: form.control, name: "info.privacyPolicy", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.privacyPolicy') }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "text", value: field.value ?? '', "data-testid": "admin-community-links-privacy" }) }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "info.termsAndConditions", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.termsAndConditions') }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "text", value: field.value ?? '', "data-testid": "admin-community-links-terms" }) }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "info.bugReportUrl", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('configuration.community.bugReportUrl', {
|
|
35
|
+
defaultValue: 'Bug report form URL',
|
|
36
|
+
}) }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "text", value: field.value ?? '', "data-testid": "admin-community-links-bug-report" }) }), _jsx(FormDescription, { children: t('configuration.community.bugReportUrlDescription', {
|
|
37
|
+
defaultValue: 'Link to an external bug report form. When set, a "Report a bug" link appears in the side menu.',
|
|
38
|
+
}) }), _jsx(FormMessage, {})] })) }), _jsx(Button, { type: "submit", variant: "default", title: t('configuration.community.save'), loading: form.formState.isSubmitting, "data-testid": "admin-community-links-save", children: t('configuration.community.save') })] }) }), status ? (_jsx(Toast, { variant: status.type, testId: "admin-community-links-toast", onDismiss: () => setStatus(null), children: status.message })) : null] }));
|
|
35
39
|
}
|
|
@@ -30,7 +30,7 @@ export function CommunityMarkdownPage({ path, titleKey, descriptionKey, }) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
if (isLoading || !draft) {
|
|
33
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
33
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
34
34
|
}
|
|
35
35
|
return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsx(Markdown, { source: t(descriptionKey), className: "pb-2 pt-4 text-sm text-muted-foreground" }), _jsx(OpenpeepsMarkdownInput, { value: value, maxLength: 10000, rows: 18, className: "min-h-[30rem]", onChange: setContent }), _jsx(Button, { variant: "default", action: handleSubmit, title: t('configuration.community.save'), children: t('configuration.community.save') }), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null] }));
|
|
36
36
|
}
|
|
@@ -44,7 +44,7 @@ export function AdminConfigurationCommunityProfileFields() {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
if (configQuery.isLoading) {
|
|
47
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
47
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
48
48
|
}
|
|
49
|
-
return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsx("p", { className: "text-sm", children: t('configuration.profileFields.description') }), fields.map((field, index) => (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("h4", { className: "text-lg font-semibold", children: index + 1 }), _jsx(Label, { title: t('profile.form.fields.label'), children: _jsx(Input, { value: field.label, onChange: (e) => updateField(index, { label: e.target.value }) }) }), _jsx(Label, { title: t('common.form.fieldKey'), children: _jsx(Input, { value: field.key, onChange: (e) => updateField(index, { key: e.target.value }) }) })] }, index))), fields.length ? (_jsxs(Button, { variant: "outline", action: () => setFields((prev) => prev.slice(0, -1)), title: t('common.
|
|
49
|
+
return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsx("p", { className: "text-sm", children: t('configuration.profileFields.description') }), fields.map((field, index) => (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("h4", { className: "text-lg font-semibold", children: index + 1 }), _jsx(Label, { title: t('profile.form.fields.label'), children: _jsx(Input, { value: field.label, onChange: (e) => updateField(index, { label: e.target.value }) }) }), _jsx(Label, { title: t('common.form.fieldKey'), children: _jsx(Input, { value: field.key, onChange: (e) => updateField(index, { key: e.target.value }) }) })] }, index))), fields.length ? (_jsxs(Button, { variant: "outline", action: () => setFields((prev) => prev.slice(0, -1)), title: t('common.actions.remove'), children: [_jsx(MinusSquare, { className: "mr-1 size-4" }), t('common.actions.remove')] })) : null, _jsxs(Button, { variant: "outline", action: () => setFields((prev) => [...prev, { key: '', label: '' }]), title: t('posts.form.poll.addOption'), children: [_jsx(PlusSquare, { className: "mr-1 size-4" }), t('posts.form.poll.addOption')] }), _jsx(Button, { variant: "ghost", action: handleSubmit, title: t('common.actions.save'), children: t('common.actions.save') }), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null] }));
|
|
50
50
|
}
|
|
@@ -42,7 +42,7 @@ function DefaultRoles({ base }) {
|
|
|
42
42
|
await handleSubmit();
|
|
43
43
|
};
|
|
44
44
|
const isDefault = roleOnRegistration === 'pendingmember';
|
|
45
|
-
return (_jsxs("div", { className: "p-4", children: [_jsx("h3", { className: "text-xl font-bold", children: t('admin.configuration.community.defaultRoles.title') }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Label, { title: t('admin.configuration.community.defaultRoles.roleOnRegistration'), description: t('admin.configuration.community.defaultRoles.roleOnRegistrationDescription'), children: _jsxs("select", { className: "op-input", value: roleOnRegistration, onChange: (e) => setRoleOnRegistration(e.target.value), children: [_jsx("option", { value: "pendingmember", children: "Pending Member" }), _jsx("option", { value: "member", children: "Member" })] }) }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Button, { variant: "default", action: handleSubmit, title: t('common.save', { defaultValue: 'Save' }), children: t('common.save', { defaultValue: 'Save' }) }), _jsx(Button, { variant: "outline", action: handleRestoreDefaults, disabled: isDefault, title: t('common.restoreDefaults', {
|
|
45
|
+
return (_jsxs("div", { className: "p-4", children: [_jsx("h3", { className: "text-xl font-bold", children: t('admin.configuration.community.defaultRoles.title') }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Label, { title: t('admin.configuration.community.defaultRoles.roleOnRegistration'), description: t('admin.configuration.community.defaultRoles.roleOnRegistrationDescription'), children: _jsxs("select", { className: "op-input", value: roleOnRegistration, onChange: (e) => setRoleOnRegistration(e.target.value), children: [_jsx("option", { value: "pendingmember", children: "Pending Member" }), _jsx("option", { value: "member", children: "Member" })] }) }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Button, { variant: "default", action: handleSubmit, title: t('common.actions.save', { defaultValue: 'Save' }), children: t('common.actions.save', { defaultValue: 'Save' }) }), _jsx(Button, { variant: "outline", action: handleRestoreDefaults, disabled: isDefault, title: t('common.restoreDefaults', {
|
|
46
46
|
defaultValue: 'Restore defaults',
|
|
47
47
|
}), children: t('common.restoreDefaults', { defaultValue: 'Restore defaults' }) })] }), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null] })] }));
|
|
48
48
|
}
|
|
@@ -97,22 +97,22 @@ function NewRoleForm() {
|
|
|
97
97
|
setDescription('');
|
|
98
98
|
setStatus(null);
|
|
99
99
|
};
|
|
100
|
-
return (_jsxs("div", { className: "flex flex-col gap-3", children: [open ? (_jsxs("div", { className: "flex flex-col gap-3 rounded-md border p-4", children: [_jsx(Label, { htmlFor: "new-role-name", title: t('
|
|
100
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [open ? (_jsxs("div", { className: "flex flex-col gap-3 rounded-md border p-4", children: [_jsx(Label, { htmlFor: "new-role-name", title: t('common.labels.name', {
|
|
101
101
|
defaultValue: 'Name',
|
|
102
|
-
}), required: true, children: _jsx(Input, { id: "new-role-name", value: name, maxLength: 32, placeholder: t('
|
|
102
|
+
}), required: true, children: _jsx(Input, { id: "new-role-name", value: name, maxLength: 32, placeholder: t('common.labels.name', {
|
|
103
103
|
defaultValue: 'Name',
|
|
104
104
|
}), onChange: (e) => {
|
|
105
105
|
setName(e.target.value);
|
|
106
106
|
setStatus(null);
|
|
107
|
-
} }) }), key ? (_jsxs("p", { className: "text-muted-foreground text-xs", children: [t('capabilities.roles.key', { defaultValue: 'Key' }), ":", ' ', _jsx("code", { children: key })] })) : null, _jsx(Label, { htmlFor: "new-role-description", title: t('
|
|
107
|
+
} }) }), key ? (_jsxs("p", { className: "text-muted-foreground text-xs", children: [t('capabilities.roles.key', { defaultValue: 'Key' }), ":", ' ', _jsx("code", { children: key })] })) : null, _jsx(Label, { htmlFor: "new-role-description", title: t('common.labels.description', {
|
|
108
108
|
defaultValue: 'Description',
|
|
109
|
-
}), children: _jsx(Input, { id: "new-role-description", value: description, onChange: (e) => setDescription(e.target.value) }) }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Button, { variant: "default", disabled: !key || creating, action: handleCreate, title: t('
|
|
109
|
+
}), children: _jsx(Input, { id: "new-role-description", value: description, onChange: (e) => setDescription(e.target.value) }) }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Button, { variant: "default", disabled: !key || creating, action: handleCreate, title: t('common.actions.create', { defaultValue: 'Create' }), loadingContent: t('capabilities.roles.creating', {
|
|
110
110
|
defaultValue: 'Creating…',
|
|
111
111
|
}), children: creating
|
|
112
112
|
? t('capabilities.roles.creating', {
|
|
113
113
|
defaultValue: 'Creating…',
|
|
114
114
|
})
|
|
115
|
-
: t('
|
|
115
|
+
: t('common.actions.create', { defaultValue: 'Create' }) }), _jsx(Button, { variant: "outline", action: handleCancel, children: t('common.actions.cancel', { defaultValue: 'Cancel' }) })] })] })) : (_jsx(Button, { variant: "outline", action: () => setOpen(true), title: t('capabilities.roles.newRole', { defaultValue: 'New role' }), children: t('capabilities.roles.newRole', { defaultValue: 'New role' }) })), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null] }));
|
|
116
116
|
}
|
|
117
117
|
export function AdminConfigurationCommunityRoles() {
|
|
118
118
|
const t = useT();
|
|
@@ -128,7 +128,7 @@ export function AdminConfigurationCommunityRoles() {
|
|
|
128
128
|
const loading = configQuery.isLoading || rolesQuery.isLoading || !base || !rolesQuery.data;
|
|
129
129
|
const [activeTab, setActiveTab] = useState(TAB_DEFAULT_ROLE);
|
|
130
130
|
if (loading) {
|
|
131
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
131
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
132
132
|
}
|
|
133
133
|
const tabs = [
|
|
134
134
|
{
|
|
@@ -3,6 +3,7 @@ import { useEffect, useState } from 'react';
|
|
|
3
3
|
import { useT, useSetPageHeader, useOpenpeeps, equal } from '../../../index.js';
|
|
4
4
|
import { Button, ThemeFontSelect, Toast } from '@openpeepshq/react-ui';
|
|
5
5
|
import { useCommunityConfig } from './useCommunityConfig.js';
|
|
6
|
+
import { ThemeColorPreview } from './ThemeColorPreview.js';
|
|
6
7
|
export function AdminConfigurationCommunityTheme() {
|
|
7
8
|
const t = useT();
|
|
8
9
|
const { openpeepsApi } = useOpenpeeps();
|
|
@@ -40,7 +41,7 @@ export function AdminConfigurationCommunityTheme() {
|
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
43
|
if (isLoading || !cfg) {
|
|
43
|
-
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.
|
|
44
|
+
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.states.loading', { defaultValue: 'Loading…' }) }));
|
|
44
45
|
}
|
|
45
46
|
const fileInput = (onChange, label, preview, previewClass = 'h-[400px] w-full bg-contain bg-center bg-no-repeat') => (_jsxs("div", { children: [_jsx("div", { className: previewClass, style: preview ? { backgroundImage: `url(${preview})` } : undefined }), _jsxs("label", { className: "border-primary mt-2 flex cursor-pointer items-center justify-center rounded border-2 border-dashed p-4 text-sm", children: [label, _jsx("input", { type: "file", accept: "image/*", className: "hidden", onChange: (e) => {
|
|
46
47
|
const file = e.target.files?.[0];
|
|
@@ -51,6 +52,6 @@ export function AdminConfigurationCommunityTheme() {
|
|
|
51
52
|
return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4 text-lg font-semibold", children: t('configuration.community.theme.title') }), _jsx("span", { children: t('configuration.community.themeDescription') }), _jsx("div", { className: "mt-2 flex flex-wrap items-center gap-x-4 gap-y-2", children: [
|
|
52
53
|
['OpenpeepsLight', 'configuration.community.lightTheme.mode'],
|
|
53
54
|
['OpenpeepsDark', 'configuration.community.darkTheme.mode'],
|
|
54
|
-
].map(([base, labelKey]) => (_jsxs("label", { className: "flex items-center gap-2", children: [_jsx("input", { type: "radio", className: "h-4 w-4", checked: cfg.theme.base === base, onChange: () => patch((c) => (c.theme.base = base)) }), _jsx("span", { children: t(labelKey) })] }, base))) })] }), _jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4 text-lg font-semibold", children: t('configuration.community.color') }), _jsx("span", { children: t('configuration.community.colorDescription') }), _jsx("div", { className: "mt-
|
|
55
|
+
].map(([base, labelKey]) => (_jsxs("label", { className: "flex items-center gap-2", children: [_jsx("input", { type: "radio", className: "h-4 w-4", checked: cfg.theme.base === base, onChange: () => patch((c) => (c.theme.base = base)) }), _jsx("span", { children: t(labelKey) })] }, base))) })] }), _jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4 text-lg font-semibold", children: t('configuration.community.color') }), _jsx("span", { children: t('configuration.community.colorDescription') }), _jsx("div", { className: "mt-4 grid gap-6 lg:grid-cols-2", children: ['light', 'dark'].map((mode) => (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-2", children: [_jsx("span", { children: t(`configuration.community.${mode}Theme.color`) }), _jsx("input", { className: "border-border !size-8 !rounded-full border [&::-moz-color-swatch]:!m-0 [&::-moz-color-swatch]:!rounded-full [&::-moz-color-swatch]:!border-0 [&::-webkit-color-swatch-wrapper]:!p-0 [&::-webkit-color-swatch]:!rounded-full [&::-webkit-color-swatch]:!border-0", type: "color", value: cfg.theme[mode].primaryHex, onChange: (e) => patch((c) => (c.theme[mode].primaryHex = e.target.value)) }), _jsx("input", { className: "op-input w-32", type: "text", value: cfg.theme[mode].primaryHex, readOnly: true, tabIndex: -1 })] }), _jsx(ThemeColorPreview, { mode: mode, primaryHex: cfg.theme[mode].primaryHex, buttonRadius: cfg.theme[mode].buttonRadius })] }, mode))) })] }), _jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4 text-lg font-semibold", children: t('configuration.community.typographyAndRadii') }), _jsx("div", { className: "mt-2 grid gap-4 sm:grid-cols-2", children: ['light', 'dark'].map((mode) => (_jsxs("div", { className: "space-y-3", children: [_jsx("div", { className: "font-medium", children: t(`configuration.community.${mode}Theme.mode`) }), _jsxs("label", { className: "block text-sm", children: [t('configuration.community.fontFamily'), _jsx(ThemeFontSelect, { className: "op-input mt-1 w-full", "aria-label": t('configuration.community.fontFamily'), value: cfg.theme[mode].fontFamily, onChange: (fontFamily) => patch((c) => (c.theme[mode].fontFamily = fontFamily)) })] }), _jsxs("label", { className: "block text-sm", children: [t('configuration.community.buttonRadius'), _jsx("input", { className: "op-input mt-1 w-full", type: "text", placeholder: "9999px", value: cfg.theme[mode].buttonRadius ?? '', onChange: (e) => patch((c) => (c.theme[mode].buttonRadius =
|
|
55
56
|
e.target.value || undefined)) })] }), _jsxs("label", { className: "block text-sm", children: [t('configuration.community.radius'), _jsx("input", { className: "op-input mt-1 w-full", type: "text", placeholder: "8px", value: cfg.theme[mode].radius ?? '', onChange: (e) => patch((c) => (c.theme[mode].radius = e.target.value || undefined)) })] })] }, mode))) })] }), _jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4 text-lg font-semibold", children: t('configuration.community.authBackground') }), _jsx("span", { children: t('configuration.community.authBackgroundDescription') }), _jsx("div", { className: "flex flex-wrap gap-x-4", children: ['light', 'dark'].map((mode) => fileInput((file) => uploadInto(file, (c, url) => (c.theme[mode].backgroundAuth = url), 'configuration.community.backgroundAuth'), t(`configuration.community.${mode}Theme.uploadAuthBackground`), cfg.theme[mode].backgroundAuth)) }), _jsx("p", { className: "py-3 text-sm", children: t('configuration.community.authBackgroundRequirements') })] }), _jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4 text-lg font-semibold", children: t('configuration.community.background') }), _jsx("span", { children: t('configuration.community.backgroundDescription') }), _jsx("div", { className: "flex flex-wrap gap-x-4", children: ['light', 'dark'].map((mode) => fileInput((file) => uploadInto(file, (c, url) => (c.theme[mode].background = url), 'configuration.community.background'), t(`configuration.community.${mode}Theme.uploadBackground`), cfg.theme[mode].background)) }), _jsx("p", { className: "py-3 text-sm", children: t('configuration.community.backgroundRequirements') })] }), _jsxs("div", { className: "border p-4", children: [_jsx("h4", { className: "my-4 text-lg font-semibold", children: t('configuration.community.logo') }), _jsx("span", { children: t('configuration.community.logoDescription') }), _jsx("div", { className: "flex flex-wrap gap-x-4", children: ['light', 'dark'].map((mode) => (_jsxs("div", { children: [_jsx("div", { className: "mb-2 flex flex-wrap gap-x-6 gap-y-2", children: _jsx("img", { className: "h-20 object-contain", alt: t('configuration.community.logo'), src: cfg.theme[mode].logoSmall ?? '/img/logo-small.png' }) }), fileInput((file) => uploadInto(file, (c, url) => (c.theme[mode].logoSmall = url), 'configuration.community.logo'), t(`configuration.community.${mode}Theme.uploadLogo`), undefined, 'hidden')] }, mode))) }), _jsx("p", { className: "py-3 text-sm", children: t('configuration.community.logoRequirements') })] }), _jsx(Button, { variant: "default", action: handleSubmit, disabled: !base || equal(base, cfg), title: t('configuration.community.save'), children: t('configuration.community.save') }), status ? (_jsx(Toast, { variant: "error", onDismiss: () => setStatus(null), children: status })) : null] }));
|
|
56
57
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Mode = 'light' | 'dark';
|
|
2
|
+
export type ThemeColorPreviewProps = {
|
|
3
|
+
mode: Mode;
|
|
4
|
+
primaryHex: string;
|
|
5
|
+
buttonRadius?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const ThemeColorPreview: ({ mode, primaryHex, buttonRadius, }: ThemeColorPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Bell, Home, Newspaper } from 'lucide-react';
|
|
3
|
+
import { Button, contrastRatio, generateA11yOnColor, hexToTailwindRgbString, themeBackgroundHex, } from '@openpeepshq/react-ui';
|
|
4
|
+
import { useT } from '../../../i18n/index.js';
|
|
5
|
+
// 3:1 is the WCAG 1.4.11 floor for icons and controls against the page
|
|
6
|
+
// background (text needs 4.5:1, so the warning only covers non-text uses).
|
|
7
|
+
const MIN_CONTRAST = 3;
|
|
8
|
+
// Keeps a sentence translatable as one string: the translator places the
|
|
9
|
+
// token where the link belongs, and we splice the styled link in around it.
|
|
10
|
+
const LINK_TOKEN = '{{link}}';
|
|
11
|
+
const splitAroundLink = (sentence) => {
|
|
12
|
+
const i = sentence.indexOf(LINK_TOKEN);
|
|
13
|
+
return i < 0
|
|
14
|
+
? { before: sentence, after: '' }
|
|
15
|
+
: {
|
|
16
|
+
before: sentence.slice(0, i),
|
|
17
|
+
after: sentence.slice(i + LINK_TOKEN.length),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const themeName = {
|
|
21
|
+
light: 'OpenpeepsLight',
|
|
22
|
+
dark: 'OpenpeepsDark',
|
|
23
|
+
};
|
|
24
|
+
export const ThemeColorPreview = ({ mode, primaryHex, buttonRadius, }) => {
|
|
25
|
+
const t = useT();
|
|
26
|
+
const ratio = contrastRatio(primaryHex, themeBackgroundHex[mode]);
|
|
27
|
+
const channels = hexToTailwindRgbString(primaryHex);
|
|
28
|
+
const valid = channels !== '(invalid)';
|
|
29
|
+
const { before: articleBefore, after: articleAfter } = splitAroundLink(t('configuration.community.preview.articleText', { link: LINK_TOKEN }));
|
|
30
|
+
const style = valid
|
|
31
|
+
? {
|
|
32
|
+
'--color-primary': channels,
|
|
33
|
+
'--color-primary-foreground': generateA11yOnColor(primaryHex.startsWith('#') ? primaryHex : `#${primaryHex}`),
|
|
34
|
+
'--theme-rounded-base': buttonRadius?.trim() || '9999px',
|
|
35
|
+
}
|
|
36
|
+
: undefined;
|
|
37
|
+
const linkKeys = [
|
|
38
|
+
'configuration.community.preview.linkGuidelines',
|
|
39
|
+
'configuration.community.preview.linkEvents',
|
|
40
|
+
'configuration.community.preview.linkMembers',
|
|
41
|
+
];
|
|
42
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [ratio !== null && ratio < MIN_CONTRAST ? (_jsx("p", { className: "text-destructive text-sm", role: "status", children: t('configuration.community.contrastPoor', {
|
|
43
|
+
mode: t(`configuration.community.${mode}Theme.mode`),
|
|
44
|
+
ratio: ratio.toFixed(1),
|
|
45
|
+
}) })) : null, _jsx("div", { "aria-hidden": "true", "data-theme": themeName[mode], style: style, className: "pointer-events-none bg-background text-foreground overflow-hidden rounded-lg border", children: _jsxs("div", { className: "grid", children: [_jsxs("div", { className: "border-b p-3", children: [_jsx("p", { className: "text-muted-foreground mb-2 text-xs font-medium", children: t('configuration.community.preview.navigation') }), _jsxs("div", { className: "text-foreground/70 flex items-center gap-2 rounded-md px-2 py-1.5 text-sm", children: [_jsx(Home, { className: "size-4" }), t('configuration.community.preview.home')] }), _jsxs("div", { className: "text-primary flex items-center gap-2 rounded-md px-2 py-1.5 text-sm font-bold", children: [_jsx(Newspaper, { className: "size-4" }), t('configuration.community.preview.feed')] }), _jsxs("div", { className: "text-foreground/70 flex items-center gap-2 rounded-md px-2 py-1.5 text-sm", children: [_jsx(Bell, { className: "size-4" }), t('configuration.community.preview.notifications')] }), _jsx(Button, { className: "mt-3", size: "sm", variant: "default", tabIndex: -1, children: t('configuration.community.preview.join') })] }), _jsxs("div", { className: "p-3", children: [_jsx("p", { className: "text-muted-foreground mb-2 text-xs font-medium", children: t('configuration.community.preview.article') }), _jsx("p", { className: "text-sm font-semibold", children: t('configuration.community.preview.articleTitle') }), _jsxs("p", { className: "mt-1 text-sm", children: [articleBefore, _jsx("span", { className: "text-primary underline", children: t('configuration.community.preview.articleLink') }), articleAfter] }), _jsx("p", { className: "text-muted-foreground mb-1 mt-3 text-xs font-medium", children: t('configuration.community.preview.links') }), _jsx("ul", { className: "space-y-1", children: linkKeys.map((key) => (_jsx("li", { children: _jsx("span", { className: "text-primary text-sm underline", children: t(key) }) }, key))) })] })] }) })] }));
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
import { act, createElement } from 'react';
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { ThemeColorPreview } from './ThemeColorPreview.js';
|
|
6
|
+
vi.mock('../../../i18n', () => ({
|
|
7
|
+
useT: () => (key, opts) => opts ? `${key}:${opts.mode}:${opts.ratio}` : key,
|
|
8
|
+
}));
|
|
9
|
+
describe('ThemeColorPreview', () => {
|
|
10
|
+
let root;
|
|
11
|
+
let container;
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
14
|
+
container = document.createElement('div');
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
root = createRoot(container);
|
|
17
|
+
});
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
act(() => root.unmount());
|
|
20
|
+
container.remove();
|
|
21
|
+
});
|
|
22
|
+
const render = (primaryHex, mode = 'light') => {
|
|
23
|
+
act(() => {
|
|
24
|
+
root.render(createElement(ThemeColorPreview, {
|
|
25
|
+
mode,
|
|
26
|
+
primaryHex,
|
|
27
|
+
buttonRadius: '4px',
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
it('shows navigation, a button, and article links in that theme', () => {
|
|
32
|
+
render('#0c90a7', 'dark');
|
|
33
|
+
const preview = container.querySelector('[data-theme="OpenpeepsDark"]');
|
|
34
|
+
expect(preview).not.toBeNull();
|
|
35
|
+
expect(preview?.textContent).toContain('configuration.community.preview.navigation');
|
|
36
|
+
expect(preview?.textContent).toContain('configuration.community.preview.join');
|
|
37
|
+
expect(preview?.textContent).toContain('configuration.community.preview.linkGuidelines');
|
|
38
|
+
expect(preview?.getAttribute('style')).toContain('--color-primary: 12 144 167');
|
|
39
|
+
expect(preview?.getAttribute('style')).toContain('--theme-rounded-base: 4px');
|
|
40
|
+
});
|
|
41
|
+
it('warns when the color blends into the theme background', () => {
|
|
42
|
+
render('#ffffff', 'light');
|
|
43
|
+
expect(container.textContent).toContain('configuration.community.contrastPoor:configuration.community.lightTheme.mode:1.0');
|
|
44
|
+
});
|
|
45
|
+
it('stays quiet for a color that clears the background', () => {
|
|
46
|
+
render('#0c90a7', 'light');
|
|
47
|
+
expect(container.textContent).not.toContain('configuration.community.contrastPoor');
|
|
48
|
+
});
|
|
49
|
+
});
|