@openpeepshq/react 0.8.2 → 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.
@@ -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',
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,9 +52,9 @@
52
52
  "simple-icons": "^16.31.0",
53
53
  "uuidv7": "^1.0.2",
54
54
  "@openpeepshq/client": "^0.2.1",
55
- "@openpeepshq/greenscreen": "^0.2.1",
56
55
  "@openpeepshq/common": "^0.4.0",
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",
@@ -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 ? (
@@ -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
  });