@openpeepshq/react 0.8.1 → 0.8.3

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.
@@ -2,13 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { Link } from 'react-router-dom';
3
3
  import { ChevronRight } from 'lucide-react';
4
4
  import { useT } from '../../i18n/index.js';
5
+ import { Markdown } from '../../lib/Markdown.js';
5
6
  /**
6
7
  * Row in a settings / configuration menu: title, description and a chevron.
7
8
  * Shared by the admin configuration screens and the user settings index.
8
9
  */
9
10
  export function ConfigMenuButton({ translationPrefix, action, onPress, testId, titleFallback, descriptionFallback, }) {
10
11
  const t = useT();
11
- const content = (_jsxs(_Fragment, { children: [_jsxs("div", { children: [_jsx("div", { className: "font-medium", children: t(`${translationPrefix}.title`, titleFallback ? { defaultValue: titleFallback } : {}) }), _jsx("div", { className: "text-muted-foreground text-xs", children: t(`${translationPrefix}.description`, descriptionFallback ? { defaultValue: descriptionFallback } : {}) })] }), _jsx("span", { "aria-hidden": "true", children: _jsx(ChevronRight, { className: "h-4 w-4" }) })] }));
12
+ const content = (_jsxs(_Fragment, { children: [_jsxs("div", { children: [_jsx("div", { className: "font-medium", children: t(`${translationPrefix}.title`, titleFallback ? { defaultValue: titleFallback } : {}) }), _jsx("div", { className: "text-muted-foreground text-xs", children: _jsx(Markdown, { inline: true, source: t(`${translationPrefix}.description`, descriptionFallback ? { defaultValue: descriptionFallback } : {}) }) })] }), _jsx("span", { "aria-hidden": "true", children: _jsx(ChevronRight, { className: "h-4 w-4" }) })] }));
12
13
  if (onPress) {
13
14
  return (_jsx("button", { "data-testid": testId, onClick: onPress, className: "hover:bg-surface flex w-full items-center justify-between px-4 py-3 text-start", children: content }));
14
15
  }
@@ -86,9 +86,10 @@ export const ResourceForm = ({ postData, onChange, isEdit = false, groupOnly = f
86
86
  defaultValue: 'https://example.com',
87
87
  }), inputMode: "url", spellCheck: false, error: urlInvalid, "aria-invalid": urlIssue, "aria-describedby": urlIssue ? 'resource-url-error' : undefined, onChange: (event) => patchResource({ url: event.target.value }) }), urlIssue ? (_jsx("span", { id: "resource-url-error", role: urlInvalid ? 'alert' : 'status', "data-testid": "resources-url-error", className: urlInvalid
88
88
  ? 'text-destructive mt-1 text-sm'
89
- : 'text-muted-foreground mt-1 text-sm', children: urlMessage })) : null] })) : (_jsxs("div", { className: "space-y-2", children: [_jsx(Button, { variant: "outline", action: kindActions[resource.resourceKind], children: t('resources.form.addMedia', {
89
+ : 'text-muted-foreground mt-1 text-sm', children: urlMessage })) : null] })) : (_jsxs("div", { className: "space-y-2", children: [resource.resourceKind === 'gallery' ||
90
+ (resource.attachments ?? []).length === 0 ? (_jsx(Button, { variant: "outline", action: kindActions[resource.resourceKind], children: t('resources.form.addMedia', {
90
91
  defaultValue: 'Add files',
91
- }) }), attachments.previews, attachments.inputs, mediaMissing ? (_jsx("p", { role: "status", className: "text-muted-foreground text-sm", children: t('resources.validation.mediaRequired', {
92
+ }) })) : null, attachments.previews, attachments.inputs, mediaMissing ? (_jsx("p", { role: "status", className: "text-muted-foreground text-sm", children: t('resources.validation.mediaRequired', {
92
93
  defaultValue: 'Add the media or link this resource needs',
93
94
  }) })) : null] })), _jsx(OpenpeepsMarkdownInput, { rows: 8, maxLength: 4000, value: resource.content ?? '', onChange: (content) => patchResource({ content }), placeholder: t('resources.form.descriptionPlaceholder', {
94
95
  defaultValue: 'Describe this resource',
@@ -1,6 +1,6 @@
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 { BookmarkCheck, BookmarkPlus, Link as LinkIcon, ImageOff, } from 'lucide-react';
3
+ import { AudioLines, BookmarkCheck, BookmarkPlus, Link as LinkIcon, ImageOff, } from 'lucide-react';
4
4
  import { attachmentMediaKind, formatSize, groupName, normalizeResourceTags, } from '@openpeepshq/common/lib';
5
5
  import { useHrefOf, useNavigate } from '../../contexts/router/index.js';
6
6
  import { useT } from '../../i18n/index.js';
@@ -9,7 +9,9 @@ import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
9
9
  import { useCurrentProfile } from '../layout/IdentityContext.js';
10
10
  import { VideoPlayOverlay } from '../post/VideoPlayOverlay.js';
11
11
  import { TruncatedMarkdown } from '../post/TruncatedMarkdown.js';
12
- const visualAttachments = (attachments) => attachments.filter((att) => attachmentMediaKind(att) !== 'audio');
12
+ // Audio attachments render their generated waveform preview like any other
13
+ // visual; without one they fall back to the kind placeholder below.
14
+ const visualAttachments = (attachments) => attachments.filter((att) => attachmentMediaKind(att) !== 'audio' || !!att.previewUrl);
13
15
  const previewSrc = (att) => att.previewUrl ?? att.url;
14
16
  /** Thumbnail size shared between list and card previews. */
15
17
  const THUMB_CLASS = 'h-12 w-12 object-cover';
@@ -154,6 +156,9 @@ export const ResourceCard = ({ post, layout = 'card', preview, showDescription =
154
156
  e.target.style.display = 'none';
155
157
  } }));
156
158
  }
159
+ if (resource.resourceKind === 'audio') {
160
+ return (_jsx("div", { className: "bg-muted flex h-12 w-12 items-center justify-center rounded-md", children: _jsx(AudioLines, { className: "text-muted-foreground size-5" }) }));
161
+ }
157
162
  if (resource.resourceKind === 'link' && resource.url) {
158
163
  return (_jsx("div", { className: "bg-muted flex h-12 w-12 items-center justify-center rounded-md", children: _jsx(LinkIcon, { className: "text-muted-foreground size-5" }) }));
159
164
  }
@@ -172,7 +177,7 @@ export const ResourceCard = ({ post, layout = 'card', preview, showDescription =
172
177
  return (_jsx("div", { className: "bg-surface relative h-full w-full overflow-hidden", children: _jsx(MediaPreview, { src: src, alt: att.description ?? resource.title, className: tiles.length > 1
173
178
  ? 'h-full w-full object-cover'
174
179
  : CARD_IMG_CLASS, isVideo: kind === 'video', isLast: last, extra: extra }) }, `${att.url ?? index}-${index}`));
175
- }) })) : resource.resourceKind === 'link' && resource.url ? (_jsx("div", { className: "bg-muted flex h-48 w-full items-center justify-center rounded-md", children: _jsx(LinkIcon, { className: "text-muted-foreground/50 size-8" }) })) : null, renderSaveButton('bg-background text-muted-foreground hover:text-foreground absolute right-2 top-2 rounded-full p-1 opacity-70 hover:opacity-100 disabled:opacity-50')] }), _jsx("h3", { className: "text-lg font-semibold", children: resource.title }), resource.categoryPath?.length ? (_jsx("p", { className: "text-muted-foreground text-xs", children: resource.categoryPath.join(' / ') })) : null, renderGroupLabel(), showDescription ? (_jsx(TruncatedMarkdown, { source: resource.content ?? '', maxBlocks: 2, maxChars: 240, maxLines: 2, interactive: !staticRender, className: "text-sm text-muted-foreground" })) : null, metaText ? (_jsx("p", { className: "text-muted-foreground text-xs", children: metaText })) : null, tags.length ? (_jsx("div", { className: "flex flex-wrap gap-1", children: tags.map((value) => staticRender ? (_jsxs("span", { className: "bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs", children: ["#", value] }, value)) : (_jsx(ResourceTagChip, { value: value }, value))) })) : null, _jsx("p", { className: "text-muted-foreground text-xs uppercase", children: t(`resources.kinds.${resource.resourceKind}`, {
180
+ }) })) : resource.resourceKind === 'audio' ? (_jsx("div", { className: "bg-muted flex h-48 w-full items-center justify-center rounded-md", children: _jsx(AudioLines, { className: "text-muted-foreground/50 size-8" }) })) : resource.resourceKind === 'link' && resource.url ? (_jsx("div", { className: "bg-muted flex h-48 w-full items-center justify-center rounded-md", children: _jsx(LinkIcon, { className: "text-muted-foreground/50 size-8" }) })) : null, renderSaveButton('bg-background text-muted-foreground hover:text-foreground absolute right-2 top-2 rounded-full p-1 opacity-70 hover:opacity-100 disabled:opacity-50')] }), _jsx("h3", { className: "text-lg font-semibold", children: resource.title }), resource.categoryPath?.length ? (_jsx("p", { className: "text-muted-foreground text-xs", children: resource.categoryPath.join(' / ') })) : null, renderGroupLabel(), showDescription ? (_jsx(TruncatedMarkdown, { source: resource.content ?? '', maxBlocks: 2, maxChars: 240, maxLines: 2, interactive: !staticRender, className: "text-sm text-muted-foreground" })) : null, metaText ? (_jsx("p", { className: "text-muted-foreground text-xs", children: metaText })) : null, tags.length ? (_jsx("div", { className: "flex flex-wrap gap-1", children: tags.map((value) => staticRender ? (_jsxs("span", { className: "bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs", children: ["#", value] }, value)) : (_jsx(ResourceTagChip, { value: value }, value))) })) : null, _jsx("p", { className: "text-muted-foreground text-xs uppercase", children: t(`resources.kinds.${resource.resourceKind}`, {
176
181
  defaultValue: resource.resourceKind,
177
182
  }) })] }));
178
183
  };
@@ -148,5 +148,6 @@ export declare const useNewGroup: () => {
148
148
  error: string | null;
149
149
  clearError: () => void;
150
150
  fieldErrors: GroupFormFieldErrors;
151
+ canCreate: boolean;
151
152
  submit: () => Promise<void>;
152
153
  };
@@ -1,9 +1,10 @@
1
1
  import { useState } from 'react';
2
2
  import { HANDLE_RESERVED_MESSAGE, isForbiddenHandle, } from '@openpeepshq/common/types';
3
- import { applySimpleGroupTemplate, defaultSimpleGroupTemplate, } from '@openpeepshq/common/lib';
3
+ import { applySimpleGroupTemplate, canCreateGroup, defaultSimpleGroupTemplate, } from '@openpeepshq/common/lib';
4
4
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
5
5
  import { useNavigate } from '../../contexts/router/index.js';
6
6
  import { useT } from '../../i18n/context.js';
7
+ import { useCurrentProfile } from '../../components/layout/IdentityContext.js';
7
8
  import { useServerInfo } from '../../components/server-data/context.js';
8
9
  import { apiErrorMessage } from '../../lib/apiErrorMessage.js';
9
10
  import { duplicateHandleMessage, groupFormFieldErrors, hasGroupFormFieldErrors, isDuplicateHandleError, } from '../../lib/groupFormErrors.js';
@@ -16,6 +17,8 @@ const handleFromDisplayName = (displayName) => displayName
16
17
  export const useNewGroup = () => {
17
18
  const t = useT();
18
19
  const navigate = useNavigate();
20
+ const profile = useCurrentProfile();
21
+ const canCreate = !!profile && canCreateGroup(profile.roles);
19
22
  const { openpeepsApi } = useOpenpeeps();
20
23
  const createGroup = openpeepsApi.createGroupAction();
21
24
  const serverInfo = useServerInfo();
@@ -33,6 +36,8 @@ export const useNewGroup = () => {
33
36
  const [error, setError] = useState(null);
34
37
  const [fieldErrors, setFieldErrors] = useState({});
35
38
  const submit = async () => {
39
+ if (!canCreate)
40
+ return;
36
41
  setError(null);
37
42
  const nextFieldErrors = groupFormFieldErrors(groupData, t, {
38
43
  additionalForbiddenHandles,
@@ -90,6 +95,7 @@ export const useNewGroup = () => {
90
95
  error,
91
96
  clearError: () => setError(null),
92
97
  fieldErrors,
98
+ canCreate,
93
99
  submit,
94
100
  };
95
101
  };
@@ -65,7 +65,7 @@ const issueMessage = (issue, t) => {
65
65
  };
66
66
  const submitErrorMessage = (err, t) => {
67
67
  const message = err instanceof Error ? err.message : '';
68
- if (message === 'Forbidden') {
68
+ if (message === 'Forbidden' || message === 'postCreateForbidden') {
69
69
  return t('resources.validation.audienceForbidden', {
70
70
  defaultValue: 'Choose a group you can post this resource in.',
71
71
  });
@@ -1,6 +1,12 @@
1
1
  export interface MarkdownProps {
2
2
  source: string;
3
3
  className?: string;
4
+ /**
5
+ * Render as inline markdown (no block `<p>` wrapper) via `marked.parseInline`.
6
+ * Use for short help text inside tight layouts (e.g. config card rows) where
7
+ * block margins would disrupt alignment.
8
+ */
9
+ inline?: boolean;
4
10
  }
5
11
  /**
6
12
  * Inline Markdown renderer. Uses `marked` synchronously to render trusted
@@ -11,4 +17,4 @@ export interface MarkdownProps {
11
17
  * Svelte app behaves. If you ever feed untrusted markdown through here,
12
18
  * sanitize first.
13
19
  */
14
- export declare function Markdown({ source, className }: MarkdownProps): import("react/jsx-runtime").JSX.Element;
20
+ export declare function Markdown({ source, className, inline }: MarkdownProps): import("react/jsx-runtime").JSX.Element;
@@ -10,7 +10,9 @@ import { marked } from 'marked';
10
10
  * Svelte app behaves. If you ever feed untrusted markdown through here,
11
11
  * sanitize first.
12
12
  */
13
- export function Markdown({ source, className }) {
14
- const html = useMemo(() => marked.parse(source ?? '', { async: false }), [source]);
13
+ export function Markdown({ source, className, inline }) {
14
+ const html = useMemo(() => inline
15
+ ? marked.parseInline(source ?? '', { async: false })
16
+ : marked.parse(source ?? '', { async: false }), [source, inline]);
15
17
  return (_jsx("div", { className: className ?? 'prose prose-sm dark:prose-invert max-w-none', dangerouslySetInnerHTML: { __html: html } }));
16
18
  }
@@ -2,13 +2,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo, useState } from 'react';
3
3
  import { useNavigate } from 'react-router-dom';
4
4
  import { Users } from 'lucide-react';
5
- import { groupName } from '@openpeepshq/common/lib';
6
- import { useT, useOpenpeeps, useSetPageHeader } from '../../index.js';
5
+ import { canCreateGroup, groupName } from '@openpeepshq/common/lib';
6
+ import { useT, useOpenpeeps, useSetPageHeader, useCurrentProfile, } from '../../index.js';
7
7
  import { Button, Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, Input, } from '@openpeepshq/react-ui';
8
8
  import { AdminGroupCard } from './components/AdminGroupCard.js';
9
9
  export function AdminGroups() {
10
10
  const t = useT();
11
11
  const navigate = useNavigate();
12
+ const profile = useCurrentProfile();
13
+ const canCreate = !!profile && canCreateGroup(profile.roles);
12
14
  const { openpeepsApi } = useOpenpeeps();
13
15
  const groupsQuery = openpeepsApi.admin.useAllGroupsList();
14
16
  const [search, setSearch] = useState('');
@@ -16,7 +18,7 @@ export function AdminGroups() {
16
18
  const createLabel = t('groups.create.title', {
17
19
  defaultValue: 'Create Group',
18
20
  });
19
- const headerActions = useMemo(() => (_jsx(Button, { title: createLabel, variant: "default", action: () => navigate('/groups/new'), children: createLabel })), [createLabel, navigate]);
21
+ const headerActions = useMemo(() => canCreate ? (_jsx(Button, { title: createLabel, variant: "default", action: () => navigate('/groups/new'), children: createLabel })) : undefined, [canCreate, createLabel, navigate]);
20
22
  useSetPageHeader(t('admin.groups.title', { defaultValue: 'Groups' }), headerActions);
21
23
  const groups = groupsQuery.data ?? [];
22
24
  const filtered = search
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo, useState } from 'react';
3
3
  import { Plus, Users } from 'lucide-react';
4
- import { checkRoleCapabilities } from '@openpeepshq/common';
4
+ import { canCreateGroup } from '@openpeepshq/common';
5
5
  import { matchesQuery } from '@openpeepshq/common/lib';
6
6
  import { useT, useOpenpeeps, useSetPageHeader, useSetPlusButtonActions, } from '../../index.js';
7
7
  import { GroupCard, useCurrentProfile } from '../../components/index.js';
@@ -20,14 +20,14 @@ export function GroupsIndex() {
20
20
  const tabGroups = useMemo(() => tab === 'mine'
21
21
  ? groups.filter((group) => myGroupIds.has(group.id))
22
22
  : groups, [groups, myGroupIds, tab]);
23
- const plusButton = useMemo(() => checkRoleCapabilities(currentProfile?.roles ?? [], ['core-groups-create'])
24
- .success
23
+ const canCreate = canCreateGroup(currentProfile?.roles ?? []);
24
+ const plusButton = useMemo(() => canCreate
25
25
  ? {
26
26
  title: t('groups.new', { defaultValue: 'New Group' }),
27
27
  icon: Plus,
28
28
  action: '/groups/new',
29
29
  }
30
- : undefined, [currentProfile?.roles, t]);
30
+ : undefined, [canCreate, t]);
31
31
  useSetPlusButtonActions(plusButton);
32
32
  useSetPageHeader(t('navigation.groups', { defaultValue: 'Groups' }));
33
33
  const filtered = useMemo(() => tabGroups.filter((g) => !search || matchesQuery(g, search)), [tabGroups, search]);
@@ -1 +1 @@
1
- export declare function NewGroup(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function NewGroup(): import("react/jsx-runtime").JSX.Element | null;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Navigate } from 'react-router-dom';
2
3
  import { useT, useSetPageHeader } from '../../index.js';
3
4
  import { GroupForm, ProfilesInput, useCurrentProfile } from '../../components/index.js';
4
5
  import { useNewGroup } from '../../hooks/index.js';
@@ -6,8 +7,13 @@ import { Button, Label, Toast } from '@openpeepshq/react-ui';
6
7
  export function NewGroup() {
7
8
  const t = useT();
8
9
  const me = useCurrentProfile();
9
- const { groupData, setGroupData, members, setMembers, submitting, error, clearError, fieldErrors, submit, } = useNewGroup();
10
- useSetPageHeader(t('groups.new.title', { defaultValue: 'Create group' }), undefined, 'groups-create-page-title');
10
+ const { groupData, setGroupData, members, setMembers, submitting, error, clearError, fieldErrors, canCreate, submit, } = useNewGroup();
11
+ useSetPageHeader(canCreate
12
+ ? t('groups.new.title', { defaultValue: 'Create group' })
13
+ : undefined, undefined, canCreate ? 'groups-create-page-title' : undefined);
14
+ if (!canCreate) {
15
+ return me ? _jsx(Navigate, { to: "/groups", replace: true }) : null;
16
+ }
11
17
  return (_jsxs("div", { className: "space-y-4 p-4 pb-12", children: [_jsx(GroupForm, { groupData: groupData, fieldErrors: fieldErrors, onChange: setGroupData }), _jsxs("div", { className: "space-y-2 px-1", children: [_jsx(Label, { htmlFor: "group-members", children: t('groups.form.members', { defaultValue: 'Members' }) }), _jsx(ProfilesInput, { value: members, onChange: setMembers, banlist: me ? [me] : [], placeholder: t('groups.form.membersPlaceholder', {
12
18
  defaultValue: 'Add members to this group',
13
19
  }) })] }), error && (_jsx(Toast, { variant: "error", testId: "groups-duplicate-handle-error", onDismiss: clearError, children: error })), _jsx(Button, { title: "Create group", variant: "default", action: submit, disabled: submitting, "data-testid": "groups-create-submit", children: submitting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,8 +53,8 @@
53
53
  "uuidv7": "^1.0.2",
54
54
  "@openpeepshq/client": "^0.2.1",
55
55
  "@openpeepshq/common": "^0.4.0",
56
- "@openpeepshq/greenscreen": "^0.2.1",
57
- "@openpeepshq/react-ui": "^0.4.1"
56
+ "@openpeepshq/react-ui": "^0.4.1",
57
+ "@openpeepshq/greenscreen": "^0.2.1"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^18.3.0 || ^19.0.0",
@@ -1,6 +1,7 @@
1
1
  import { Link } from 'react-router-dom';
2
2
  import { ChevronRight } from 'lucide-react';
3
3
  import { useT } from '../../i18n';
4
+ import { Markdown } from '../../lib/Markdown';
4
5
 
5
6
  export interface ConfigMenuButtonProps {
6
7
  translationPrefix: string;
@@ -36,10 +37,13 @@ export function ConfigMenuButton({
36
37
  )}
37
38
  </div>
38
39
  <div className="text-muted-foreground text-xs">
39
- {t(
40
- `${translationPrefix}.description`,
41
- descriptionFallback ? { defaultValue: descriptionFallback } : {},
42
- )}
40
+ <Markdown
41
+ inline
42
+ source={t(
43
+ `${translationPrefix}.description`,
44
+ descriptionFallback ? { defaultValue: descriptionFallback } : {},
45
+ )}
46
+ />
43
47
  </div>
44
48
  </div>
45
49
  <span aria-hidden="true">
@@ -224,14 +224,18 @@ export const ResourceForm = ({
224
224
  </Label>
225
225
  ) : (
226
226
  <div className="space-y-2">
227
- <Button
228
- variant="outline"
229
- action={kindActions[resource.resourceKind]}
230
- >
231
- {t('resources.form.addMedia', {
232
- defaultValue: 'Add files',
233
- })}
234
- </Button>
227
+ {/* Only galleries take more than one file; other kinds pick once. */}
228
+ {resource.resourceKind === 'gallery' ||
229
+ (resource.attachments ?? []).length === 0 ? (
230
+ <Button
231
+ variant="outline"
232
+ action={kindActions[resource.resourceKind]}
233
+ >
234
+ {t('resources.form.addMedia', {
235
+ defaultValue: 'Add files',
236
+ })}
237
+ </Button>
238
+ ) : null}
235
239
  {attachments.previews}
236
240
  {attachments.inputs}
237
241
  {mediaMissing ? (
@@ -1,6 +1,7 @@
1
1
  import { useMemo, useState } from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
  import {
4
+ AudioLines,
4
5
  BookmarkCheck,
5
6
  BookmarkPlus,
6
7
  Link as LinkIcon,
@@ -36,8 +37,12 @@ export interface ResourceCardProps {
36
37
  inGroup?: boolean;
37
38
  }
38
39
 
40
+ // Audio attachments render their generated waveform preview like any other
41
+ // visual; without one they fall back to the kind placeholder below.
39
42
  const visualAttachments = (attachments: MediaAttachmentData[]) =>
40
- attachments.filter((att) => attachmentMediaKind(att) !== 'audio');
43
+ attachments.filter(
44
+ (att) => attachmentMediaKind(att) !== 'audio' || !!att.previewUrl,
45
+ );
41
46
 
42
47
  const previewSrc = (att: MediaAttachmentData) => att.previewUrl ?? att.url;
43
48
 
@@ -300,6 +305,13 @@ export const ResourceCard = ({
300
305
  />
301
306
  );
302
307
  }
308
+ if (resource.resourceKind === 'audio') {
309
+ return (
310
+ <div className="bg-muted flex h-12 w-12 items-center justify-center rounded-md">
311
+ <AudioLines className="text-muted-foreground size-5" />
312
+ </div>
313
+ );
314
+ }
303
315
  if (resource.resourceKind === 'link' && resource.url) {
304
316
  return (
305
317
  <div className="bg-muted flex h-12 w-12 items-center justify-center rounded-md">
@@ -400,6 +412,10 @@ export const ResourceCard = ({
400
412
  );
401
413
  })}
402
414
  </div>
415
+ ) : resource.resourceKind === 'audio' ? (
416
+ <div className="bg-muted flex h-48 w-full items-center justify-center rounded-md">
417
+ <AudioLines className="text-muted-foreground/50 size-8" />
418
+ </div>
403
419
  ) : resource.resourceKind === 'link' && resource.url ? (
404
420
  <div className="bg-muted flex h-48 w-full items-center justify-center rounded-md">
405
421
  <LinkIcon className="text-muted-foreground/50 size-8" />
@@ -7,11 +7,13 @@ import {
7
7
  } from '@openpeepshq/common/types';
8
8
  import {
9
9
  applySimpleGroupTemplate,
10
+ canCreateGroup,
10
11
  defaultSimpleGroupTemplate,
11
12
  } from '@openpeepshq/common/lib';
12
13
  import { useOpenpeeps } from '../../contexts/openpeeps';
13
14
  import { useNavigate } from '../../contexts/router';
14
15
  import { useT } from '../../i18n/context';
16
+ import { useCurrentProfile } from '../../components/layout/IdentityContext';
15
17
  import { useServerInfo } from '../../components/server-data/context';
16
18
  import { apiErrorMessage } from '../../lib/apiErrorMessage';
17
19
  import {
@@ -33,6 +35,8 @@ const handleFromDisplayName = (displayName: string) =>
33
35
  export const useNewGroup = () => {
34
36
  const t = useT();
35
37
  const navigate = useNavigate();
38
+ const profile = useCurrentProfile();
39
+ const canCreate = !!profile && canCreateGroup(profile.roles);
36
40
  const { openpeepsApi } = useOpenpeeps();
37
41
  const createGroup = openpeepsApi.createGroupAction();
38
42
  const serverInfo = useServerInfo();
@@ -54,6 +58,7 @@ export const useNewGroup = () => {
54
58
  const [fieldErrors, setFieldErrors] = useState<GroupFormFieldErrors>({});
55
59
 
56
60
  const submit = async () => {
61
+ if (!canCreate) return;
57
62
  setError(null);
58
63
  const nextFieldErrors = groupFormFieldErrors(groupData, t, {
59
64
  additionalForbiddenHandles,
@@ -119,6 +124,7 @@ export const useNewGroup = () => {
119
124
  error,
120
125
  clearError: () => setError(null),
121
126
  fieldErrors,
127
+ canCreate,
122
128
  submit,
123
129
  };
124
130
  };
@@ -92,7 +92,7 @@ const submitErrorMessage = (
92
92
  t: (key: string, options: { defaultValue: string }) => string,
93
93
  ) => {
94
94
  const message = err instanceof Error ? err.message : '';
95
- if (message === 'Forbidden') {
95
+ if (message === 'Forbidden' || message === 'postCreateForbidden') {
96
96
  return t('resources.validation.audienceForbidden', {
97
97
  defaultValue: 'Choose a group you can post this resource in.',
98
98
  });
@@ -4,6 +4,12 @@ import { marked } from 'marked';
4
4
  export interface MarkdownProps {
5
5
  source: string;
6
6
  className?: string;
7
+ /**
8
+ * Render as inline markdown (no block `<p>` wrapper) via `marked.parseInline`.
9
+ * Use for short help text inside tight layouts (e.g. config card rows) where
10
+ * block margins would disrupt alignment.
11
+ */
12
+ inline?: boolean;
7
13
  }
8
14
 
9
15
  /**
@@ -15,10 +21,13 @@ export interface MarkdownProps {
15
21
  * Svelte app behaves. If you ever feed untrusted markdown through here,
16
22
  * sanitize first.
17
23
  */
18
- export function Markdown({ source, className }: MarkdownProps) {
24
+ export function Markdown({ source, className, inline }: MarkdownProps) {
19
25
  const html = useMemo(
20
- () => marked.parse(source ?? '', { async: false }) as string,
21
- [source],
26
+ () =>
27
+ inline
28
+ ? (marked.parseInline(source ?? '', { async: false }) as string)
29
+ : (marked.parse(source ?? '', { async: false }) as string),
30
+ [source, inline],
22
31
  );
23
32
  return (
24
33
  <div
@@ -1,9 +1,14 @@
1
1
  import { useMemo, useState } from 'react';
2
2
  import { useNavigate } from 'react-router-dom';
3
3
  import { Users } from 'lucide-react';
4
- import { groupName } from '@openpeepshq/common/lib';
4
+ import { canCreateGroup, groupName } from '@openpeepshq/common/lib';
5
5
  import type { AdminGroup } from '@openpeepshq/common/types';
6
- import { useT, useOpenpeeps, useSetPageHeader } from '../../index';
6
+ import {
7
+ useT,
8
+ useOpenpeeps,
9
+ useSetPageHeader,
10
+ useCurrentProfile,
11
+ } from '../../index';
7
12
  import {
8
13
  Button,
9
14
  Dialog,
@@ -18,6 +23,8 @@ import { AdminGroupCard } from './components/AdminGroupCard';
18
23
  export function AdminGroups() {
19
24
  const t = useT();
20
25
  const navigate = useNavigate();
26
+ const profile = useCurrentProfile();
27
+ const canCreate = !!profile && canCreateGroup(profile.roles);
21
28
  const { openpeepsApi } = useOpenpeeps();
22
29
  const groupsQuery = openpeepsApi.admin.useAllGroupsList();
23
30
  const [search, setSearch] = useState('');
@@ -27,16 +34,17 @@ export function AdminGroups() {
27
34
  defaultValue: 'Create Group',
28
35
  });
29
36
  const headerActions = useMemo(
30
- () => (
31
- <Button
32
- title={createLabel}
33
- variant="default"
34
- action={() => navigate('/groups/new')}
35
- >
36
- {createLabel}
37
- </Button>
38
- ),
39
- [createLabel, navigate],
37
+ () =>
38
+ canCreate ? (
39
+ <Button
40
+ title={createLabel}
41
+ variant="default"
42
+ action={() => navigate('/groups/new')}
43
+ >
44
+ {createLabel}
45
+ </Button>
46
+ ) : undefined,
47
+ [canCreate, createLabel, navigate],
40
48
  );
41
49
 
42
50
  useSetPageHeader(
@@ -1,6 +1,6 @@
1
1
  import { useMemo, useState, type ReactNode } from 'react';
2
2
  import { Plus, Users } from 'lucide-react';
3
- import { checkRoleCapabilities } from '@openpeepshq/common';
3
+ import { canCreateGroup } from '@openpeepshq/common';
4
4
  import { matchesQuery } from '@openpeepshq/common/lib';
5
5
  import {
6
6
  useT,
@@ -43,17 +43,17 @@ export function GroupsIndex() {
43
43
  [groups, myGroupIds, tab],
44
44
  );
45
45
 
46
+ const canCreate = canCreateGroup(currentProfile?.roles ?? []);
46
47
  const plusButton = useMemo(
47
48
  () =>
48
- checkRoleCapabilities(currentProfile?.roles ?? [], ['core-groups-create'])
49
- .success
49
+ canCreate
50
50
  ? {
51
51
  title: t('groups.new', { defaultValue: 'New Group' }),
52
52
  icon: Plus,
53
53
  action: '/groups/new',
54
54
  }
55
55
  : undefined,
56
- [currentProfile?.roles, t],
56
+ [canCreate, t],
57
57
  );
58
58
  useSetPlusButtonActions(plusButton);
59
59
 
@@ -1,3 +1,4 @@
1
+ import { Navigate } from 'react-router-dom';
1
2
  import { useT, useSetPageHeader } from '../../index';
2
3
  import { GroupForm, ProfilesInput, useCurrentProfile } from '../../components';
3
4
  import { useNewGroup } from '../../hooks';
@@ -15,15 +16,22 @@ export function NewGroup() {
15
16
  error,
16
17
  clearError,
17
18
  fieldErrors,
19
+ canCreate,
18
20
  submit,
19
21
  } = useNewGroup();
20
22
 
21
23
  useSetPageHeader(
22
- t('groups.new.title', { defaultValue: 'Create group' }),
24
+ canCreate
25
+ ? t('groups.new.title', { defaultValue: 'Create group' })
26
+ : undefined,
23
27
  undefined,
24
- 'groups-create-page-title',
28
+ canCreate ? 'groups-create-page-title' : undefined,
25
29
  );
26
30
 
31
+ if (!canCreate) {
32
+ return me ? <Navigate to="/groups" replace /> : null;
33
+ }
34
+
27
35
  return (
28
36
  <div className="space-y-4 p-4 pb-12">
29
37
  <GroupForm