@ossy/resources 1.11.7 → 1.12.1
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 +10 -4
- package/src/AudioResource.jsx +4 -2
- package/src/CreateDirectory.jsx +14 -13
- package/src/CreateDocument.jsx +7 -5
- package/src/Definition.js +2 -8
- package/src/DocumentEdit.jsx +9 -6
- package/src/DocumentView.jsx +8 -4
- package/src/GenericResourceCard.jsx +4 -2
- package/src/GenericResourceDetail.jsx +9 -4
- package/src/GenericResourceForm.jsx +14 -7
- package/src/ImageResource.jsx +4 -2
- package/src/PDFResource.jsx +4 -2
- package/src/ResourceContentPage.jsx +4 -2
- package/src/ResourceDescription.jsx +4 -3
- package/src/ResourceDetails.jsx +9 -4
- package/src/ResourceDialogMove.jsx +4 -3
- package/src/ResourceFactory.jsx +6 -3
- package/src/ResourceGenericView.jsx +4 -2
- package/src/ResourceList.jsx +4 -2
- package/src/ResourcePanel.jsx +9 -12
- package/src/ResourceTags.jsx +4 -3
- package/src/ResourcesPage.jsx +8 -6
- package/src/UploadResources.jsx +9 -11
- package/src/VideoResource.jsx +4 -2
- package/src/create-page-view.action.js +1 -38
- package/src/create-page-view.task.js +38 -0
- package/src/create.action.js +1 -98
- package/src/create.task.js +100 -0
- package/src/delete.action.js +1 -31
- package/src/delete.task.js +31 -0
- package/src/en.translations.json +48 -0
- package/src/get-page-view-stats.action.js +1 -65
- package/src/get-page-view-stats.task.js +64 -0
- package/src/get.action.js +1 -14
- package/src/get.task.js +14 -0
- package/src/index.js +13 -4
- package/src/list.action.js +1 -19
- package/src/list.task.js +20 -0
- package/src/resource-create.page.jsx +7 -5
- package/src/resource-detail.page.jsx +0 -2
- package/src/resource.helpers.js +83 -0
- package/src/resources.action-media.js +18 -0
- package/src/resources.attach-media-urls.js +1 -1
- package/src/resources.events.js +1 -0
- package/src/resources.spec.js +54 -55
- package/src/search.action.js +1 -19
- package/src/search.task.js +20 -0
- package/src/server.js +4 -0
- package/src/sv.translations.json +48 -0
- package/src/update-access.action.js +1 -20
- package/src/update-access.task.js +22 -0
- package/src/update-content.action.js +1 -39
- package/src/update-content.task.js +41 -0
- package/src/update-location.action.js +1 -18
- package/src/update-location.task.js +20 -0
- package/src/update-name.action.js +1 -18
- package/src/update-name.task.js +20 -0
- package/src/upload-named-version.action.js +1 -42
- package/src/upload-named-version.task.js +46 -0
- package/src/item-access.api.js +0 -34
- package/src/item-content.api.js +0 -35
- package/src/item-location.api.js +0 -34
- package/src/item-name.api.js +0 -34
- package/src/item-version.api.js +0 -48
- package/src/item.api.js +0 -58
- package/src/list.api.js +0 -43
- package/src/page-views-stats.api.js +0 -23
- package/src/page-views.api.js +0 -23
- package/src/search.api.js +0 -27
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/resources",
|
|
3
3
|
"description": "Resource domain — aggregate and events for the Ossy resource model",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.12.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./src/index.js",
|
|
8
8
|
"module": "./src/index.js",
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./src/index.js"
|
|
10
|
+
".": "./src/index.js",
|
|
11
|
+
"./server": "./src/server.js"
|
|
11
12
|
},
|
|
12
13
|
"scripts": {
|
|
13
14
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose"
|
|
@@ -17,9 +18,14 @@
|
|
|
17
18
|
"ossy": {
|
|
18
19
|
"src": "./src"
|
|
19
20
|
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@ossy/sdk-react": ">=1.0.0",
|
|
23
|
+
"@ossy/workspaces": ">=1.0.0",
|
|
24
|
+
"react": ">=19.0.0 <20.0.0"
|
|
25
|
+
},
|
|
20
26
|
"devDependencies": {
|
|
21
27
|
"@jest/globals": "^30.2.0",
|
|
22
|
-
"@ossy/platform": "^1.
|
|
28
|
+
"@ossy/platform": "^1.39.1",
|
|
23
29
|
"casual": "^1.6.2",
|
|
24
30
|
"jest": "^30.2.0"
|
|
25
31
|
},
|
|
@@ -31,5 +37,5 @@
|
|
|
31
37
|
"/src",
|
|
32
38
|
"README.md"
|
|
33
39
|
],
|
|
34
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c0ba5d90749690634e4dc2705178ff8d89dd3070"
|
|
35
41
|
}
|
package/src/AudioResource.jsx
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import { View } from '@ossy/design-system'
|
|
4
5
|
|
|
5
6
|
export const AudioResource = ({
|
|
6
7
|
resourceId,
|
|
7
8
|
onClose: _onClose
|
|
8
9
|
}) => {
|
|
9
|
-
const
|
|
10
|
+
const sdk = useSdk()
|
|
11
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
10
12
|
|
|
11
13
|
return (
|
|
12
14
|
<View stack bordered>
|
package/src/CreateDirectory.jsx
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import React, { useState, useRef } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { createDirectory } from './resource.helpers.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import {
|
|
4
5
|
Input,
|
|
5
6
|
Title,
|
|
6
7
|
Button,
|
|
7
8
|
View,
|
|
8
9
|
useInputValue,
|
|
9
|
-
Text
|
|
10
|
+
Text,
|
|
11
|
+
useLocale,
|
|
10
12
|
} from '@ossy/design-system'
|
|
11
13
|
import { useRouter } from '@ossy/router-react'
|
|
12
14
|
|
|
13
15
|
export const CreateDirectory = () => {
|
|
16
|
+
const { t } = useLocale()
|
|
14
17
|
const router = useRouter()
|
|
15
|
-
const
|
|
18
|
+
const sdk = useSdk()
|
|
16
19
|
const [directoryName, setDirectoryName] = useInputValue('')
|
|
17
20
|
const [error, setError] = useState()
|
|
18
21
|
const formRef = useRef()
|
|
@@ -24,15 +27,15 @@ export const CreateDirectory = () => {
|
|
|
24
27
|
|
|
25
28
|
|
|
26
29
|
if (!directoryName || directoryName.trim() === '') {
|
|
27
|
-
return setError('
|
|
30
|
+
return setError(t('resources.createDirectory.errorEmpty'))
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
if (directoryName?.startsWith?.('@ossy') || directoryName?.startsWith?.('/@ossy')) {
|
|
31
|
-
setError('
|
|
34
|
+
setError(t('resources.createDirectory.errorOssyPrefix'))
|
|
32
35
|
return
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
formRef.current.reportValidity() && createDirectory({
|
|
38
|
+
formRef.current.reportValidity() && createDirectory(sdk, {
|
|
36
39
|
name: directoryName,
|
|
37
40
|
location: directoryLocation
|
|
38
41
|
})
|
|
@@ -48,11 +51,10 @@ export const CreateDirectory = () => {
|
|
|
48
51
|
return (
|
|
49
52
|
<View gap="s" style={{ height: '100%' }}>
|
|
50
53
|
|
|
51
|
-
<Title variant="primary" style={{ marginBottom: 'var(--space-m)' }}>
|
|
54
|
+
<Title variant="primary" style={{ marginBottom: 'var(--space-m)' }}>{t('resources.createDirectory.title')}</Title>
|
|
52
55
|
|
|
53
56
|
<Text style={{ marginBottom: 'var(--space-m)' }}>
|
|
54
|
-
|
|
55
|
-
The new directory will be created in the location: {directoryLocation}
|
|
57
|
+
{t('resources.createDirectory.description', { location: directoryLocation })}
|
|
56
58
|
</Text>
|
|
57
59
|
|
|
58
60
|
<form
|
|
@@ -64,7 +66,7 @@ export const CreateDirectory = () => {
|
|
|
64
66
|
<Input
|
|
65
67
|
id="path"
|
|
66
68
|
type="text"
|
|
67
|
-
placeholder=
|
|
69
|
+
placeholder={t('resources.createDirectory.namePlaceholder')}
|
|
68
70
|
value={directoryName}
|
|
69
71
|
onChange={setDirectoryName}
|
|
70
72
|
style={{ width: '100%', marginBottom: 'var(--space-l)' }}
|
|
@@ -78,14 +80,14 @@ export const CreateDirectory = () => {
|
|
|
78
80
|
<Button
|
|
79
81
|
id="cancel"
|
|
80
82
|
onClick={() => router.navigate('@back')}
|
|
81
|
-
>
|
|
83
|
+
>{t('design-system.cancel')}
|
|
82
84
|
</Button>
|
|
83
85
|
|
|
84
86
|
<Button
|
|
85
87
|
id="createDirectory"
|
|
86
88
|
variant="cta"
|
|
87
89
|
onClick={onCreateDirectory}
|
|
88
|
-
>
|
|
90
|
+
>{t('resources.createDirectory.submit')}
|
|
89
91
|
</Button>
|
|
90
92
|
|
|
91
93
|
</View>
|
|
@@ -95,4 +97,3 @@ export const CreateDirectory = () => {
|
|
|
95
97
|
)
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
|
package/src/CreateDocument.jsx
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { createDocument } from './resource.helpers.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
4
|
+
import { Alert, useLocale } from '@ossy/design-system'
|
|
4
5
|
import { useRouter } from '@ossy/router-react'
|
|
5
6
|
import { GenericResourceForm } from './GenericResourceForm.jsx'
|
|
6
7
|
|
|
7
8
|
export const CreateDocument = () => {
|
|
9
|
+
const { t } = useLocale()
|
|
8
10
|
const router = useRouter()
|
|
9
11
|
const templateId = router.searchParams.templateId
|
|
10
12
|
const location = router.searchParams.location
|
|
11
|
-
const
|
|
13
|
+
const sdk = useSdk()
|
|
12
14
|
const [error, setError] = useState()
|
|
13
15
|
|
|
14
16
|
const onCancel = () => {
|
|
@@ -17,9 +19,9 @@ export const CreateDocument = () => {
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const onSubmit = ({ name, content, type }) => {
|
|
20
|
-
createDocument({ type, location, name, content })
|
|
22
|
+
createDocument(sdk, { type, location, name, content })
|
|
21
23
|
.then(() => onCancel())
|
|
22
|
-
.catch((err) => setError(err?.message || '
|
|
24
|
+
.catch((err) => setError(err?.message || t('resources.form.createFailed')))
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
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
|
-
|
|
12
|
-
id: 'resources',
|
|
13
|
-
enabled: true
|
|
14
|
-
},
|
|
11
|
+
icon: 'image',
|
|
15
12
|
statuses: ['beta'],
|
|
16
|
-
|
|
17
|
-
views: ['home.page', 'resources.list', 'resources.get'],
|
|
18
|
-
tasks: []
|
|
19
|
-
}
|
|
13
|
+
}
|
package/src/DocumentEdit.jsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
4
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
5
|
import {
|
|
4
6
|
Text,
|
|
5
7
|
View,
|
|
@@ -11,11 +13,12 @@ export const DocumentEdit = ({
|
|
|
11
13
|
resourceId,
|
|
12
14
|
form,
|
|
13
15
|
}) => {
|
|
14
|
-
const
|
|
16
|
+
const sdk = useSdk()
|
|
17
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
18
|
+
const { data: workspace } = sdk.read(GetWorkspace)
|
|
19
|
+
const template = workspace?.resourceTemplates?.find(t => t.id === resource?.type)
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (template.fields && form.data) {
|
|
21
|
+
if (template?.fields && form.data) {
|
|
19
22
|
return (
|
|
20
23
|
<View style={{ padding: '16px 0' }}>
|
|
21
24
|
<Fields data={form.data} onChange={form.onChange} fields={template.fields} />
|
|
@@ -24,7 +27,7 @@ export const DocumentEdit = ({
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
// Loading
|
|
27
|
-
if (template
|
|
30
|
+
if (template?.fields && !form.data) {
|
|
28
31
|
return (
|
|
29
32
|
<DelayedRender>
|
|
30
33
|
<View style={{ padding: '16px 0' }}>
|
package/src/DocumentView.jsx
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { pipe, keys, map } from 'ramda'
|
|
3
|
-
import {
|
|
3
|
+
import { metadata as GetResource } from './get.action.js'
|
|
4
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
5
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
4
6
|
import { Text, View } from '@ossy/design-system'
|
|
5
7
|
|
|
6
8
|
export const DocumentView = ({
|
|
7
9
|
resourceId
|
|
8
10
|
}) => {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const sdk = useSdk()
|
|
12
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
13
|
+
const { data: workspace } = sdk.read(GetWorkspace)
|
|
14
|
+
const template = workspace?.resourceTemplates?.find(t => t.id === resource?.type)
|
|
11
15
|
|
|
12
16
|
return (
|
|
13
17
|
<View style={{ padding: '16px 0' }}>
|
|
14
18
|
<View gap="m">
|
|
15
19
|
{
|
|
16
|
-
!!resource?.content && (template
|
|
20
|
+
!!resource?.content && (template?.fields || [])
|
|
17
21
|
.map(field => ({ name: field.name, value: resource?.content?.[field.name] }))
|
|
18
22
|
.map(field => (
|
|
19
23
|
<View gap="s" key={field.name}>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import { Slot, resourceSlot, View, Title, Text, DelayedRender } from '@ossy/design-system'
|
|
4
5
|
|
|
5
6
|
function GenericResourceCardFallback ({ resource }) {
|
|
@@ -16,7 +17,8 @@ function GenericResourceCardFallback ({ resource }) {
|
|
|
16
17
|
|
|
17
18
|
/** Card-sized resource preview — `resource:{type}/card`. */
|
|
18
19
|
export function GenericResourceCard ({ resourceId, resource: resourceProp }) {
|
|
19
|
-
const
|
|
20
|
+
const sdk = useSdk()
|
|
21
|
+
const { data: loaded } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId && !resourceProp })
|
|
20
22
|
const resource = resourceProp ?? loaded
|
|
21
23
|
|
|
22
24
|
if (!resource) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
4
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
5
|
import {
|
|
4
6
|
Slot,
|
|
5
7
|
resourceSlot,
|
|
@@ -12,8 +14,10 @@ import {
|
|
|
12
14
|
import { ResourceGenericView } from './ResourceGenericView.jsx'
|
|
13
15
|
|
|
14
16
|
function GenericResourceDetailFallback ({ resourceId }) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
+
const sdk = useSdk()
|
|
18
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
19
|
+
const { data: workspace } = sdk.read(GetWorkspace)
|
|
20
|
+
const template = workspace?.resourceTemplates?.find(t => t.id === resource?.type)
|
|
17
21
|
|
|
18
22
|
if (!resource) {
|
|
19
23
|
return (
|
|
@@ -40,7 +44,8 @@ function GenericResourceDetailFallback ({ resourceId }) {
|
|
|
40
44
|
* registry; falls back to template fields or a minimal placeholder.
|
|
41
45
|
*/
|
|
42
46
|
export function GenericResourceDetail ({ resourceId }) {
|
|
43
|
-
const
|
|
47
|
+
const sdk = useSdk()
|
|
48
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
44
49
|
|
|
45
50
|
if (!resource) {
|
|
46
51
|
return (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import {
|
|
4
5
|
Slot,
|
|
5
6
|
resourceSlot,
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
Fields,
|
|
13
14
|
applyFieldChange,
|
|
14
15
|
useInputValue,
|
|
16
|
+
useLocale,
|
|
15
17
|
} from '@ossy/design-system'
|
|
16
18
|
|
|
17
19
|
function GenericResourceFormFallback ({
|
|
@@ -23,14 +25,17 @@ function GenericResourceFormFallback ({
|
|
|
23
25
|
onCancel,
|
|
24
26
|
submitLabel,
|
|
25
27
|
}) {
|
|
26
|
-
const
|
|
28
|
+
const { t } = useLocale()
|
|
29
|
+
const sdk = useSdk()
|
|
30
|
+
const { data: workspace } = sdk.read(GetWorkspace)
|
|
31
|
+
const template = workspace?.resourceTemplates?.find(t => t.id === templateId)
|
|
27
32
|
const [name, setName] = useInputValue(initialName)
|
|
28
33
|
const [content, setContent] = useState(initialContent)
|
|
29
34
|
const [error, setError] = useState()
|
|
30
35
|
|
|
31
36
|
const handleSubmit = () => {
|
|
32
37
|
if (!name?.trim()) {
|
|
33
|
-
setError('
|
|
38
|
+
setError(t('resources.form.nameRequired'))
|
|
34
39
|
return
|
|
35
40
|
}
|
|
36
41
|
setError(undefined)
|
|
@@ -42,7 +47,7 @@ function GenericResourceFormFallback ({
|
|
|
42
47
|
<InputTitle
|
|
43
48
|
id="resource-name"
|
|
44
49
|
type="text"
|
|
45
|
-
placeholder=
|
|
50
|
+
placeholder={t('resources.form.untitled')}
|
|
46
51
|
value={name}
|
|
47
52
|
onChange={setName}
|
|
48
53
|
/>
|
|
@@ -53,9 +58,9 @@ function GenericResourceFormFallback ({
|
|
|
53
58
|
/>
|
|
54
59
|
{error && <Alert>{error}</Alert>}
|
|
55
60
|
<View layout="row" gap="s" justifyContent="flex-end">
|
|
56
|
-
{onCancel && <Button variant="link" onClick={onCancel}>
|
|
61
|
+
{onCancel && <Button variant="link" onClick={onCancel}>{t('design-system.cancel')}</Button>}
|
|
57
62
|
<Button variant="cta" onClick={handleSubmit}>
|
|
58
|
-
{submitLabel || (mode === 'edit' ? '
|
|
63
|
+
{submitLabel || (mode === 'edit' ? t('design-system.save') : (template?.name ? `${t('design-system.add')} ${template.name}` : t('resources.form.createResource')))}
|
|
59
64
|
</Button>
|
|
60
65
|
</View>
|
|
61
66
|
</View>
|
|
@@ -77,8 +82,10 @@ export function GenericResourceForm ({
|
|
|
77
82
|
onCancel,
|
|
78
83
|
submitLabel,
|
|
79
84
|
}) {
|
|
85
|
+
const { t } = useLocale()
|
|
86
|
+
|
|
80
87
|
if (!templateId) {
|
|
81
|
-
return <Text>
|
|
88
|
+
return <Text>{t('resources.form.selectType')}</Text>
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
return (
|
package/src/ImageResource.jsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import {
|
|
4
5
|
Image
|
|
5
6
|
} from '@ossy/design-system'
|
|
@@ -7,7 +8,8 @@ import {
|
|
|
7
8
|
export const ImageResource = ({
|
|
8
9
|
resourceId
|
|
9
10
|
}) => {
|
|
10
|
-
const
|
|
11
|
+
const sdk = useSdk()
|
|
12
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
11
13
|
|
|
12
14
|
return (
|
|
13
15
|
<div style={{ display: 'flex', justifyContent: 'center', padding: 'var(--space-m) var(--space-s) var(--space-xl)' }}>
|
package/src/PDFResource.jsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import { View } from '@ossy/design-system'
|
|
4
5
|
|
|
5
6
|
export const PDFResource = ({
|
|
6
7
|
resourceId
|
|
7
8
|
}) => {
|
|
8
|
-
const
|
|
9
|
+
const sdk = useSdk()
|
|
10
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
9
11
|
|
|
10
12
|
return (
|
|
11
13
|
<View stack bordered>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { AsyncStatus, useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import { Switch, View, DelayedRender, Button, Icon, PageSection, Title, Text, Tags, ImageCard } from '@ossy/design-system'
|
|
4
5
|
import { useRouter } from '@ossy/router-react'
|
|
5
6
|
|
|
@@ -7,7 +8,8 @@ import { useRouter } from '@ossy/router-react'
|
|
|
7
8
|
export const ResourceContentPage = (props) => {
|
|
8
9
|
const router = useRouter()
|
|
9
10
|
const resourceId = router.params.resourceId
|
|
10
|
-
const
|
|
11
|
+
const sdk = useSdk()
|
|
12
|
+
const { status, data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
11
13
|
|
|
12
14
|
return (
|
|
13
15
|
<View {...props} slot="content" style={{ flexDirection: 'column', wrap: 'no-wrap', height: '100%' }}>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import { View, Text } from '@ossy/design-system'
|
|
4
5
|
|
|
5
6
|
export const ResourceDescription = ({ resourceId }) => {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
7
|
+
const sdk = useSdk()
|
|
8
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
8
9
|
|
|
9
10
|
const description = resource?.content?.description;
|
|
10
11
|
|
package/src/ResourceDetails.jsx
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { updateResourceAccess } from './resource.helpers.js'
|
|
4
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
5
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
6
|
import { Text, View } from '@ossy/design-system'
|
|
4
7
|
import { formatBytes } from './utils/format-bytes.js'
|
|
5
8
|
|
|
6
9
|
export const ResourceDetails = ({ resourceId }) => {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
10
|
+
const sdk = useSdk()
|
|
11
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
12
|
+
const { data: workspace } = sdk.read(GetWorkspace)
|
|
13
|
+
const template = workspace?.resourceTemplates?.find(t => t.id === resource?.type)
|
|
9
14
|
const [accessBusy, setAccessBusy] = useState(false)
|
|
10
15
|
const [accessError, setAccessError] = useState(null)
|
|
11
16
|
|
|
@@ -24,7 +29,7 @@ export const ResourceDetails = ({ resourceId }) => {
|
|
|
24
29
|
const next = event.target.checked ? 'public' : 'restricted'
|
|
25
30
|
setAccessError(null)
|
|
26
31
|
setAccessBusy(true)
|
|
27
|
-
|
|
32
|
+
updateResourceAccess(sdk, { id: resourceId, access: next })
|
|
28
33
|
.catch(() => setAccessError('Could not update access'))
|
|
29
34
|
.finally(() => setAccessBusy(false))
|
|
30
35
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { moveResource } from './resource.helpers.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import { Button, View, Title, Input, Text, useInputValue } from '@ossy/design-system'
|
|
4
5
|
|
|
5
6
|
export const ResourceDialogMove = ({
|
|
6
7
|
resourceId,
|
|
7
8
|
onClose = () => {},
|
|
8
9
|
}) => {
|
|
9
|
-
const
|
|
10
|
+
const sdk = useSdk()
|
|
10
11
|
const [location, setLocation] = useInputValue('')
|
|
11
12
|
|
|
12
13
|
const onMove = () => {
|
|
13
|
-
moveResource(resourceId, location)
|
|
14
|
+
moveResource(sdk, resourceId, location)
|
|
14
15
|
.then(() => {
|
|
15
16
|
onClose()
|
|
16
17
|
})
|
package/src/ResourceFactory.jsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { AsyncStatus, useSdk } from '@ossy/sdk-react'
|
|
4
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
3
5
|
import { Guide, Text, DelayedRender } from '@ossy/design-system'
|
|
4
6
|
import { DocumentEdit } from './DocumentEdit.jsx'
|
|
5
7
|
import { ImageResource } from './ImageResource.jsx'
|
|
@@ -15,8 +17,9 @@ export const ResourceFactory = ({
|
|
|
15
17
|
onClose: _onClose,
|
|
16
18
|
form
|
|
17
19
|
}) => {
|
|
18
|
-
const
|
|
19
|
-
const {
|
|
20
|
+
const sdk = useSdk()
|
|
21
|
+
const { data: workspace } = sdk.read(GetWorkspace)
|
|
22
|
+
const { data: resource, status } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
20
23
|
|
|
21
24
|
console.log('ResourceFactory', { resourceId, mode, resource, status })
|
|
22
25
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import {
|
|
4
5
|
View,
|
|
5
6
|
Icon,
|
|
@@ -8,7 +9,8 @@ import {
|
|
|
8
9
|
export const ResourceGenericView = ({
|
|
9
10
|
resourceId
|
|
10
11
|
}) => {
|
|
11
|
-
const
|
|
12
|
+
const sdk = useSdk()
|
|
13
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
12
14
|
|
|
13
15
|
return (
|
|
14
16
|
<View stack bordered>
|
package/src/ResourceList.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import React, { useRef, useEffect } from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
4
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
4
5
|
import {
|
|
5
6
|
Dropdown,
|
|
6
7
|
DropZone,
|
|
@@ -156,7 +157,8 @@ function ResourceListItem({
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
function ResourceIcon({ ...resource }) {
|
|
159
|
-
const
|
|
160
|
+
const sdk = useSdk()
|
|
161
|
+
const { data: workspace } = sdk.read(GetWorkspace)
|
|
160
162
|
|
|
161
163
|
const resourceTemplates = (workspace.resourceTemplates || [])
|
|
162
164
|
.reduce((acc, curr) => ({ ...acc, [curr.id]: curr }), {})
|
package/src/ResourcePanel.jsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { removeResource, updateResourceContent, renameResource } from './resource.helpers.js'
|
|
4
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
5
|
import {
|
|
4
6
|
Title,
|
|
5
7
|
Overlay,
|
|
@@ -43,18 +45,13 @@ export const ResourcePanel = ({
|
|
|
43
45
|
extraPanels = [],
|
|
44
46
|
}) => {
|
|
45
47
|
const router = useRouter()
|
|
46
|
-
const
|
|
48
|
+
const sdk = useSdk()
|
|
47
49
|
const [overlay, setOverlay] = useState(Overlays.None)
|
|
48
50
|
const [error] = useState()
|
|
49
51
|
const [resourceName, setResourceName] = useInputValue('')
|
|
50
52
|
const [panelViewModes, setPanelViewModes] = useState(DefaultViewModes)
|
|
51
53
|
|
|
52
|
-
const {
|
|
53
|
-
resource,
|
|
54
|
-
removeResource,
|
|
55
|
-
updateResourceContent,
|
|
56
|
-
renameResource
|
|
57
|
-
} = useResource(resourceId)
|
|
54
|
+
const { data: resource = {} } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
58
55
|
|
|
59
56
|
const form = useForm({ defaultData: resource.content })
|
|
60
57
|
|
|
@@ -67,18 +64,18 @@ export const ResourcePanel = ({
|
|
|
67
64
|
|
|
68
65
|
const onRenameResource = () => {
|
|
69
66
|
if (resourceName === resource.name) return
|
|
70
|
-
renameResource(resourceName)
|
|
67
|
+
renameResource(sdk, resourceId, resourceName)
|
|
71
68
|
.then(() => setPanelViewModes(x => ({ ...x, 'panel-header': ViewMode.View })))
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
const onUpdateResource = () => {
|
|
75
|
-
updateResourceContent(form.data)
|
|
72
|
+
updateResourceContent(sdk, resourceId, form.data)
|
|
76
73
|
.then(() => setPanelViewModes(x => ({ ...x, 'panel-resource-content': ViewMode.View })))
|
|
77
74
|
.catch(() => alert('Something went wrong!'))
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
const onRemoveResource = () => {
|
|
81
|
-
removeResource()
|
|
78
|
+
removeResource(sdk, resourceId, resource?.location)
|
|
82
79
|
.then(onCloseResource)
|
|
83
80
|
}
|
|
84
81
|
|
|
@@ -253,7 +250,7 @@ export const ResourcePanel = ({
|
|
|
253
250
|
actions={[
|
|
254
251
|
{ label: 'Cancel', variant: "command", onClick: () => setOverlay(Overlays.None) },
|
|
255
252
|
{ label: 'Remove', variant: 'command-danger', onClick: () => {
|
|
256
|
-
removeResource(resourceId)
|
|
253
|
+
removeResource(sdk, resourceId, resource?.location)
|
|
257
254
|
setOverlay(Overlays.None)
|
|
258
255
|
}}
|
|
259
256
|
]}
|
package/src/ResourceTags.jsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { metadata as GetResource } from './get.action.js'
|
|
3
|
+
import { useSdk } from '@ossy/sdk-react'
|
|
3
4
|
import { View, Tags, Text } from '@ossy/design-system'
|
|
4
5
|
|
|
5
6
|
export const ResourceTags = ({ resourceId }) => {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
7
|
+
const sdk = useSdk()
|
|
8
|
+
const { data: resource } = sdk.read(GetResource, { id: resourceId }, { enabled: !!resourceId })
|
|
8
9
|
|
|
9
10
|
let resourceContentTags = resource?.content?.Tags || []
|
|
10
11
|
|