@ossy/resources 1.11.7 → 1.12.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/resources",
3
3
  "description": "Resource domain — aggregate and events for the Ossy resource model",
4
- "version": "1.11.7",
4
+ "version": "1.12.0",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "./src/index.js",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@jest/globals": "^30.2.0",
22
- "@ossy/platform": "^1.38.7",
22
+ "@ossy/platform": "^1.39.0",
23
23
  "casual": "^1.6.2",
24
24
  "jest": "^30.2.0"
25
25
  },
@@ -31,5 +31,5 @@
31
31
  "/src",
32
32
  "README.md"
33
33
  ],
34
- "gitHead": "f65df0cd6da864c314c4f424112e05e8e2dec0ff"
34
+ "gitHead": "d9d31182be64a448d575da432af2830d909ad4b9"
35
35
  }
@@ -6,11 +6,13 @@ import {
6
6
  Button,
7
7
  View,
8
8
  useInputValue,
9
- Text
9
+ Text,
10
+ useLocale,
10
11
  } from '@ossy/design-system'
11
12
  import { useRouter } from '@ossy/router-react'
12
13
 
13
14
  export const CreateDirectory = () => {
15
+ const { t } = useLocale()
14
16
  const router = useRouter()
15
17
  const { createDirectory } = useResources()
16
18
  const [directoryName, setDirectoryName] = useInputValue('')
@@ -24,11 +26,11 @@ export const CreateDirectory = () => {
24
26
 
25
27
 
26
28
  if (!directoryName || directoryName.trim() === '') {
27
- return setError('Directory name cannot be empty')
29
+ return setError(t('resources.createDirectory.errorEmpty'))
28
30
  }
29
31
 
30
32
  if (directoryName?.startsWith?.('@ossy') || directoryName?.startsWith?.('/@ossy')) {
31
- setError('Directory name cannot start with @ossy')
33
+ setError(t('resources.createDirectory.errorOssyPrefix'))
32
34
  return
33
35
  }
34
36
 
@@ -48,11 +50,10 @@ export const CreateDirectory = () => {
48
50
  return (
49
51
  <View gap="s" style={{ height: '100%' }}>
50
52
 
51
- <Title variant="primary" style={{ marginBottom: 'var(--space-m)' }}>Create a new directory</Title>
53
+ <Title variant="primary" style={{ marginBottom: 'var(--space-m)' }}>{t('resources.createDirectory.title')}</Title>
52
54
 
53
55
  <Text style={{ marginBottom: 'var(--space-m)' }}>
54
- Create a new directory to organize your resources.
55
- The new directory will be created in the location: {directoryLocation}
56
+ {t('resources.createDirectory.description', { location: directoryLocation })}
56
57
  </Text>
57
58
 
58
59
  <form
@@ -64,7 +65,7 @@ export const CreateDirectory = () => {
64
65
  <Input
65
66
  id="path"
66
67
  type="text"
67
- placeholder="Directory name"
68
+ placeholder={t('resources.createDirectory.namePlaceholder')}
68
69
  value={directoryName}
69
70
  onChange={setDirectoryName}
70
71
  style={{ width: '100%', marginBottom: 'var(--space-l)' }}
@@ -78,14 +79,14 @@ export const CreateDirectory = () => {
78
79
  <Button
79
80
  id="cancel"
80
81
  onClick={() => router.navigate('@back')}
81
- >Cancel
82
+ >{t('design-system.cancel')}
82
83
  </Button>
83
84
 
84
85
  <Button
85
86
  id="createDirectory"
86
87
  variant="cta"
87
88
  onClick={onCreateDirectory}
88
- >Create directory
89
+ >{t('resources.createDirectory.submit')}
89
90
  </Button>
90
91
 
91
92
  </View>
@@ -95,4 +96,3 @@ export const CreateDirectory = () => {
95
96
  )
96
97
  }
97
98
 
98
-
@@ -1,10 +1,11 @@
1
1
  import React, { useState } from 'react'
2
2
  import { useResources } from '@ossy/sdk-react'
3
- import { Alert } from '@ossy/design-system'
3
+ import { Alert, useLocale } from '@ossy/design-system'
4
4
  import { useRouter } from '@ossy/router-react'
5
5
  import { GenericResourceForm } from './GenericResourceForm.jsx'
6
6
 
7
7
  export const CreateDocument = () => {
8
+ const { t } = useLocale()
8
9
  const router = useRouter()
9
10
  const templateId = router.searchParams.templateId
10
11
  const location = router.searchParams.location
@@ -19,7 +20,7 @@ export const CreateDocument = () => {
19
20
  const onSubmit = ({ name, content, type }) => {
20
21
  createDocument({ type, location, name, content })
21
22
  .then(() => onCancel())
22
- .catch((err) => setError(err?.message || 'Create failed'))
23
+ .catch((err) => setError(err?.message || t('resources.form.createFailed')))
23
24
  }
24
25
 
25
26
  return (
package/src/Definition.js CHANGED
@@ -8,12 +8,6 @@ export const Definition = {
8
8
  explore the gallery below to discover valuable assets that align with your vision.
9
9
  We hope you find them useful, and we're here if you have any questions!
10
10
  `,
11
- module: {
12
- id: 'resources',
13
- enabled: true
14
- },
11
+ icon: 'image',
15
12
  statuses: ['beta'],
16
- actions: ['resources.create', 'resources.update-content', 'resources.remove'],
17
- views: ['home.page', 'resources.list', 'resources.get'],
18
- tasks: []
19
- }
13
+ }
@@ -12,6 +12,7 @@ import {
12
12
  Fields,
13
13
  applyFieldChange,
14
14
  useInputValue,
15
+ useLocale,
15
16
  } from '@ossy/design-system'
16
17
 
17
18
  function GenericResourceFormFallback ({
@@ -23,6 +24,7 @@ function GenericResourceFormFallback ({
23
24
  onCancel,
24
25
  submitLabel,
25
26
  }) {
27
+ const { t } = useLocale()
26
28
  const template = useResourceTemplate(templateId)
27
29
  const [name, setName] = useInputValue(initialName)
28
30
  const [content, setContent] = useState(initialContent)
@@ -30,7 +32,7 @@ function GenericResourceFormFallback ({
30
32
 
31
33
  const handleSubmit = () => {
32
34
  if (!name?.trim()) {
33
- setError('Name is required')
35
+ setError(t('resources.form.nameRequired'))
34
36
  return
35
37
  }
36
38
  setError(undefined)
@@ -42,7 +44,7 @@ function GenericResourceFormFallback ({
42
44
  <InputTitle
43
45
  id="resource-name"
44
46
  type="text"
45
- placeholder="Untitled"
47
+ placeholder={t('resources.form.untitled')}
46
48
  value={name}
47
49
  onChange={setName}
48
50
  />
@@ -53,9 +55,9 @@ function GenericResourceFormFallback ({
53
55
  />
54
56
  {error && <Alert>{error}</Alert>}
55
57
  <View layout="row" gap="s" justifyContent="flex-end">
56
- {onCancel && <Button variant="link" onClick={onCancel}>Cancel</Button>}
58
+ {onCancel && <Button variant="link" onClick={onCancel}>{t('design-system.cancel')}</Button>}
57
59
  <Button variant="cta" onClick={handleSubmit}>
58
- {submitLabel || (mode === 'edit' ? 'Save' : `Create ${template?.name || 'resource'}`)}
60
+ {submitLabel || (mode === 'edit' ? t('design-system.save') : (template?.name ? `${t('design-system.add')} ${template.name}` : t('resources.form.createResource')))}
59
61
  </Button>
60
62
  </View>
61
63
  </View>
@@ -77,8 +79,10 @@ export function GenericResourceForm ({
77
79
  onCancel,
78
80
  submitLabel,
79
81
  }) {
82
+ const { t } = useLocale()
83
+
80
84
  if (!templateId) {
81
- return <Text>Select a resource type to continue.</Text>
85
+ return <Text>{t('resources.form.selectType')}</Text>
82
86
  }
83
87
 
84
88
  return (
@@ -1,9 +1,8 @@
1
1
  import React from 'react'
2
2
  import { SDK } from '@ossy/sdk'
3
3
  import { useResources, AsyncStatus, WorkspaceProvider } from '@ossy/sdk-react'
4
- import { Title, Text, Switch, View, ImageCard, Tags } from '@ossy/design-system'
4
+ import { Title, Text, Switch, View, ImageCard, Tags, useLocale } from '@ossy/design-system'
5
5
  import { useRouter } from '@ossy/router-react'
6
- import { Definition } from './Definition.js'
7
6
 
8
7
  const sdk = SDK.of({
9
8
  /** Ossy.se workspaceID - used to fetch free resources */
@@ -18,6 +17,7 @@ const freeResourcesGridStyles = {
18
17
 
19
18
  export const ResourcesPage= () => {
20
19
  const router = useRouter()
20
+ const { t } = useLocale()
21
21
  const { status, resources } = useResources('/publications/images/')
22
22
  const tags = resources.flatMap(resource => resource?.content?.tags || [])
23
23
  const tagsCount = tags.reduce((acc, t) => ({ ...acc, [t]: (acc?.[t] ?? 0) + 1 }), {})
@@ -34,8 +34,8 @@ export const ResourcesPage= () => {
34
34
  <View gap="l" style={{ margin: '0 auto' }}>
35
35
 
36
36
  <View gap="m">
37
- <Title>{Definition.title}</Title>
38
- <Text style={{ maxWidth: '900px'}}>{Definition.description}</Text>
37
+ <Title>{t('resources.home.title')}</Title>
38
+ <Text style={{ maxWidth: '900px'}}>{t('resources.home.description')}</Text>
39
39
  </View>
40
40
 
41
41
  <WorkspaceProvider sdk={sdk}>
@@ -1,26 +1,23 @@
1
1
  import React from 'react'
2
2
  import { useResources } from '@ossy/sdk-react'
3
- import { Title, View, Text, Upload as _Upload } from '@ossy/design-system'
3
+ import { Title, View, Text, useLocale } from '@ossy/design-system'
4
4
  import { useRouter } from '@ossy/router-react'
5
5
  import { Upload } from './Upload.jsx'
6
6
 
7
7
  export const UploadResources = () => {
8
+ const { t } = useLocale()
8
9
  const router = useRouter()
9
10
  const location = router.searchParams.location
10
11
  const { uploadFile } = useResources()
11
12
 
12
13
  return (
13
14
  <View gap="s" style={{ height: '100%' }}>
14
-
15
15
  <View gap="s">
16
- <Title variant="tertiary" style={{ marginBottom: '0' }}>
17
- Upload
18
- </Title>
16
+ <Title variant="tertiary" style={{ marginBottom: '0' }}>{t('resources.upload.title')}</Title>
19
17
  <View layout="row" gap="s">
20
- <Text variant="small" >Location: {location}</Text>
18
+ <Text variant="small">{t('resources.upload.location', { location })}</Text>
21
19
  </View>
22
20
  </View>
23
-
24
21
  <Upload
25
22
  onUpload={(file) => uploadFile(location, file)}
26
23
  onCancel={() => router.navigate(`@storage/home?location=${location}`)}
@@ -28,4 +25,4 @@ export const UploadResources = () => {
28
25
  />
29
26
  </View>
30
27
  )
31
- }
28
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "resources.home.documentTitle": "Free Resources",
3
+ "resources.home.title": "Free Resources",
4
+ "resources.home.description": "We believe in providing value at every step of your journey with us. That's why we've curated a collection of free resources. Whether you're looking to enhance your creative projects or simply seeking inspiration, explore the gallery below to discover valuable assets that align with your vision. We hope you find them useful, and we're here if you have any questions!",
5
+ "resources.form.nameRequired": "Name is required",
6
+ "resources.form.untitled": "Untitled",
7
+ "resources.form.selectType": "Select a resource type to continue.",
8
+ "resources.form.createFailed": "Create failed",
9
+ "resources.form.createResource": "Create resource",
10
+ "resources/create.label": "Create resource",
11
+ "resources/create.description": "Create a new resource in the workspace",
12
+ "resources/list.label": "List resources",
13
+ "resources/list.description": "List resources in a workspace location",
14
+ "resources/get.label": "Get resource",
15
+ "resources/get.description": "Fetch a single resource by id",
16
+ "resources/search.label": "Search resources",
17
+ "resources/search.description": "Search resources in a workspace",
18
+ "resources/delete.label": "Delete resource",
19
+ "resources/delete.description": "Delete a resource from the workspace",
20
+ "resources/update-name.label": "Update resource name",
21
+ "resources/update-name.description": "Rename a workspace resource",
22
+ "resources/update-content.label": "Update resource content",
23
+ "resources/update-content.description": "Update the content of a workspace resource",
24
+ "resources/update-location.label": "Update resource location",
25
+ "resources/update-location.description": "Move a resource to a new location",
26
+ "resources/update-access.label": "Update resource access",
27
+ "resources/update-access.description": "Change access settings for a resource",
28
+ "resources/upload-named-version.label": "Upload named version",
29
+ "resources/upload-named-version.description": "Upload a named version of a resource file",
30
+ "resources/create-page-view.label": "Create page view",
31
+ "resources/create-page-view.description": "Record a page view analytics event",
32
+ "resources/get-page-view-stats.label": "Get page view stats",
33
+ "resources/get-page-view-stats.description": "Fetch aggregated page view statistics",
34
+ "resources.create.generic.documentTitle": "Create resource",
35
+ "createDirectory.documentTitle": "Create directory",
36
+ "createDocument.documentTitle": "Create document",
37
+ "uploadMedia.documentTitle": "Upload",
38
+ "@resource.documentTitle": "Resource",
39
+ "resources.upload.title": "Upload",
40
+ "resources.upload.location": "Location: {location}",
41
+ "resources.createDirectory.title": "Create directory",
42
+ "resources.createDocument.title": "Create document",
43
+ "resources.createDirectory.description": "Create a new directory to organize your resources. The new directory will be created in the location: {location}",
44
+ "resources.createDirectory.namePlaceholder": "Directory name",
45
+ "resources.createDirectory.submit": "Create directory",
46
+ "resources.createDirectory.errorEmpty": "Directory name cannot be empty",
47
+ "resources.createDirectory.errorOssyPrefix": "Directory name cannot start with @ossy"
48
+ }
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from 'react'
2
2
  import { useResources } from '@ossy/sdk-react'
3
- import { View } from '@ossy/design-system'
3
+ import { View, useLocale } from '@ossy/design-system'
4
4
  import { useRouter } from '@ossy/router-react'
5
5
  import { GenericResourceForm } from './GenericResourceForm.jsx'
6
6
 
@@ -15,6 +15,7 @@ export const metadata = {
15
15
  /** Generic resource create page — slot lookup with template Fields fallback. */
16
16
  export default function GenericResourceCreatePage () {
17
17
  const router = useRouter()
18
+ const { t } = useLocale()
18
19
  const templateId = decodeURIComponent(router.params.templateId || '')
19
20
  const location = router.searchParams.location
20
21
  const { createDocument } = useResources()
@@ -28,7 +29,7 @@ export default function GenericResourceCreatePage () {
28
29
  const onSubmit = ({ name, content, type }) => {
29
30
  createDocument({ type, location, name, content })
30
31
  .then(() => onCancel())
31
- .catch((err) => setError(err?.message || 'Create failed'))
32
+ .catch((err) => setError(err?.message || t('resources.form.createFailed')))
32
33
  }
33
34
 
34
35
  return (
@@ -5,14 +5,12 @@ import { GenericResourceDetail } from './GenericResourceDetail.jsx'
5
5
 
6
6
  export const metadata = {
7
7
  id: '@resource',
8
- title: 'Resource',
9
8
  path: {
10
9
  en: '/resources/item/:resourceId',
11
10
  sv: '/resources/objekt/:resourceId',
12
11
  },
13
12
  }
14
13
 
15
- /** Generic resource detail page — slot lookup with template fallback. */
16
14
  export default function ResourceDetailPage () {
17
15
  const router = useRouter()
18
16
  const resourceId = router.params.resourceId
@@ -0,0 +1,48 @@
1
+ {
2
+ "resources.home.documentTitle": "Gratis resurser",
3
+ "resources.home.title": "Gratis resurser",
4
+ "resources.home.description": "Vi tror på att leverera värde i varje steg av din resa med oss. Därför har vi samlat gratis resurser. Oavsett om du vill förbättra dina kreativa projekt eller bara söker inspiration kan du utforska galleriet nedan. Vi hoppas att du hittar något användbart — hör av dig om du har frågor!",
5
+ "resources.form.nameRequired": "Namn krävs",
6
+ "resources.form.untitled": "Namnlös",
7
+ "resources.form.selectType": "Välj en resurstyp för att fortsätta.",
8
+ "resources.form.createFailed": "Skapandet misslyckades",
9
+ "resources.form.createResource": "Skapa resurs",
10
+ "resources/create.label": "Skapa resurs",
11
+ "resources/create.description": "Skapa en ny resurs i workspace",
12
+ "resources/list.label": "Lista resurser",
13
+ "resources/list.description": "Lista resurser på en plats i workspace",
14
+ "resources/get.label": "Hämta resurs",
15
+ "resources/get.description": "Hämta en enskild resurs via id",
16
+ "resources/search.label": "Sök resurser",
17
+ "resources/search.description": "Sök resurser i en workspace",
18
+ "resources/delete.label": "Ta bort resurs",
19
+ "resources/delete.description": "Ta bort en resurs från workspace",
20
+ "resources/update-name.label": "Uppdatera resursnamn",
21
+ "resources/update-name.description": "Byt namn på en resurs i workspace",
22
+ "resources/update-content.label": "Uppdatera resursinnehåll",
23
+ "resources/update-content.description": "Uppdatera innehållet i en resurs",
24
+ "resources/update-location.label": "Uppdatera resursplats",
25
+ "resources/update-location.description": "Flytta en resurs till en ny plats",
26
+ "resources/update-access.label": "Uppdatera resursåtkomst",
27
+ "resources/update-access.description": "Ändra åtkomstinställningar för en resurs",
28
+ "resources/upload-named-version.label": "Ladda upp namngiven version",
29
+ "resources/upload-named-version.description": "Ladda upp en namngiven version av en resursfil",
30
+ "resources/create-page-view.label": "Skapa sidvisning",
31
+ "resources/create-page-view.description": "Registrera en sidvisningshändelse för analys",
32
+ "resources/get-page-view-stats.label": "Hämta sidvisningsstatistik",
33
+ "resources/get-page-view-stats.description": "Hämta aggregerad statistik för sidvisningar",
34
+ "resources.create.generic.documentTitle": "Skapa resurs",
35
+ "createDirectory.documentTitle": "Skapa mapp",
36
+ "createDocument.documentTitle": "Skapa dokument",
37
+ "uploadMedia.documentTitle": "Ladda upp",
38
+ "@resource.documentTitle": "Resurs",
39
+ "resources.upload.title": "Ladda upp",
40
+ "resources.upload.location": "Plats: {location}",
41
+ "resources.createDirectory.title": "Skapa mapp",
42
+ "resources.createDocument.title": "Skapa dokument",
43
+ "resources.createDirectory.description": "Skapa en ny mapp för att organisera dina resurser. Den nya mappen skapas på platsen: {location}",
44
+ "resources.createDirectory.namePlaceholder": "Mappnamn",
45
+ "resources.createDirectory.submit": "Skapa mapp",
46
+ "resources.createDirectory.errorEmpty": "Mappnamn får inte vara tomt",
47
+ "resources.createDirectory.errorOssyPrefix": "Mappnamn får inte börja med @ossy"
48
+ }