@openpeepshq/react 0.8.5 → 0.9.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/conversations/DirectMessageSearch.d.ts +7 -0
- package/dist/components/conversations/DirectMessageSearch.js +46 -0
- package/dist/components/conversations/MessageInThread.d.ts +2 -1
- package/dist/components/conversations/MessageInThread.js +3 -3
- package/dist/components/conversations/index.d.ts +1 -0
- package/dist/components/conversations/index.js +1 -0
- package/dist/components/post/pieces/modals/DeletePostModal.js +4 -4
- package/dist/components/post/post-form/ArticleForm.d.ts +4 -1
- package/dist/components/post/post-form/ArticleForm.js +8 -3
- package/dist/components/post/post-form/EventForm.d.ts +4 -1
- package/dist/components/post/post-form/EventForm.js +8 -4
- package/dist/components/post/post-form/NewPostModal.js +4 -5
- package/dist/components/post/post-form/OpenpeepsMarkdownInput.js +7 -1
- package/dist/components/post/post-form/OpenpeepsMarkdownInput.test.d.ts +1 -0
- package/dist/components/post/post-form/OpenpeepsMarkdownInput.test.js +64 -0
- package/dist/contexts/openpeeps/hooks/conversations.d.ts +3 -2
- package/dist/contexts/openpeeps/hooks/conversations.js +8 -1
- package/dist/hooks/events/useEventComposer.d.ts +3 -0
- package/dist/hooks/events/useEventComposer.js +24 -1
- package/dist/hooks/posts/useArticleComposer.d.ts +3 -0
- package/dist/hooks/posts/useArticleComposer.js +24 -1
- package/dist/pages/admin/ConfigurationCommunity.js +1 -1
- package/dist/pages/admin/community/CommunityAccess.d.ts +6 -0
- package/dist/pages/admin/community/CommunityAccess.js +60 -0
- package/dist/pages/articles/New.js +2 -2
- package/dist/pages/conversations/Index.js +17 -11
- package/dist/pages/conversations/Show.js +63 -12
- package/dist/pages/events/New.js +2 -2
- package/dist/pages/groups/Index.js +1 -1
- package/dist/pages/index.d.ts +1 -0
- package/dist/pages/index.js +1 -0
- package/package.json +5 -5
- package/src/components/conversations/DirectMessageSearch.tsx +130 -0
- package/src/components/conversations/MessageInThread.tsx +9 -2
- package/src/components/conversations/index.ts +1 -0
- package/src/components/post/pieces/modals/DeletePostModal.tsx +11 -9
- package/src/components/post/post-form/ArticleForm.tsx +28 -1
- package/src/components/post/post-form/EventForm.tsx +28 -2
- package/src/components/post/post-form/NewPostModal.tsx +5 -11
- package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +8 -1
- package/src/contexts/openpeeps/hooks/conversations.ts +16 -3
- package/src/hooks/events/useEventComposer.ts +29 -1
- package/src/hooks/posts/useArticleComposer.ts +29 -1
- package/src/pages/admin/ConfigurationCommunity.tsx +4 -0
- package/src/pages/admin/community/CommunityAccess.tsx +129 -0
- package/src/pages/articles/New.tsx +10 -1
- package/src/pages/conversations/Index.tsx +51 -32
- package/src/pages/conversations/Show.tsx +97 -18
- package/src/pages/events/New.tsx +10 -1
- package/src/pages/groups/Index.tsx +1 -1
- package/src/pages/index.ts +1 -0
|
@@ -6,10 +6,10 @@ import { useNewArticle } from '../../hooks/index.js';
|
|
|
6
6
|
import { Button, Toast } from '@openpeepshq/react-ui';
|
|
7
7
|
export function NewArticle() {
|
|
8
8
|
const t = useT();
|
|
9
|
-
const { postData, setPostData, canSubmit, submitting, error, clearError, submit, } = useNewArticle();
|
|
9
|
+
const { postData, setPostData, canSubmit, submitting, error, clearError, notify, setNotify, showNotify, submit, } = useNewArticle();
|
|
10
10
|
const headerActions = useMemo(() => (_jsx(Button, { title: t('articles.create.title', { defaultValue: 'Create article' }), variant: "default", action: submit, disabled: submitting || !canSubmit, children: submitting
|
|
11
11
|
? t('common.submitting', { defaultValue: 'Publishing…' })
|
|
12
12
|
: t('articles.create.title', { defaultValue: 'Create article' }) })), [canSubmit, submit, submitting, t]);
|
|
13
13
|
useSetPageHeader(t('articles.new', { defaultValue: 'New article' }), headerActions);
|
|
14
|
-
return (_jsxs("div", { className: "pb-12", children: [_jsx(ArticleForm, { postData: postData, onChange: setPostData }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
14
|
+
return (_jsxs("div", { className: "pb-12", children: [_jsx(ArticleForm, { postData: postData, onChange: setPostData, showNotify: showNotify, notify: notify, onNotifyChange: setNotify }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
15
15
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
4
|
import { MessageCircleOff, Calendar, MessageSquarePlus } from 'lucide-react';
|
|
4
5
|
import { canCreatePost, formatBadgeCount, truncateText, } from '@openpeepshq/common';
|
|
5
6
|
import { useT, useOpenpeeps, useSetPlusButtonActions, useSetPageHeader, } from '../../index.js';
|
|
6
|
-
import { Avatar, PostMarkdown, useAuthData, useCurrentProfile, useCreateNewConversation, AccessDeniedLoader, } from '../../components/index.js';
|
|
7
|
+
import { Avatar, DirectMessageSearch, PostMarkdown, useAuthData, useCurrentProfile, useCreateNewConversation, AccessDeniedLoader, } from '../../components/index.js';
|
|
7
8
|
import { UpdatingDate } from '@openpeepshq/react-ui';
|
|
8
9
|
function ChatPreview({ conversation, unreadCount = 0, }) {
|
|
9
10
|
const t = useT();
|
|
@@ -29,6 +30,7 @@ function TabButton({ onClick, className, children, }) {
|
|
|
29
30
|
}
|
|
30
31
|
export function ConversationsIndex() {
|
|
31
32
|
const t = useT();
|
|
33
|
+
const navigate = useNavigate();
|
|
32
34
|
const { openpeepsApi } = useOpenpeeps();
|
|
33
35
|
const { openCreateConversation } = useCreateNewConversation();
|
|
34
36
|
const authData = useAuthData();
|
|
@@ -38,6 +40,8 @@ export function ConversationsIndex() {
|
|
|
38
40
|
const unseenByConversation = unseenCountsQuery.data?.direct ?? {};
|
|
39
41
|
const canCreate = canCreatePost(authData, 'note', 'direct');
|
|
40
42
|
const [tab, setTab] = useState('active');
|
|
43
|
+
const [messageSearch, setMessageSearch] = useState('');
|
|
44
|
+
const searching = messageSearch.trim().length >= 2;
|
|
41
45
|
const conversations = (tab === 'active' ? query.data : archivedQuery.data) ?? [];
|
|
42
46
|
const plusButton = useMemo(() => canCreate
|
|
43
47
|
? {
|
|
@@ -58,14 +62,16 @@ export function ConversationsIndex() {
|
|
|
58
62
|
? 'border-primary border-b-2 font-semibold'
|
|
59
63
|
: 'text-muted-foreground hover:text-foreground', children: t('conversations.tabs.archived', { defaultValue: 'Archived' }) })] })), [tab, t]);
|
|
60
64
|
useSetPageHeader(t('navigation.messages', { defaultValue: 'Messages' }), headerActions, 'conversations-page-heading');
|
|
61
|
-
return (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
return (_jsxs("div", { children: [activeQuery.isError ? null : (_jsx(DirectMessageSearch, { onQueryChange: setMessageSearch, onSelect: (hit) => {
|
|
66
|
+
navigate(`/conversations/${hit.conversationId}?message=${hit.message.id}`);
|
|
67
|
+
} })), searching ? null : (_jsx(AccessDeniedLoader, { queries: [activeQuery], children: conversations.length === 0 ? (_jsxs("div", { className: "flex h-[80vh] items-center justify-center gap-2", children: [_jsx(MessageCircleOff, { size: 40 }), _jsx("p", { className: "text-muted-foreground", children: t('conversations.empty', {
|
|
68
|
+
defaultValue: 'No direct messages here',
|
|
69
|
+
}) })] })) : (_jsx("div", { children: conversations.map((conversation) => {
|
|
70
|
+
const first = conversation[0];
|
|
71
|
+
if (!first)
|
|
72
|
+
return null;
|
|
73
|
+
return (_jsx("a", { href: `/conversations/${first.id}`, className: "hover:bg-surface block text-left transition-all", title: t('conversations.open', {
|
|
74
|
+
defaultValue: 'Open conversation',
|
|
75
|
+
}), children: _jsx(ChatPreview, { conversation: conversation, unreadCount: unseenByConversation[first.id] ?? 0 }) }, first.id));
|
|
76
|
+
}) })) }))] }));
|
|
71
77
|
}
|
|
@@ -1,25 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { useParams } from 'react-router-dom';
|
|
4
|
-
import { Info } from 'lucide-react';
|
|
3
|
+
import { useParams, useSearchParams } from 'react-router-dom';
|
|
4
|
+
import { Info, Search } from 'lucide-react';
|
|
5
5
|
import { useT, useOpenpeeps, useSetPageHeader, usePostViewFlush, adjustUnseenCounts, useNavigate, } from '../../index.js';
|
|
6
6
|
import { canCreatePost } from '@openpeepshq/common';
|
|
7
|
-
import { Avatar, ConversationParticipantsModal, MessageInThread, OpenpeepsMarkdownInput, ProfileCard, useAuthData, useCurrentProfile, useToast, } from '../../components/index.js';
|
|
7
|
+
import { Avatar, ConversationParticipantsModal, DirectMessageSearch, MessageInThread, OpenpeepsMarkdownInput, ProfileCard, useAuthData, useCurrentProfile, useToast, } from '../../components/index.js';
|
|
8
8
|
import { Button, LoadingSpinner } from '@openpeepshq/react-ui';
|
|
9
9
|
const MAX_LENGTH = 500;
|
|
10
|
+
const isMessageId = (value) => !!value &&
|
|
11
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
10
12
|
export function ConversationShow() {
|
|
11
13
|
const t = useT();
|
|
12
14
|
const { id = '' } = useParams();
|
|
15
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
16
|
+
const messageParam = searchParams.get('message');
|
|
17
|
+
const focusId = isMessageId(messageParam) ? messageParam : undefined;
|
|
13
18
|
const { openpeepsApi, queryClient, client } = useOpenpeeps();
|
|
14
19
|
const me = useCurrentProfile();
|
|
15
20
|
const authData = useAuthData();
|
|
16
21
|
const toast = useToast();
|
|
17
22
|
const endRef = useRef(null);
|
|
18
|
-
const conversationQuery = openpeepsApi.useConversation(id);
|
|
23
|
+
const conversationQuery = openpeepsApi.useConversation(id, focusId);
|
|
19
24
|
const createMessage = openpeepsApi.createConversationPostAction({ id });
|
|
20
25
|
const markPostsSeen = openpeepsApi.markPostsSeenAction();
|
|
21
26
|
const flushPostViews = usePostViewFlush();
|
|
22
|
-
|
|
27
|
+
// Keep the open thread visible while a search hit refetches an older
|
|
28
|
+
// message. Switching conversations clears it so the previous thread
|
|
29
|
+
// does not linger.
|
|
30
|
+
const [shownMessages, setShownMessages] = useState([]);
|
|
31
|
+
const [shownFor, setShownFor] = useState(id);
|
|
32
|
+
const [searchOpen, setSearchOpen] = useState(false);
|
|
33
|
+
if (shownFor !== id) {
|
|
34
|
+
setShownFor(id);
|
|
35
|
+
setShownMessages([]);
|
|
36
|
+
setSearchOpen(false);
|
|
37
|
+
}
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (conversationQuery.data)
|
|
40
|
+
setShownMessages(conversationQuery.data);
|
|
41
|
+
}, [conversationQuery.data]);
|
|
42
|
+
const messages = shownMessages;
|
|
23
43
|
const lastMessage = messages[messages.length - 1];
|
|
24
44
|
const participants = lastMessage?.audience?.filter((a) => a.id !== me?.id) ?? [];
|
|
25
45
|
const hasLeft = lastMessage?.profile?.id === me?.id &&
|
|
@@ -39,9 +59,16 @@ export function ConversationShow() {
|
|
|
39
59
|
return (_jsx("button", { type: "button", className: "min-w-0 truncate text-left text-xl font-semibold", onClick: () => setParticipantsOpen(true), title: openParticipantsLabel, "aria-haspopup": "dialog", "data-testid": "conversation-participants-open", children: participantNames }));
|
|
40
60
|
}, [multipleParticipants, participantNames, openParticipantsLabel]);
|
|
41
61
|
const navigate = useNavigate();
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
const searchLabel = searchOpen
|
|
63
|
+
? t('common.close', { defaultValue: 'Close' })
|
|
64
|
+
: t('conversations.search.toggle', {
|
|
65
|
+
defaultValue: 'Search this conversation',
|
|
66
|
+
});
|
|
67
|
+
const headerActions = useMemo(() => (_jsxs("div", { className: "flex items-center", children: [_jsx("button", { type: "button", onClick: () => setSearchOpen((open) => !open), title: searchLabel, "aria-label": searchLabel, "aria-expanded": searchOpen, "aria-controls": searchOpen ? 'conversation-message-search' : undefined, "data-testid": "conversation-search-toggle", className: `rounded-md p-1.5 ${searchOpen
|
|
68
|
+
? 'bg-muted text-foreground'
|
|
69
|
+
: 'text-muted-foreground hover:text-foreground'}`, children: _jsx(Search, { size: 18 }) }), _jsx("button", { type: "button", onClick: () => navigate({ type: 'conversation', id, view: 'info' }), title: t('conversations.info.title', {
|
|
70
|
+
defaultValue: 'Conversation info',
|
|
71
|
+
}), className: "text-muted-foreground hover:text-foreground rounded-md p-1.5", children: _jsx(Info, { size: 18 }) })] })), [id, navigate, searchLabel, searchOpen, t]);
|
|
45
72
|
useSetPageHeader(headerTitle, headerActions);
|
|
46
73
|
const [text, setText] = useState('');
|
|
47
74
|
const [sending, setSending] = useState(false);
|
|
@@ -74,8 +101,27 @@ export function ConversationShow() {
|
|
|
74
101
|
}
|
|
75
102
|
};
|
|
76
103
|
useEffect(() => {
|
|
104
|
+
if (focusId)
|
|
105
|
+
return;
|
|
77
106
|
endRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
78
|
-
}, [messages.length]);
|
|
107
|
+
}, [messages.length, focusId]);
|
|
108
|
+
// The ?message= param sticks around after focusing, so scroll only the
|
|
109
|
+
// first time the message renders — re-scrolling on every messages change
|
|
110
|
+
// would fight the user while they read.
|
|
111
|
+
const scrolledToMessageRef = useRef(null);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (!focusId) {
|
|
114
|
+
scrolledToMessageRef.current = null;
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (scrolledToMessageRef.current === focusId)
|
|
118
|
+
return;
|
|
119
|
+
const element = document.querySelector(`[data-message-id="${focusId}"]`);
|
|
120
|
+
if (!element)
|
|
121
|
+
return;
|
|
122
|
+
scrolledToMessageRef.current = focusId;
|
|
123
|
+
element.scrollIntoView({ block: 'center' });
|
|
124
|
+
}, [focusId, messages]);
|
|
79
125
|
useEffect(() => {
|
|
80
126
|
if (!id)
|
|
81
127
|
return;
|
|
@@ -106,13 +152,18 @@ export function ConversationShow() {
|
|
|
106
152
|
return;
|
|
107
153
|
void markPostsSeen({ postIds: unseenIds });
|
|
108
154
|
}, [id, me, messages, conversationQuery.isLoading, markPostsSeen]);
|
|
109
|
-
if (conversationQuery.isLoading) {
|
|
155
|
+
if (conversationQuery.isLoading && messages.length === 0) {
|
|
110
156
|
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: _jsx(LoadingSpinner, {}) }));
|
|
111
157
|
}
|
|
112
158
|
const overLimit = text.length > MAX_LENGTH;
|
|
113
|
-
return (_jsxs("div", { className: "flex h-[calc(100vh-8rem)] flex-col", children: [_jsx("header", { className: "border-b", children: participants.length === 1 && participants[0] ? (_jsx(ProfileCard, { profile: participants[0], showAction: false })) : multipleParticipants ? (_jsxs("button", { type: "button", className: "flex w-full min-w-0 items-center gap-2 p-3 text-left", onClick: () => setParticipantsOpen(true), title: openParticipantsLabel, "aria-haspopup": "dialog", children: [_jsx("div", { className: "flex shrink-0 -space-x-2", children: participants.slice(0, 4).map((p) => (_jsx(Avatar, { profile: p, size: 2.25, borderless: true }, p.id))) }), _jsx("div", { className: "min-w-0 truncate text-sm font-medium", children: participantNames })] })) : null }), _jsx(ConversationParticipantsModal, { open: participantsOpen, onOpenChange: setParticipantsOpen, participants: participants }),
|
|
159
|
+
return (_jsxs("div", { className: "flex h-[calc(100vh-8rem)] flex-col", children: [_jsx("header", { className: "border-b", children: participants.length === 1 && participants[0] ? (_jsx(ProfileCard, { profile: participants[0], showAction: false })) : multipleParticipants ? (_jsxs("button", { type: "button", className: "flex w-full min-w-0 items-center gap-2 p-3 text-left", onClick: () => setParticipantsOpen(true), title: openParticipantsLabel, "aria-haspopup": "dialog", children: [_jsx("div", { className: "flex shrink-0 -space-x-2", children: participants.slice(0, 4).map((p) => (_jsx(Avatar, { profile: p, size: 2.25, borderless: true }, p.id))) }), _jsx("div", { className: "min-w-0 truncate text-sm font-medium", children: participantNames })] })) : null }), _jsx(ConversationParticipantsModal, { open: participantsOpen, onOpenChange: setParticipantsOpen, participants: participants }), searchOpen ? (_jsx("div", { id: "conversation-message-search", children: _jsx(DirectMessageSearch, { conversationId: id, autoFocus: true, onSelect: (hit) => {
|
|
160
|
+
const next = new URLSearchParams(searchParams);
|
|
161
|
+
next.set('message', hit.message.id);
|
|
162
|
+
setSearchParams(next);
|
|
163
|
+
setSearchOpen(false);
|
|
164
|
+
} }) })) : null, _jsxs("div", { role: "log", "aria-live": "polite", "aria-label": t('conversations.messageLog', {
|
|
114
165
|
defaultValue: 'Messages',
|
|
115
|
-
}), className: "flex-1 overflow-y-auto px-3", children: [messages.map((m, index) => (_jsx(MessageInThread, { previous: messages[index - 1], message: m, multipleParticipants: multipleParticipants, conversationRootId: id }, m.id))), _jsx("div", { ref: endRef })] }), canCreate && (_jsxs("footer", { className: "space-y-2 border-t p-3", children: [_jsx(OpenpeepsMarkdownInput, { rows: 3, value: text, onChange: setText, maxLength: MAX_LENGTH, placeholder: t('conversations.placeholder', {
|
|
166
|
+
}), className: "flex-1 overflow-y-auto px-3", children: [messages.map((m, index) => (_jsx(MessageInThread, { previous: messages[index - 1], message: m, multipleParticipants: multipleParticipants, conversationRootId: id, highlighted: m.id === focusId }, m.id))), _jsx("div", { ref: endRef })] }), canCreate && (_jsxs("footer", { className: "space-y-2 border-t p-3", children: [_jsx(OpenpeepsMarkdownInput, { rows: 3, value: text, onChange: setText, maxLength: MAX_LENGTH, placeholder: t('conversations.placeholder', {
|
|
116
167
|
defaultValue: 'Write a message…',
|
|
117
168
|
}) }), _jsx("div", { className: "flex justify-end", children: _jsx(Button, { title: "Send", variant: "default", action: send, disabled: sending || !text.trim() || overLimit, children: sending
|
|
118
169
|
? t('common.sending', { defaultValue: 'Sending…' })
|
package/dist/pages/events/New.js
CHANGED
|
@@ -6,10 +6,10 @@ import { EventForm } from '../../components/index.js';
|
|
|
6
6
|
import { Button, Toast } from '@openpeepshq/react-ui';
|
|
7
7
|
export function NewEvent() {
|
|
8
8
|
const t = useT();
|
|
9
|
-
const { postData, setPostData, canSubmit, submitting, error, clearError, submit, } = useNewEvent();
|
|
9
|
+
const { postData, setPostData, canSubmit, submitting, error, clearError, notify, setNotify, showNotify, submit, } = useNewEvent();
|
|
10
10
|
const headerActions = useMemo(() => (_jsx(Button, { title: t('events.create.title', { defaultValue: 'Create Event' }), variant: "default", action: submit, disabled: submitting || !canSubmit, "data-testid": "events-create-submit", children: submitting
|
|
11
11
|
? t('common.submitting', { defaultValue: 'Creating…' })
|
|
12
12
|
: t('events.create.title', { defaultValue: 'Create Event' }) })), [canSubmit, submit, submitting, t]);
|
|
13
13
|
useSetPageHeader(t('events.create.title', { defaultValue: 'Create Event' }), headerActions);
|
|
14
|
-
return (_jsxs("div", { className: "pb-12", children: [_jsx(EventForm, { postData: postData, onChange: setPostData }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
14
|
+
return (_jsxs("div", { className: "pb-12", children: [_jsx(EventForm, { postData: postData, onChange: setPostData, showNotify: showNotify, notify: notify, onNotifyChange: setNotify }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
15
15
|
}
|
|
@@ -23,7 +23,7 @@ export function GroupsIndex() {
|
|
|
23
23
|
const canCreate = canCreateGroup(currentProfile?.roles ?? []);
|
|
24
24
|
const plusButton = useMemo(() => canCreate
|
|
25
25
|
? {
|
|
26
|
-
title: t('groups.new', { defaultValue: 'New Group' }),
|
|
26
|
+
title: t('groups.new.label', { defaultValue: 'New Group' }),
|
|
27
27
|
icon: Plus,
|
|
28
28
|
action: '/groups/new',
|
|
29
29
|
}
|
package/dist/pages/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export { ConfigurationPluginPage } from './admin/ConfigurationPluginPage';
|
|
|
76
76
|
export { AdminConfigurationCommunity } from './admin/ConfigurationCommunity';
|
|
77
77
|
export { AdminConfigEditor } from './admin/ConfigEditor';
|
|
78
78
|
export { AdminConfigurationI18n } from './admin/ConfigurationI18n';
|
|
79
|
+
export { AdminConfigurationCommunityAccess } from './admin/community/CommunityAccess';
|
|
79
80
|
export { AdminConfigurationCommunityInfo } from './admin/community/CommunityInfo';
|
|
80
81
|
export { AdminConfigurationCommunityLinks } from './admin/community/CommunityLinks';
|
|
81
82
|
export { CommunityMarkdownPage } from './admin/community/CommunityMarkdownPage';
|
package/dist/pages/index.js
CHANGED
|
@@ -76,6 +76,7 @@ export { ConfigurationPluginPage } from './admin/ConfigurationPluginPage.js';
|
|
|
76
76
|
export { AdminConfigurationCommunity } from './admin/ConfigurationCommunity.js';
|
|
77
77
|
export { AdminConfigEditor } from './admin/ConfigEditor.js';
|
|
78
78
|
export { AdminConfigurationI18n } from './admin/ConfigurationI18n.js';
|
|
79
|
+
export { AdminConfigurationCommunityAccess } from './admin/community/CommunityAccess.js';
|
|
79
80
|
export { AdminConfigurationCommunityInfo } from './admin/community/CommunityInfo.js';
|
|
80
81
|
export { AdminConfigurationCommunityLinks } from './admin/community/CommunityLinks.js';
|
|
81
82
|
export { CommunityMarkdownPage } from './admin/community/CommunityMarkdownPage.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@livekit/components-styles": "^1.1.6",
|
|
35
35
|
"@tanstack/react-query": "5.90.16",
|
|
36
36
|
"@videojs/react": "^10.0.0-beta.24",
|
|
37
|
-
"dompurify": "^3.4.
|
|
37
|
+
"dompurify": "^3.4.17",
|
|
38
38
|
"emoji-picker-element": "^1.29.1",
|
|
39
39
|
"heic2any": "^0.0.4",
|
|
40
40
|
"i18next": "^24.2.3",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"react-i18next": "^15.4.1",
|
|
52
52
|
"simple-icons": "^16.31.0",
|
|
53
53
|
"uuidv7": "^1.0.2",
|
|
54
|
-
"@openpeepshq/
|
|
55
|
-
"@openpeepshq/greenscreen": "^0.2.1",
|
|
54
|
+
"@openpeepshq/common": "^0.5.0",
|
|
56
55
|
"@openpeepshq/react-ui": "^0.4.1",
|
|
57
|
-
"@openpeepshq/
|
|
56
|
+
"@openpeepshq/greenscreen": "^0.2.1",
|
|
57
|
+
"@openpeepshq/client": "^0.3.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.3.0 || ^19.0.0",
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
conversationLabel,
|
|
4
|
+
messagePreviewText,
|
|
5
|
+
profileName,
|
|
6
|
+
type DirectMessageSearchHit,
|
|
7
|
+
} from '@openpeepshq/common';
|
|
8
|
+
import { Input, UpdatingDate } from '@openpeepshq/react-ui';
|
|
9
|
+
import { useOpenpeeps } from '../../contexts/openpeeps';
|
|
10
|
+
import { useT } from '../../i18n';
|
|
11
|
+
import { useCurrentProfile } from '../layout/IdentityContext';
|
|
12
|
+
|
|
13
|
+
export const DirectMessageSearch = ({
|
|
14
|
+
conversationId,
|
|
15
|
+
autoFocus,
|
|
16
|
+
onQueryChange,
|
|
17
|
+
onSelect,
|
|
18
|
+
}: {
|
|
19
|
+
conversationId?: string;
|
|
20
|
+
autoFocus?: boolean;
|
|
21
|
+
onQueryChange?: (query: string) => void;
|
|
22
|
+
onSelect: (hit: DirectMessageSearchHit) => void;
|
|
23
|
+
}) => {
|
|
24
|
+
const t = useT();
|
|
25
|
+
const me = useCurrentProfile();
|
|
26
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
27
|
+
const [input, setInput] = useState('');
|
|
28
|
+
const [query, setQuery] = useState('');
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const handle = setTimeout(() => setQuery(input.trim()), 300);
|
|
32
|
+
return () => clearTimeout(handle);
|
|
33
|
+
}, [input]);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
onQueryChange?.(query);
|
|
37
|
+
}, [query, onQueryChange]);
|
|
38
|
+
|
|
39
|
+
const search = openpeepsApi.useSearchDirectMessages(query, conversationId);
|
|
40
|
+
const active = query.length >= 2;
|
|
41
|
+
const hits = search.data ?? [];
|
|
42
|
+
const placeholder = conversationId
|
|
43
|
+
? t('conversations.search.inConversation', {
|
|
44
|
+
defaultValue: 'Search this conversation…',
|
|
45
|
+
})
|
|
46
|
+
: t('conversations.search.placeholder', {
|
|
47
|
+
defaultValue: 'Search all messages…',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<form
|
|
52
|
+
role="search"
|
|
53
|
+
className="border-border space-y-2 border-b p-3"
|
|
54
|
+
onSubmit={(event) => event.preventDefault()}
|
|
55
|
+
>
|
|
56
|
+
<Input
|
|
57
|
+
type="search"
|
|
58
|
+
value={input}
|
|
59
|
+
onChange={(event) => setInput(event.target.value)}
|
|
60
|
+
placeholder={placeholder}
|
|
61
|
+
aria-label={placeholder}
|
|
62
|
+
autoFocus={autoFocus}
|
|
63
|
+
data-testid="dm-search-input"
|
|
64
|
+
/>
|
|
65
|
+
{active && search.isFetching ? (
|
|
66
|
+
<p className="text-muted-foreground text-sm">
|
|
67
|
+
{t('conversations.search.searching', { defaultValue: 'Searching…' })}
|
|
68
|
+
</p>
|
|
69
|
+
) : null}
|
|
70
|
+
{active && search.isError ? (
|
|
71
|
+
<p className="text-destructive text-sm">
|
|
72
|
+
{t('conversations.search.error', { defaultValue: 'Search failed' })}
|
|
73
|
+
</p>
|
|
74
|
+
) : null}
|
|
75
|
+
{active && !search.isFetching && !search.isError && hits.length === 0 ? (
|
|
76
|
+
<p className="text-muted-foreground text-sm">
|
|
77
|
+
{t('conversations.search.empty', {
|
|
78
|
+
defaultValue: 'No messages match "{{query}}"',
|
|
79
|
+
query,
|
|
80
|
+
})}
|
|
81
|
+
</p>
|
|
82
|
+
) : null}
|
|
83
|
+
{active && hits.length > 0 ? (
|
|
84
|
+
<ul
|
|
85
|
+
aria-label={t('conversations.search.results', {
|
|
86
|
+
defaultValue: 'Message search results',
|
|
87
|
+
})}
|
|
88
|
+
className="max-h-64 overflow-y-auto"
|
|
89
|
+
data-testid="dm-search-results"
|
|
90
|
+
>
|
|
91
|
+
{hits.map((hit) => {
|
|
92
|
+
const senderId = hit.message.profile.id;
|
|
93
|
+
const sender =
|
|
94
|
+
senderId === me?.id
|
|
95
|
+
? t('common.you', { defaultValue: 'You' })
|
|
96
|
+
: profileName(hit.message.profile);
|
|
97
|
+
const others = conversationLabel(hit.message, me?.id);
|
|
98
|
+
return (
|
|
99
|
+
<li key={hit.message.id}>
|
|
100
|
+
<button
|
|
101
|
+
type="button"
|
|
102
|
+
className="hover:bg-surface w-full rounded-md px-2 py-2 text-left"
|
|
103
|
+
title={t('conversations.search.openResult', {
|
|
104
|
+
defaultValue: 'Show this message',
|
|
105
|
+
})}
|
|
106
|
+
data-testid="dm-search-result"
|
|
107
|
+
onClick={() => onSelect(hit)}
|
|
108
|
+
>
|
|
109
|
+
{!conversationId && others ? (
|
|
110
|
+
<span className="block truncate text-sm font-semibold">
|
|
111
|
+
{others}
|
|
112
|
+
</span>
|
|
113
|
+
) : null}
|
|
114
|
+
<span className="text-muted-foreground block truncate text-sm">
|
|
115
|
+
{sender}
|
|
116
|
+
{' · '}
|
|
117
|
+
<UpdatingDate date={hit.message.createdAt} />
|
|
118
|
+
</span>
|
|
119
|
+
<span className="line-clamp-2 text-sm">
|
|
120
|
+
{messagePreviewText(hit.message)}
|
|
121
|
+
</span>
|
|
122
|
+
</button>
|
|
123
|
+
</li>
|
|
124
|
+
);
|
|
125
|
+
})}
|
|
126
|
+
</ul>
|
|
127
|
+
) : null}
|
|
128
|
+
</form>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
@@ -28,6 +28,7 @@ export interface MessageInThreadProps {
|
|
|
28
28
|
message: PublicPost;
|
|
29
29
|
multipleParticipants?: boolean;
|
|
30
30
|
conversationRootId?: string;
|
|
31
|
+
highlighted?: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -40,6 +41,7 @@ export function MessageInThread({
|
|
|
40
41
|
message,
|
|
41
42
|
multipleParticipants = true,
|
|
42
43
|
conversationRootId,
|
|
44
|
+
highlighted = false,
|
|
43
45
|
}: MessageInThreadProps) {
|
|
44
46
|
const t = useT();
|
|
45
47
|
const me = useCurrentProfile();
|
|
@@ -56,7 +58,12 @@ export function MessageInThread({
|
|
|
56
58
|
const isMe = message.profile.id === me?.id;
|
|
57
59
|
|
|
58
60
|
return (
|
|
59
|
-
|
|
61
|
+
<div
|
|
62
|
+
data-message-id={message.id}
|
|
63
|
+
className={
|
|
64
|
+
highlighted ? 'bg-muted ring-ring rounded-md ring-2' : undefined
|
|
65
|
+
}
|
|
66
|
+
>
|
|
60
67
|
{!previous && (
|
|
61
68
|
<div className="mt-2 w-full text-center text-sm">
|
|
62
69
|
{message.inReplyToId
|
|
@@ -117,6 +124,6 @@ export function MessageInThread({
|
|
|
117
124
|
{multipleParticipants && !isMe && <span>{name} · </span>}
|
|
118
125
|
<UpdatingDate date={message.createdAt} />
|
|
119
126
|
</div>
|
|
120
|
-
|
|
127
|
+
</div>
|
|
121
128
|
);
|
|
122
129
|
}
|
|
@@ -5,6 +5,7 @@ export {
|
|
|
5
5
|
useCreateNewConversation,
|
|
6
6
|
} from './CreateNewConversationContext';
|
|
7
7
|
export type { CreateConversationOptions } from './CreateNewConversationContext';
|
|
8
|
+
export { DirectMessageSearch } from './DirectMessageSearch';
|
|
8
9
|
export { DirectMessagesHeaderActions } from './DirectMessagesHeaderActions';
|
|
9
10
|
export { ConversationParticipantsModal } from './ConversationParticipantsModal';
|
|
10
11
|
export type { ConversationParticipantsModalProps } from './ConversationParticipantsModal';
|
|
@@ -35,7 +35,7 @@ export function DeletePostModal({
|
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
37
|
<Dialog open={open} onOpenChange={(next) => !next && onClose()}>
|
|
38
|
-
<DialogContent className="max-w-lg overflow-x-hidden">
|
|
38
|
+
<DialogContent className="flex max-h-[90vh] max-w-lg flex-col overflow-x-hidden">
|
|
39
39
|
<DialogHeader>
|
|
40
40
|
<DialogTitle>
|
|
41
41
|
{t('posts.deleteModal.deletePostTitle', {
|
|
@@ -43,14 +43,16 @@ export function DeletePostModal({
|
|
|
43
43
|
})}
|
|
44
44
|
</DialogTitle>
|
|
45
45
|
</DialogHeader>
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
47
|
+
<article className="min-w-0 overflow-x-hidden">
|
|
48
|
+
<FeedPost post={post} noReactionHeader />
|
|
49
|
+
<p className="my-4 text-sm">
|
|
50
|
+
{t('posts.delete.confirm', {
|
|
51
|
+
defaultValue: 'Are you sure you want to delete this post?',
|
|
52
|
+
})}
|
|
53
|
+
</p>
|
|
54
|
+
</article>
|
|
55
|
+
</div>
|
|
54
56
|
<DialogActions
|
|
55
57
|
cancelLabel={t('posts.deleteModal.cancel', {
|
|
56
58
|
defaultValue: 'Cancel',
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
+
import { Megaphone } from 'lucide-react';
|
|
2
3
|
import type {
|
|
3
4
|
Article,
|
|
4
5
|
AudienceSetting,
|
|
5
6
|
PostCreationData,
|
|
6
7
|
} from '@openpeepshq/common/types';
|
|
7
|
-
import { Input, Label } from '@openpeepshq/react-ui';
|
|
8
|
+
import { Input, Label, Switch } from '@openpeepshq/react-ui';
|
|
8
9
|
import { useT } from '../../../i18n';
|
|
9
10
|
import { useCurrentProfile } from '../../layout/IdentityContext';
|
|
10
11
|
import { applyAudienceSetting } from '../../../lib/audienceSetting';
|
|
@@ -18,12 +19,18 @@ export interface ArticleFormProps {
|
|
|
18
19
|
postData: PostCreationData;
|
|
19
20
|
onChange: (data: PostCreationData) => void;
|
|
20
21
|
isEdit?: boolean;
|
|
22
|
+
showNotify?: boolean;
|
|
23
|
+
notify?: boolean;
|
|
24
|
+
onNotifyChange?: (value: boolean) => void;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
export function ArticleForm({
|
|
24
28
|
postData,
|
|
25
29
|
onChange,
|
|
26
30
|
isEdit = false,
|
|
31
|
+
showNotify = false,
|
|
32
|
+
notify = false,
|
|
33
|
+
onNotifyChange,
|
|
27
34
|
}: ArticleFormProps) {
|
|
28
35
|
const t = useT();
|
|
29
36
|
const me = useCurrentProfile();
|
|
@@ -100,6 +107,26 @@ export function ArticleForm({
|
|
|
100
107
|
showDirect
|
|
101
108
|
/>
|
|
102
109
|
</Label>
|
|
110
|
+
|
|
111
|
+
{showNotify ? (
|
|
112
|
+
<div className="flex w-full items-center justify-between">
|
|
113
|
+
<div className="flex items-center gap-2">
|
|
114
|
+
<Megaphone className="size-5" />
|
|
115
|
+
<p className="text-base">
|
|
116
|
+
{t('posts.form.notifyEveryone', {
|
|
117
|
+
defaultValue: 'Notify everyone',
|
|
118
|
+
})}
|
|
119
|
+
</p>
|
|
120
|
+
</div>
|
|
121
|
+
<Switch
|
|
122
|
+
checked={notify}
|
|
123
|
+
onCheckedChange={(checked) => onNotifyChange?.(checked)}
|
|
124
|
+
aria-label={t('posts.form.notifyEveryone', {
|
|
125
|
+
defaultValue: 'Notify everyone',
|
|
126
|
+
})}
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
) : null}
|
|
103
130
|
</div>
|
|
104
131
|
|
|
105
132
|
{!isEdit ? (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { X } from 'lucide-react';
|
|
2
|
+
import { Megaphone, X } from 'lucide-react';
|
|
3
3
|
import type {
|
|
4
4
|
PostCreationData,
|
|
5
5
|
RecurrenceFreq,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
utcIsoToZonedDateTime,
|
|
12
12
|
zonedDateTimeToUtcIso,
|
|
13
13
|
} from '@openpeepshq/common/lib';
|
|
14
|
-
import { Input, Label } from '@openpeepshq/react-ui';
|
|
14
|
+
import { Input, Label, Switch } from '@openpeepshq/react-ui';
|
|
15
15
|
import { useT } from '../../../i18n';
|
|
16
16
|
import {
|
|
17
17
|
EVENT_WEEKDAYS,
|
|
@@ -30,6 +30,9 @@ export interface EventFormProps {
|
|
|
30
30
|
onChange: (data: PostCreationData) => void;
|
|
31
31
|
isEdit?: boolean;
|
|
32
32
|
occurrenceEdit?: boolean;
|
|
33
|
+
showNotify?: boolean;
|
|
34
|
+
notify?: boolean;
|
|
35
|
+
onNotifyChange?: (value: boolean) => void;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
const dateToInputValue = (value: string | undefined, timeZone: string) =>
|
|
@@ -48,6 +51,9 @@ export const EventForm = ({
|
|
|
48
51
|
onChange,
|
|
49
52
|
isEdit = false,
|
|
50
53
|
occurrenceEdit = false,
|
|
54
|
+
showNotify = false,
|
|
55
|
+
notify = false,
|
|
56
|
+
onNotifyChange,
|
|
51
57
|
}: EventFormProps) => {
|
|
52
58
|
const t = useT();
|
|
53
59
|
const [audienceOpen, setAudienceOpen] = useState(false);
|
|
@@ -402,6 +408,26 @@ export const EventForm = ({
|
|
|
402
408
|
/>
|
|
403
409
|
</Label>
|
|
404
410
|
|
|
411
|
+
{showNotify ? (
|
|
412
|
+
<div className="flex w-full items-center justify-between">
|
|
413
|
+
<div className="flex items-center gap-2">
|
|
414
|
+
<Megaphone className="size-5" />
|
|
415
|
+
<p className="text-base">
|
|
416
|
+
{t('posts.form.notifyEveryone', {
|
|
417
|
+
defaultValue: 'Notify everyone',
|
|
418
|
+
})}
|
|
419
|
+
</p>
|
|
420
|
+
</div>
|
|
421
|
+
<Switch
|
|
422
|
+
checked={notify}
|
|
423
|
+
onCheckedChange={(checked) => onNotifyChange?.(checked)}
|
|
424
|
+
aria-label={t('posts.form.notifyEveryone', {
|
|
425
|
+
defaultValue: 'Notify everyone',
|
|
426
|
+
})}
|
|
427
|
+
/>
|
|
428
|
+
</div>
|
|
429
|
+
) : null}
|
|
430
|
+
|
|
405
431
|
<Label
|
|
406
432
|
description={t('events.form.attendeeListPublic', {
|
|
407
433
|
defaultValue: 'Let an attendee see others attending this event',
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
Paperclip,
|
|
8
8
|
} from 'lucide-react';
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
canAnnouncePosts,
|
|
11
|
+
isCommunityWideVisibility,
|
|
11
12
|
pollOptionsWithinLimit,
|
|
12
13
|
resolvePollOptionContents,
|
|
13
14
|
type GroupWithMeta,
|
|
@@ -194,12 +195,8 @@ export function NewPostModal({
|
|
|
194
195
|
audience,
|
|
195
196
|
]);
|
|
196
197
|
|
|
197
|
-
const canNotify = useMemo(
|
|
198
|
-
|
|
199
|
-
checkRoleCapabilities(me?.roles ?? [], ['allpeep-core-admin-notify'])
|
|
200
|
-
.success,
|
|
201
|
-
[me?.roles],
|
|
202
|
-
);
|
|
198
|
+
const canNotify = useMemo(() => canAnnouncePosts(me?.roles), [me?.roles]);
|
|
199
|
+
const showNotify = canNotify && isCommunityWideVisibility(visibility);
|
|
203
200
|
|
|
204
201
|
const selectedGroupName = useMemo(() => {
|
|
205
202
|
if (!groupId) return undefined;
|
|
@@ -300,7 +297,7 @@ export function NewPostModal({
|
|
|
300
297
|
}
|
|
301
298
|
|
|
302
299
|
const response = await createPost(payload);
|
|
303
|
-
if (notify &&
|
|
300
|
+
if (notify && showNotify && response?.id) {
|
|
304
301
|
await announcePost({ id: response.id });
|
|
305
302
|
}
|
|
306
303
|
if (composerType === 'question') {
|
|
@@ -328,9 +325,6 @@ export function NewPostModal({
|
|
|
328
325
|
}
|
|
329
326
|
};
|
|
330
327
|
|
|
331
|
-
const showNotify =
|
|
332
|
-
canNotify && (visibility === 'public' || visibility === 'local');
|
|
333
|
-
|
|
334
328
|
return (
|
|
335
329
|
<>
|
|
336
330
|
<Dialog open onOpenChange={(open) => !open && onClose()}>
|