@openpeepshq/react 0.6.0 → 0.6.2
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/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/post/CompactReplyParent.js +8 -0
- package/dist/components/post/FeedPostContent.js +3 -0
- package/dist/components/post/NewResourceButton.d.ts +8 -0
- package/dist/components/post/NewResourceButton.js +36 -0
- package/dist/components/post/PostDetail.js +3 -0
- package/dist/components/post/index.d.ts +5 -0
- package/dist/components/post/index.js +3 -0
- package/dist/components/post/pieces/PostMenu.js +4 -0
- package/dist/components/post/post-form/PostTypeSwitcher.js +12 -2
- package/dist/components/post/post-form/ResourceForm.d.ts +7 -0
- package/dist/components/post/post-form/ResourceForm.js +68 -0
- package/dist/components/post/types/event/FullEvent.js +3 -1
- package/dist/components/post/types/resource/FullResource.d.ts +5 -0
- package/dist/components/post/types/resource/FullResource.js +99 -0
- package/dist/components/resources/CategoryPathPicker.d.ts +7 -0
- package/dist/components/resources/CategoryPathPicker.js +26 -0
- package/dist/components/resources/ResourceCard.d.ts +8 -0
- package/dist/components/resources/ResourceCard.js +121 -0
- package/dist/components/resources/ResourceLibrary.d.ts +4 -0
- package/dist/components/resources/ResourceLibrary.js +106 -0
- package/dist/components/resources/index.d.ts +6 -0
- package/dist/components/resources/index.js +3 -0
- package/dist/contexts/openpeeps/hooks/admin.d.ts +1064 -38
- package/dist/contexts/openpeeps/hooks/jams.d.ts +1064 -38
- package/dist/contexts/openpeeps/hooks/posts.d.ts +4508 -39936
- package/dist/hooks/events/useEventComposer.d.ts +1184 -44
- package/dist/hooks/events/useEventsCalendar.d.ts +2113 -61
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/jams/useCreateNewJamForm.d.ts +39 -1
- package/dist/hooks/jams/useJamDetails.d.ts +1064 -38
- package/dist/hooks/jams/useJamRoom.d.ts +2113 -61
- package/dist/hooks/posts/useArticleComposer.d.ts +1184 -44
- package/dist/hooks/posts/useFeedPostPresentation.d.ts +2113 -61
- package/dist/hooks/posts/usePostDetailTitle.d.ts +1064 -38
- package/dist/hooks/posts/useResourceComposer.d.ts +12019 -0
- package/dist/hooks/posts/useResourceComposer.js +139 -0
- package/dist/hooks/resources/useResourceLibrary.d.ts +21880 -0
- package/dist/hooks/resources/useResourceLibrary.js +130 -0
- package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
- package/dist/navigation/menuItems.js +5 -0
- package/dist/navigation/targets.d.ts +4 -0
- package/dist/pages/admin/analytics/Content.js +2 -1
- package/dist/pages/admin/analytics/Overview.js +15 -3
- package/dist/pages/groups/Show.js +7 -3
- package/dist/pages/index.d.ts +3 -0
- package/dist/pages/index.js +3 -0
- package/dist/pages/resources/Edit.d.ts +1 -0
- package/dist/pages/resources/Edit.js +26 -0
- package/dist/pages/resources/Index.d.ts +1 -0
- package/dist/pages/resources/Index.js +29 -0
- package/dist/pages/resources/New.d.ts +1 -0
- package/dist/pages/resources/New.js +15 -0
- package/dist/react-native.d.ts +1 -1
- package/dist/react-native.js +1 -1
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/stores/newPosts.d.ts +79 -2
- package/dist/stores/newPosts.js +26 -2
- package/dist/stores/types.d.ts +2 -0
- package/package.json +6 -6
- package/src/components/index.ts +1 -0
- package/src/components/post/CompactReplyParent.tsx +8 -0
- package/src/components/post/FeedPostContent.tsx +3 -0
- package/src/components/post/NewResourceButton.tsx +75 -0
- package/src/components/post/PostDetail.tsx +3 -0
- package/src/components/post/index.ts +5 -0
- package/src/components/post/pieces/PostMenu.tsx +4 -0
- package/src/components/post/post-form/PostTypeSwitcher.tsx +19 -1
- package/src/components/post/post-form/ResourceForm.tsx +237 -0
- package/src/components/post/types/event/FullEvent.tsx +11 -3
- package/src/components/post/types/resource/FullResource.tsx +173 -0
- package/src/components/resources/CategoryPathPicker.tsx +95 -0
- package/src/components/resources/ResourceCard.tsx +335 -0
- package/src/components/resources/ResourceLibrary.tsx +374 -0
- package/src/components/resources/index.ts +6 -0
- package/src/contexts/openpeeps/hooks/posts.ts +11 -2
- package/src/hooks/index.ts +2 -0
- package/src/hooks/posts/useResourceComposer.ts +165 -0
- package/src/hooks/resources/useResourceLibrary.ts +156 -0
- package/src/navigation/menuItems.ts +6 -0
- package/src/navigation/targets.ts +1 -0
- package/src/pages/admin/analytics/Content.tsx +2 -1
- package/src/pages/admin/analytics/Overview.tsx +15 -3
- package/src/pages/groups/Show.tsx +30 -1
- package/src/pages/index.ts +3 -0
- package/src/pages/resources/Edit.tsx +73 -0
- package/src/pages/resources/Index.tsx +45 -0
- package/src/pages/resources/New.tsx +53 -0
- package/src/react-native.ts +1 -0
- package/src/stores/index.ts +1 -0
- package/src/stores/newPosts.ts +33 -2
- package/src/stores/types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -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/
|
|
56
|
-
"@openpeepshq/greenscreen": "^0.2.
|
|
57
|
-
"@openpeepshq/
|
|
54
|
+
"@openpeepshq/common": "^0.3.2",
|
|
55
|
+
"@openpeepshq/client": "^0.2.1",
|
|
56
|
+
"@openpeepshq/greenscreen": "^0.2.1",
|
|
57
|
+
"@openpeepshq/react-ui": "^0.4.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.3.0 || ^19.0.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"tsc-alias": "^1.8.10",
|
|
74
74
|
"typescript": "^5.7.3",
|
|
75
75
|
"vitest": "^2.1.8",
|
|
76
|
-
"@openpeepshq/fetch-client": "^0.2.
|
|
76
|
+
"@openpeepshq/fetch-client": "^0.2.1"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"lint": "prettier --check . && ESLINT_USE_FLAT_CONFIG=false eslint .",
|
package/src/components/index.ts
CHANGED
|
@@ -109,6 +109,8 @@ const compactThumb = (post: CompactPost, t: TFunction): ReactNode => {
|
|
|
109
109
|
if (!article.image) return null;
|
|
110
110
|
return <CompactThumb src={article.image} alt={article.title ?? alt} />;
|
|
111
111
|
}
|
|
112
|
+
case 'resource':
|
|
113
|
+
return attachmentThumb(attachmentsOf(post), alt);
|
|
112
114
|
default:
|
|
113
115
|
return null;
|
|
114
116
|
}
|
|
@@ -209,6 +211,12 @@ const CompactTypeBody = ({ post, t }: { post: CompactPost; t: TFunction }) => {
|
|
|
209
211
|
return <CompactEventBody post={post} />;
|
|
210
212
|
case 'article':
|
|
211
213
|
return <CompactArticleBody post={post} />;
|
|
214
|
+
case 'resource': {
|
|
215
|
+
const title =
|
|
216
|
+
post.data?.type === 'resource' ? post.data.title.trim() : '';
|
|
217
|
+
if (!title) return null;
|
|
218
|
+
return <p className="line-clamp-2 text-sm font-medium">{title}</p>;
|
|
219
|
+
}
|
|
212
220
|
default:
|
|
213
221
|
return null;
|
|
214
222
|
}
|
|
@@ -6,6 +6,7 @@ import { FeedArticle } from './types/Article';
|
|
|
6
6
|
import { FeedEvent } from './types/Event';
|
|
7
7
|
import { FeedNote } from './types/Note';
|
|
8
8
|
import { FeedPoll } from './types/Poll';
|
|
9
|
+
import { ResourceCard } from '../resources/ResourceCard';
|
|
9
10
|
|
|
10
11
|
export interface FeedPostContentProps {
|
|
11
12
|
post: PublicPost;
|
|
@@ -38,6 +39,8 @@ export function FeedPostContent({ post }: FeedPostContentProps) {
|
|
|
38
39
|
return <FeedEvent post={post} />;
|
|
39
40
|
case 'article':
|
|
40
41
|
return <FeedArticle post={post} />;
|
|
42
|
+
case 'resource':
|
|
43
|
+
return <ResourceCard post={post} />;
|
|
41
44
|
default:
|
|
42
45
|
return null;
|
|
43
46
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { FilePlus } from 'lucide-react';
|
|
3
|
+
import {
|
|
4
|
+
canCreatePost,
|
|
5
|
+
type GroupWithMeta,
|
|
6
|
+
type ProfileWithMeta,
|
|
7
|
+
type VisibilityType,
|
|
8
|
+
} from '@openpeepshq/common';
|
|
9
|
+
import { Button } from '@openpeepshq/react-ui';
|
|
10
|
+
import { useT } from '../../i18n';
|
|
11
|
+
import { getNewPostStores, useSetPlusButtonActions } from '../../stores';
|
|
12
|
+
import { useAuthData } from '../layout/IdentityContext';
|
|
13
|
+
import { useNavigate } from '../../contexts/router';
|
|
14
|
+
|
|
15
|
+
export interface NewResourceButtonProps {
|
|
16
|
+
visibility: VisibilityType;
|
|
17
|
+
currentProfile?: ProfileWithMeta;
|
|
18
|
+
group?: GroupWithMeta;
|
|
19
|
+
showButton?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const NewResourceButton = ({
|
|
23
|
+
visibility,
|
|
24
|
+
currentProfile,
|
|
25
|
+
group,
|
|
26
|
+
showButton = true,
|
|
27
|
+
}: NewResourceButtonProps) => {
|
|
28
|
+
const t = useT();
|
|
29
|
+
const authData = useAuthData();
|
|
30
|
+
const navigate = useNavigate();
|
|
31
|
+
const stores = getNewPostStores();
|
|
32
|
+
|
|
33
|
+
const profile = currentProfile ?? authData.profile;
|
|
34
|
+
const canPost =
|
|
35
|
+
!!profile && canCreatePost(authData, 'resource', visibility, group);
|
|
36
|
+
|
|
37
|
+
const openNew = useCallback(() => {
|
|
38
|
+
stores.resource = {
|
|
39
|
+
...stores.resource,
|
|
40
|
+
visibility,
|
|
41
|
+
groupId: group?.id,
|
|
42
|
+
};
|
|
43
|
+
navigate({ type: 'resources', view: 'new' });
|
|
44
|
+
}, [group?.id, navigate, stores, visibility]);
|
|
45
|
+
|
|
46
|
+
const plusActions = useMemo(
|
|
47
|
+
() =>
|
|
48
|
+
canPost
|
|
49
|
+
? {
|
|
50
|
+
title: t('resources.new', { defaultValue: 'New resource' }),
|
|
51
|
+
icon: FilePlus,
|
|
52
|
+
action: openNew,
|
|
53
|
+
}
|
|
54
|
+
: undefined,
|
|
55
|
+
[canPost, openNew, t],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
useSetPlusButtonActions(plusActions);
|
|
59
|
+
|
|
60
|
+
if (!canPost || !showButton) return null;
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div className="mb-4 p-4 pb-0">
|
|
64
|
+
<Button
|
|
65
|
+
title={t('resources.new', { defaultValue: 'New resource' })}
|
|
66
|
+
variant="default"
|
|
67
|
+
action={openNew}
|
|
68
|
+
data-testid="resources-new-resource-button"
|
|
69
|
+
>
|
|
70
|
+
<FilePlus className="mr-1 size-4" />
|
|
71
|
+
{t('resources.new', { defaultValue: 'New resource' })}
|
|
72
|
+
</Button>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -4,6 +4,7 @@ import { FullNote } from './types/note/FullNote';
|
|
|
4
4
|
import { FullArticle } from './types/article/FullArticle';
|
|
5
5
|
import { FullPoll } from './types/poll/FullPoll';
|
|
6
6
|
import { FullEvent } from './types/event/FullEvent';
|
|
7
|
+
import { FullResource } from './types/resource/FullResource';
|
|
7
8
|
import { LoadingSpinner } from '@openpeepshq/react-ui';
|
|
8
9
|
|
|
9
10
|
export interface PostDetailProps {
|
|
@@ -38,6 +39,8 @@ export function PostDetail({ postId, occurrence }: PostDetailProps) {
|
|
|
38
39
|
switch (post.type) {
|
|
39
40
|
case 'article':
|
|
40
41
|
return <FullArticle post={post} />;
|
|
42
|
+
case 'resource':
|
|
43
|
+
return <FullResource post={post} />;
|
|
41
44
|
case 'event':
|
|
42
45
|
return <FullEvent post={post} occurrence={occurrence} />;
|
|
43
46
|
case 'question':
|
|
@@ -24,6 +24,8 @@ export { OpenpeepsMarkdownInput } from './post-form/OpenpeepsMarkdownInput';
|
|
|
24
24
|
export type { OpenpeepsMarkdownInputProps } from './post-form/OpenpeepsMarkdownInput';
|
|
25
25
|
export { ArticleForm } from './post-form/ArticleForm';
|
|
26
26
|
export type { ArticleFormProps } from './post-form/ArticleForm';
|
|
27
|
+
export { ResourceForm } from './post-form/ResourceForm';
|
|
28
|
+
export type { ResourceFormProps } from './post-form/ResourceForm';
|
|
27
29
|
export { EventForm } from './post-form/EventForm';
|
|
28
30
|
export type { EventFormProps } from './post-form/EventForm';
|
|
29
31
|
export { PreviewLink } from '../preview-link/PreviewLink';
|
|
@@ -31,6 +33,8 @@ export { NewNoteButton, useNewNotePlusButton } from './NewNoteButton';
|
|
|
31
33
|
export type { NewNoteButtonProps } from './NewNoteButton';
|
|
32
34
|
export { NewEventButton } from './NewEventButton';
|
|
33
35
|
export type { NewEventButtonProps } from './NewEventButton';
|
|
36
|
+
export { NewResourceButton } from './NewResourceButton';
|
|
37
|
+
export type { NewResourceButtonProps } from './NewResourceButton';
|
|
34
38
|
export { PinnedPost } from './PinnedPost';
|
|
35
39
|
export type { PinnedPostProps } from './PinnedPost';
|
|
36
40
|
export { FullPostLayout } from './FullPostLayout';
|
|
@@ -62,6 +66,7 @@ export { ParticipantsCard } from './pieces/ParticipantsCard';
|
|
|
62
66
|
export type { ParticipantsCardProps } from './pieces/ParticipantsCard';
|
|
63
67
|
export { FullNote } from './types/note/FullNote';
|
|
64
68
|
export { FullArticle } from './types/article/FullArticle';
|
|
69
|
+
export { FullResource } from './types/resource/FullResource';
|
|
65
70
|
export { FullPoll } from './types/poll/FullPoll';
|
|
66
71
|
export { FullEvent } from './types/event/FullEvent';
|
|
67
72
|
export { PollContent } from './pieces/PollContent';
|
|
@@ -114,6 +114,10 @@ export function PostMenu({ post, deleteCallback }: PostMenuProps) {
|
|
|
114
114
|
window.location.assign(`/articles/${post.id}/edit`);
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
|
+
if (post.data?.type === 'resource') {
|
|
118
|
+
window.location.assign(`/resources/${post.id}/edit`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
117
121
|
openEditPost(post);
|
|
118
122
|
};
|
|
119
123
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CalendarDays,
|
|
3
3
|
ChartColumnBig,
|
|
4
|
+
Library,
|
|
4
5
|
Notebook,
|
|
5
6
|
ScrollText,
|
|
6
7
|
} from 'lucide-react';
|
|
@@ -43,7 +44,7 @@ export function PostTypeSwitcher({
|
|
|
43
44
|
const me = useCurrentProfile();
|
|
44
45
|
const isOwner = Boolean(me?.roles?.some((role) => role.key === 'owner'));
|
|
45
46
|
|
|
46
|
-
const goto = (path: '/articles/new' | '/events/new') => {
|
|
47
|
+
const goto = (path: '/articles/new' | '/events/new' | '/resources/new') => {
|
|
47
48
|
const stores = getNewPostStores();
|
|
48
49
|
if (path === '/articles/new') {
|
|
49
50
|
stores.article = {
|
|
@@ -52,6 +53,13 @@ export function PostTypeSwitcher({
|
|
|
52
53
|
visibility: visibility ?? stores.article.visibility,
|
|
53
54
|
groupId,
|
|
54
55
|
};
|
|
56
|
+
} else if (path === '/resources/new') {
|
|
57
|
+
stores.resource = {
|
|
58
|
+
...stores.resource,
|
|
59
|
+
type: 'resource',
|
|
60
|
+
visibility: visibility ?? stores.resource.visibility,
|
|
61
|
+
groupId,
|
|
62
|
+
};
|
|
55
63
|
} else {
|
|
56
64
|
stores.event = {
|
|
57
65
|
...stores.event,
|
|
@@ -107,6 +115,16 @@ export function PostTypeSwitcher({
|
|
|
107
115
|
<ScrollText className="size-5" />
|
|
108
116
|
</Button>
|
|
109
117
|
) : null}
|
|
118
|
+
<Button
|
|
119
|
+
compact
|
|
120
|
+
variant="ghost"
|
|
121
|
+
title={t('posts.switcher.resource', {
|
|
122
|
+
defaultValue: 'Add a resource',
|
|
123
|
+
})}
|
|
124
|
+
action={() => goto('/resources/new')}
|
|
125
|
+
>
|
|
126
|
+
<Library className="size-5" />
|
|
127
|
+
</Button>
|
|
110
128
|
</div>
|
|
111
129
|
);
|
|
112
130
|
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { useMemo, useState, type KeyboardEvent } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
AudienceSetting,
|
|
4
|
+
PostCreationData,
|
|
5
|
+
ResourceKind,
|
|
6
|
+
ResourcePost,
|
|
7
|
+
} from '@openpeepshq/common/types';
|
|
8
|
+
import { RESOURCE_KINDS, normalizeResourceTags } from '@openpeepshq/common/lib';
|
|
9
|
+
import { Button, Input, Label } from '@openpeepshq/react-ui';
|
|
10
|
+
import { useT } from '../../../i18n';
|
|
11
|
+
import { useCurrentProfile } from '../../layout/IdentityContext';
|
|
12
|
+
import { applyAudienceSetting } from '../../../lib/audienceSetting';
|
|
13
|
+
import { CategoryPathPicker } from '../../resources/CategoryPathPicker';
|
|
14
|
+
import { useResourceLibrary } from '../../../hooks';
|
|
15
|
+
import { OpenpeepsMarkdownInput } from './OpenpeepsMarkdownInput';
|
|
16
|
+
import { PostAudienceSelector } from './PostAudienceSelector';
|
|
17
|
+
import { VisibilitySelector } from './VisibilitySelector';
|
|
18
|
+
import { useComposeAttachments } from './ComposeAttachments';
|
|
19
|
+
|
|
20
|
+
export interface ResourceFormProps {
|
|
21
|
+
postData: PostCreationData;
|
|
22
|
+
onChange: (data: PostCreationData) => void;
|
|
23
|
+
isEdit?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const ResourceForm = ({
|
|
27
|
+
postData,
|
|
28
|
+
onChange,
|
|
29
|
+
isEdit = false,
|
|
30
|
+
}: ResourceFormProps) => {
|
|
31
|
+
const t = useT();
|
|
32
|
+
const me = useCurrentProfile();
|
|
33
|
+
const resource = postData.data as ResourcePost;
|
|
34
|
+
const [audienceOpen, setAudienceOpen] = useState(false);
|
|
35
|
+
const [tagDraft, setTagDraft] = useState('');
|
|
36
|
+
const library = useResourceLibrary(postData.groupId ?? undefined);
|
|
37
|
+
const attachments = useComposeAttachments({
|
|
38
|
+
attachments: resource.attachments ?? [],
|
|
39
|
+
onChange: (next) => patchResource({ attachments: next }),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const patchResource = (patch: Partial<ResourcePost>) => {
|
|
43
|
+
onChange({
|
|
44
|
+
...postData,
|
|
45
|
+
data: { ...resource, ...patch },
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const setAudience = (settings: AudienceSetting) =>
|
|
50
|
+
onChange(applyAudienceSetting(postData, settings, me));
|
|
51
|
+
|
|
52
|
+
const addTag = () => {
|
|
53
|
+
const next = normalizeResourceTags([
|
|
54
|
+
...(resource.tags ?? []),
|
|
55
|
+
...tagDraft.split(/[,\s]+/),
|
|
56
|
+
]);
|
|
57
|
+
patchResource({ tags: next });
|
|
58
|
+
setTagDraft('');
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const onTagKey = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
62
|
+
if (event.key === 'Enter' || event.key === ',') {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
addTag();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const kindActions = useMemo(
|
|
69
|
+
() => ({
|
|
70
|
+
gallery: attachments.openImagePicker,
|
|
71
|
+
video: attachments.openImagePicker,
|
|
72
|
+
audio: attachments.openAudioPicker,
|
|
73
|
+
file: attachments.openDocumentPicker,
|
|
74
|
+
link: undefined,
|
|
75
|
+
}),
|
|
76
|
+
[attachments],
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div>
|
|
81
|
+
<div className="mt-4 flex flex-col gap-4 px-3">
|
|
82
|
+
<h2 className="text-lg">
|
|
83
|
+
{t('resources.form.title', { defaultValue: 'New resource' })}
|
|
84
|
+
</h2>
|
|
85
|
+
|
|
86
|
+
<Label
|
|
87
|
+
title={t('resources.form.name', { defaultValue: 'Title' })}
|
|
88
|
+
htmlFor="resource-title"
|
|
89
|
+
>
|
|
90
|
+
<Input
|
|
91
|
+
id="resource-title"
|
|
92
|
+
data-testid="resources-title"
|
|
93
|
+
value={resource.title}
|
|
94
|
+
onChange={(event) => patchResource({ title: event.target.value })}
|
|
95
|
+
/>
|
|
96
|
+
</Label>
|
|
97
|
+
|
|
98
|
+
<div>
|
|
99
|
+
<p className="mb-2 text-sm font-medium">
|
|
100
|
+
{t('resources.form.kind', { defaultValue: 'Type' })}
|
|
101
|
+
</p>
|
|
102
|
+
<div className="flex flex-wrap gap-2">
|
|
103
|
+
{RESOURCE_KINDS.map((kind) => (
|
|
104
|
+
<Button
|
|
105
|
+
key={kind}
|
|
106
|
+
variant={resource.resourceKind === kind ? 'default' : 'outline'}
|
|
107
|
+
compact
|
|
108
|
+
data-testid={`resources-kind-${kind}`}
|
|
109
|
+
action={() =>
|
|
110
|
+
patchResource({ resourceKind: kind as ResourceKind })
|
|
111
|
+
}
|
|
112
|
+
>
|
|
113
|
+
{t(`resources.kinds.${kind}`, { defaultValue: kind })}
|
|
114
|
+
</Button>
|
|
115
|
+
))}
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{resource.resourceKind === 'link' ? (
|
|
120
|
+
<Label
|
|
121
|
+
title={t('resources.form.url', { defaultValue: 'URL' })}
|
|
122
|
+
htmlFor="resource-url"
|
|
123
|
+
>
|
|
124
|
+
<Input
|
|
125
|
+
id="resource-url"
|
|
126
|
+
data-testid="resources-url"
|
|
127
|
+
value={resource.url ?? ''}
|
|
128
|
+
onChange={(event) => patchResource({ url: event.target.value })}
|
|
129
|
+
/>
|
|
130
|
+
</Label>
|
|
131
|
+
) : (
|
|
132
|
+
<div className="space-y-2">
|
|
133
|
+
<Button
|
|
134
|
+
variant="outline"
|
|
135
|
+
action={kindActions[resource.resourceKind]}
|
|
136
|
+
>
|
|
137
|
+
{t('resources.form.addMedia', {
|
|
138
|
+
defaultValue: 'Add files',
|
|
139
|
+
})}
|
|
140
|
+
</Button>
|
|
141
|
+
{attachments.previews}
|
|
142
|
+
{attachments.inputs}
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
<OpenpeepsMarkdownInput
|
|
147
|
+
rows={8}
|
|
148
|
+
maxLength={4000}
|
|
149
|
+
value={resource.content ?? ''}
|
|
150
|
+
onChange={(content) => patchResource({ content })}
|
|
151
|
+
placeholder={t('resources.form.descriptionPlaceholder', {
|
|
152
|
+
defaultValue: 'Describe this resource',
|
|
153
|
+
})}
|
|
154
|
+
/>
|
|
155
|
+
|
|
156
|
+
<Label
|
|
157
|
+
title={t('resources.form.tags', { defaultValue: 'Tags' })}
|
|
158
|
+
htmlFor="resource-tags"
|
|
159
|
+
>
|
|
160
|
+
<Input
|
|
161
|
+
id="resource-tags"
|
|
162
|
+
value={tagDraft}
|
|
163
|
+
onChange={(event) => setTagDraft(event.target.value)}
|
|
164
|
+
onKeyDown={onTagKey}
|
|
165
|
+
onBlur={addTag}
|
|
166
|
+
placeholder={t('resources.form.tagsPlaceholder', {
|
|
167
|
+
defaultValue: 'Add tags, then press Enter',
|
|
168
|
+
})}
|
|
169
|
+
/>
|
|
170
|
+
</Label>
|
|
171
|
+
{resource.tags?.length ? (
|
|
172
|
+
<div className="flex flex-wrap gap-1">
|
|
173
|
+
{normalizeResourceTags(resource.tags).map((tag) => (
|
|
174
|
+
<button
|
|
175
|
+
key={tag}
|
|
176
|
+
type="button"
|
|
177
|
+
className="bg-muted rounded-full px-2 py-0.5 text-xs"
|
|
178
|
+
onClick={() =>
|
|
179
|
+
patchResource({
|
|
180
|
+
tags: (resource.tags ?? []).filter(
|
|
181
|
+
(value) => value.toLowerCase() !== tag,
|
|
182
|
+
),
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
>
|
|
186
|
+
#{tag}
|
|
187
|
+
</button>
|
|
188
|
+
))}
|
|
189
|
+
</div>
|
|
190
|
+
) : null}
|
|
191
|
+
|
|
192
|
+
<div>
|
|
193
|
+
<p className="mb-2 text-sm font-medium">
|
|
194
|
+
{t('resources.form.hierarchy', {
|
|
195
|
+
defaultValue: 'Place in the library',
|
|
196
|
+
})}
|
|
197
|
+
</p>
|
|
198
|
+
<CategoryPathPicker
|
|
199
|
+
path={resource.categoryPath ?? []}
|
|
200
|
+
tree={library.tree}
|
|
201
|
+
onChange={(categoryPath) => patchResource({ categoryPath })}
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<Label
|
|
206
|
+
title={t('resources.form.visibility', {
|
|
207
|
+
defaultValue: 'Who can see this (Required)',
|
|
208
|
+
})}
|
|
209
|
+
description={t('resources.form.visibilityNotChangeable', {
|
|
210
|
+
defaultValue:
|
|
211
|
+
"Once you post your resource, you can't change the visibility",
|
|
212
|
+
})}
|
|
213
|
+
>
|
|
214
|
+
<VisibilitySelector
|
|
215
|
+
postData={postData}
|
|
216
|
+
onClick={() => setAudienceOpen(true)}
|
|
217
|
+
disabled={isEdit}
|
|
218
|
+
showDirect
|
|
219
|
+
/>
|
|
220
|
+
</Label>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
{!isEdit ? (
|
|
224
|
+
<PostAudienceSelector
|
|
225
|
+
open={audienceOpen}
|
|
226
|
+
onClose={() => setAudienceOpen(false)}
|
|
227
|
+
type="resource"
|
|
228
|
+
visibility={postData.visibility}
|
|
229
|
+
groupId={postData.groupId ?? undefined}
|
|
230
|
+
audience={postData.audience ?? []}
|
|
231
|
+
showDirect
|
|
232
|
+
onConfirm={setAudience}
|
|
233
|
+
/>
|
|
234
|
+
) : null}
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
@@ -80,6 +80,8 @@ export function FullEvent({ post, occurrence }: FullEventProps) {
|
|
|
80
80
|
const event = post.data as Event;
|
|
81
81
|
const contextQuery = openpeepsApi.usePostContext(post.id);
|
|
82
82
|
const jamAttendeesQuery = openpeepsApi.useJamAttendance(post.id);
|
|
83
|
+
const jamStateQuery = openpeepsApi.useJamState(post.id, occurrenceId);
|
|
84
|
+
const jamState = event.jam ? jamStateQuery.data : undefined;
|
|
83
85
|
const canViewRecordings = canAccessJamRecordings(profile, post);
|
|
84
86
|
const recordingsQuery = openpeepsApi.usePostRecordings(
|
|
85
87
|
post.id,
|
|
@@ -251,9 +253,15 @@ export function FullEvent({ post, occurrence }: FullEventProps) {
|
|
|
251
253
|
|
|
252
254
|
{event.jam && (myEvent || iAmModerator) ? (
|
|
253
255
|
livekitEnabled ? (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
jamState?.active ? (
|
|
257
|
+
<Button variant="default" className="mt-2 w-full" action={jamLink}>
|
|
258
|
+
{t('jam.join.submit', { defaultValue: 'Join Jam' })}
|
|
259
|
+
</Button>
|
|
260
|
+
) : (
|
|
261
|
+
<Button variant="default" className="mt-2 w-full" action={jamLink}>
|
|
262
|
+
{t('events.jam.start', { defaultValue: 'Start jam' })}
|
|
263
|
+
</Button>
|
|
264
|
+
)
|
|
257
265
|
) : (
|
|
258
266
|
<p role="status" className="text-destructive mt-2 text-sm">
|
|
259
267
|
{t('jams.unavailable.message', {
|