@ossy/storage 1.9.7 → 1.10.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 +2 -2
- package/src/Definition.js +1 -7
- package/src/ResourcesPage.jsx +30 -28
- package/src/en.translations.json +20 -0
- package/src/features.js +7 -6
- package/src/storage.page.jsx +14 -4
- package/src/sv.translations.json +20 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/storage",
|
|
3
3
|
"description": "Analytics module — workspace analytics for website traffic",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"ramda": "*",
|
|
31
31
|
"react": "*"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "c0ba5d90749690634e4dc2705178ff8d89dd3070"
|
|
34
34
|
}
|
package/src/Definition.js
CHANGED
|
@@ -2,12 +2,6 @@ export const Definition = {
|
|
|
2
2
|
id: 'storage',
|
|
3
3
|
title: 'Storage',
|
|
4
4
|
description: 'Storage views and resource browsing inside workspaces.',
|
|
5
|
-
|
|
6
|
-
id: 'storage',
|
|
7
|
-
enabled: true
|
|
8
|
-
},
|
|
5
|
+
icon: 'software-upload',
|
|
9
6
|
statuses: ['beta'],
|
|
10
|
-
actions: ['resources.create-directory', 'resources.move', 'resources.rename', 'resources.remove'],
|
|
11
|
-
views: ['home.page', 'resources.list', 'resources.search', 'resources.get'],
|
|
12
|
-
tasks: ['resources.upload-named-version']
|
|
13
7
|
}
|
package/src/ResourcesPage.jsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { ListResources, createDirectory, moveResource, removeResource } from '@ossy/resources'
|
|
3
|
+
import { GetWorkspace } from '@ossy/workspaces'
|
|
4
|
+
import { AsyncStatus, useSdk } from '@ossy/sdk-react'
|
|
3
5
|
import {
|
|
4
6
|
pipe,
|
|
5
7
|
split,
|
|
@@ -22,6 +24,7 @@ import {
|
|
|
22
24
|
Title,
|
|
23
25
|
Tags,
|
|
24
26
|
EmptyState,
|
|
27
|
+
useLocale,
|
|
25
28
|
} from '@ossy/design-system'
|
|
26
29
|
import { useActivePath, ResourcePanel, ResourceList, ResourceDialogMove } from '@ossy/resources'
|
|
27
30
|
import { useRouter } from '@ossy/router-react'
|
|
@@ -48,7 +51,9 @@ const Overlays = {
|
|
|
48
51
|
|
|
49
52
|
export const ResourcesPage = () => {
|
|
50
53
|
const router = useRouter()
|
|
51
|
-
const {
|
|
54
|
+
const { t } = useLocale()
|
|
55
|
+
const sdk = useSdk()
|
|
56
|
+
const { data: workspace = {} } = sdk.read(GetWorkspace)
|
|
52
57
|
const [overlay, setOverlay] = useState(Overlays.None)
|
|
53
58
|
const [selectedResourceId, setSelectedResourceId] = useState()
|
|
54
59
|
const [resourcesListStatus, setResourcesListStatus] = useState(ResourcesListStatus.Loading)
|
|
@@ -56,14 +61,11 @@ export const ResourcesPage = () => {
|
|
|
56
61
|
|
|
57
62
|
const {
|
|
58
63
|
status: resourcesStatus,
|
|
59
|
-
resources,
|
|
60
|
-
|
|
61
|
-
moveResource,
|
|
62
|
-
createDirectory,
|
|
63
|
-
} = useResources(activePath)
|
|
64
|
+
data: resources = [],
|
|
65
|
+
} = sdk.read(ListResources, { location: activePath })
|
|
64
66
|
|
|
65
67
|
const [isCreatingFolder, setIsCreatingFolder] = useState(false)
|
|
66
|
-
const [newFolderName, setNewFolderName] = useState(
|
|
68
|
+
const [newFolderName, setNewFolderName] = useState(() => t('storage.resources.newFolderDefault'))
|
|
67
69
|
|
|
68
70
|
const onCreateFolderSave = (name) => {
|
|
69
71
|
const folderName = (name || '').trim()
|
|
@@ -71,10 +73,10 @@ export const ResourcesPage = () => {
|
|
|
71
73
|
onCreateFolderCancel()
|
|
72
74
|
return
|
|
73
75
|
}
|
|
74
|
-
createDirectory({ name: folderName, location: activePath })
|
|
76
|
+
createDirectory(sdk, { name: folderName, location: activePath })
|
|
75
77
|
.finally(() => {
|
|
76
78
|
setIsCreatingFolder(false)
|
|
77
|
-
setNewFolderName('
|
|
79
|
+
setNewFolderName(t('storage.resources.newFolderDefault'))
|
|
78
80
|
})
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -94,7 +96,7 @@ export const ResourcesPage = () => {
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
const onMoveResource = newLocation => resourceId => {
|
|
97
|
-
moveResource(resourceId, newLocation)
|
|
99
|
+
moveResource(sdk, resourceId, newLocation, activePath)
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
const onRemoveResource = resource => {
|
|
@@ -103,7 +105,7 @@ export const ResourcesPage = () => {
|
|
|
103
105
|
if (resource.type === 'directory') {
|
|
104
106
|
setOverlay(Overlays.RemoveDirectory)
|
|
105
107
|
} else {
|
|
106
|
-
removeResource(resource.id)
|
|
108
|
+
removeResource(sdk, resource.id, resource.location)
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
}
|
|
@@ -168,7 +170,7 @@ export const ResourcesPage = () => {
|
|
|
168
170
|
event.stopPropagation()
|
|
169
171
|
onRemoveResource(resource)
|
|
170
172
|
}}
|
|
171
|
-
>
|
|
173
|
+
>{t('storage.resources.contextRemove')}
|
|
172
174
|
</ContextMenu.Item>
|
|
173
175
|
]
|
|
174
176
|
}
|
|
@@ -199,7 +201,7 @@ export const ResourcesPage = () => {
|
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
>
|
|
202
|
-
|
|
204
|
+
{t('storage.resources.move')}
|
|
203
205
|
</ContextMenu.Item>,
|
|
204
206
|
<ContextMenu.Separator key="separator"></ContextMenu.Separator>,
|
|
205
207
|
<ContextMenu.Item
|
|
@@ -240,9 +242,9 @@ export const ResourcesPage = () => {
|
|
|
240
242
|
|
|
241
243
|
<View layout="row" inset="m" justifyContent="space-between" alignItems="center" surface="primary" roundness="s" style={{ flexShrink: 0 }}>
|
|
242
244
|
<View layout='row' gap="s" alignItems="center">
|
|
243
|
-
<Title>
|
|
245
|
+
<Title>{t('storage.resources.title')}</Title>
|
|
244
246
|
|
|
245
|
-
<Tags size="s" tags={['
|
|
247
|
+
<Tags size="s" tags={[t('storage.resources.beta')]} />
|
|
246
248
|
</View>
|
|
247
249
|
</View>
|
|
248
250
|
|
|
@@ -278,23 +280,23 @@ export const ResourcesPage = () => {
|
|
|
278
280
|
{ activePath !== '/' && getActivePath() }
|
|
279
281
|
</Breadcrumbs>
|
|
280
282
|
|
|
281
|
-
<Dropdown trigger={<Button prefix="add" variant="command" style={{ height: '32px' }}>
|
|
283
|
+
<Dropdown trigger={<Button prefix="add" variant="command" style={{ height: '32px' }}>{t('storage.resources.add')}</Button>}>
|
|
282
284
|
<View inset="xs" surface="primary" roundness="s">
|
|
283
285
|
<ContextMenu roundness="s" surface="primary">
|
|
284
286
|
<ContextMenu.Item
|
|
285
287
|
prefix="folder-add"
|
|
286
288
|
onClick={() => {
|
|
287
289
|
setIsCreatingFolder(true)
|
|
288
|
-
setNewFolderName('
|
|
290
|
+
setNewFolderName(t('storage.resources.newFolderDefault'))
|
|
289
291
|
}}
|
|
290
292
|
>
|
|
291
|
-
|
|
293
|
+
{t('storage.resources.createFolder')}
|
|
292
294
|
</ContextMenu.Item>
|
|
293
295
|
<ContextMenu.Item
|
|
294
296
|
prefix="software-upload"
|
|
295
297
|
href={router.getHref(`@upload-media?location=${activePath}`)}
|
|
296
298
|
>
|
|
297
|
-
|
|
299
|
+
{t('storage.resources.uploadFile')}
|
|
298
300
|
</ContextMenu.Item>
|
|
299
301
|
</ContextMenu>
|
|
300
302
|
</View>
|
|
@@ -309,8 +311,8 @@ export const ResourcesPage = () => {
|
|
|
309
311
|
<View layout="off-center" style={{ height: '100%' }}>
|
|
310
312
|
<Guide
|
|
311
313
|
slot="content"
|
|
312
|
-
title=
|
|
313
|
-
text=
|
|
314
|
+
title={t('storage.resources.errorTitle')}
|
|
315
|
+
text={t('storage.resources.errorText')}
|
|
314
316
|
style={{ width: '100vw', maxWidth: '350px' }}
|
|
315
317
|
/>
|
|
316
318
|
</View>
|
|
@@ -352,7 +354,7 @@ export const ResourcesPage = () => {
|
|
|
352
354
|
<Switch.Case match={[ResourcesListStatus.Empty]}>
|
|
353
355
|
{isCreatingFolder
|
|
354
356
|
? <ResourceList resources={[]} inlineFolder={inlineFolder} />
|
|
355
|
-
: <EmptyState message=
|
|
357
|
+
: <EmptyState message={t('storage.resources.emptyDirectory')} />
|
|
356
358
|
}
|
|
357
359
|
</Switch.Case>
|
|
358
360
|
|
|
@@ -379,12 +381,12 @@ export const ResourcesPage = () => {
|
|
|
379
381
|
<View surface="primary" roundness="s">
|
|
380
382
|
<View surface="primary" inset="l" roundness="s">
|
|
381
383
|
<Guide
|
|
382
|
-
title=
|
|
383
|
-
text=
|
|
384
|
+
title={t('storage.resources.removeDirectoryTitle')}
|
|
385
|
+
text={t('storage.resources.removeDirectoryText')}
|
|
384
386
|
actions={[
|
|
385
|
-
{ label: '
|
|
386
|
-
{ label: '
|
|
387
|
-
removeResource(selectedResourceId)
|
|
387
|
+
{ label: t('storage.resources.cancel'), variant: "command", onClick: () => setOverlay(Overlays.None) },
|
|
388
|
+
{ label: t('storage.resources.remove'), variant: 'command-danger', onClick: () => {
|
|
389
|
+
removeResource(sdk, selectedResourceId, activePath)
|
|
388
390
|
setOverlay(Overlays.None)
|
|
389
391
|
}}
|
|
390
392
|
]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"storage/home.documentTitle": "Storage – Ossy",
|
|
3
|
+
"storage.home.cover.title": "Storage",
|
|
4
|
+
"storage.home.cover.text": "Managing content should be easy",
|
|
5
|
+
"storage.resources.title": "Storage",
|
|
6
|
+
"storage.resources.beta": "Beta",
|
|
7
|
+
"storage.resources.add": "Add",
|
|
8
|
+
"storage.resources.createFolder": "Create folder",
|
|
9
|
+
"storage.resources.uploadFile": "Upload file",
|
|
10
|
+
"storage.resources.newFolderDefault": "New folder",
|
|
11
|
+
"storage.resources.errorTitle": "Something went wrong",
|
|
12
|
+
"storage.resources.errorText": "We could not fetch the data to display",
|
|
13
|
+
"storage.resources.emptyDirectory": "Empty directory",
|
|
14
|
+
"storage.resources.removeDirectoryTitle": "Remove directory",
|
|
15
|
+
"storage.resources.removeDirectoryText": "Are you sure you want to remove this directory and everything in it?",
|
|
16
|
+
"storage.resources.cancel": "Cancel",
|
|
17
|
+
"storage.resources.remove": "Remove",
|
|
18
|
+
"storage.resources.move": "Move",
|
|
19
|
+
"storage.resources.contextRemove": "Remove"
|
|
20
|
+
}
|
package/src/features.js
CHANGED
|
@@ -11,22 +11,23 @@ export const features = [
|
|
|
11
11
|
"icon": "user-list"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
"title": "React
|
|
15
|
-
"text": "Load content with
|
|
14
|
+
"title": "React SDK",
|
|
15
|
+
"text": "Load content with useSdk().read() by passing a folder path.",
|
|
16
16
|
"icon": "code-slash",
|
|
17
17
|
"content": `
|
|
18
18
|
\`\`\`
|
|
19
|
-
|
|
20
|
-
import {
|
|
19
|
+
import { WorkspaceProvider, useSdk } from '@ossy/sdk-react'
|
|
20
|
+
import { ListResources } from '@ossy/resources'
|
|
21
21
|
|
|
22
22
|
export const App = () => (
|
|
23
|
-
<WorkspaceProvider
|
|
23
|
+
<WorkspaceProvider sdk={sdk}>
|
|
24
24
|
<MyComponent />
|
|
25
25
|
</WorkspaceProvider>
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
const MyComponent = () => {
|
|
29
|
-
const
|
|
29
|
+
const sdk = useSdk()
|
|
30
|
+
const { status, data: resources } = sdk.read(ListResources, { location: '/folder/path/in/cms' })
|
|
30
31
|
|
|
31
32
|
return status !== 'Success'
|
|
32
33
|
? <>Loading...</>
|
package/src/storage.page.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { useLocale } from '@ossy/design-system'
|
|
2
3
|
import { ResourcesPage } from './ResourcesPage.jsx'
|
|
3
4
|
import { useApp } from '@ossy/app/shell'
|
|
4
|
-
import { cover } from './cover.js'
|
|
5
5
|
import { features } from './features.js'
|
|
6
6
|
import SalesSection from './SalesSection.jsx'
|
|
7
7
|
|
|
@@ -13,7 +13,17 @@ export const metadata = {
|
|
|
13
13
|
},
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
function StorageSalesSection () {
|
|
17
|
+
const { t } = useLocale()
|
|
18
|
+
const cover = {
|
|
19
|
+
title: t('storage.home.cover.title'),
|
|
20
|
+
titleVariant: 'primary',
|
|
21
|
+
text: t('storage.home.cover.text'),
|
|
22
|
+
}
|
|
23
|
+
return <SalesSection cover={cover} features={features} />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function StorageHomePage () {
|
|
27
|
+
const app = useApp()
|
|
28
|
+
return app?.isAuthenticated ? <ResourcesPage /> : <StorageSalesSection />
|
|
19
29
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"storage/home.documentTitle": "Storage",
|
|
3
|
+
"storage.home.cover.title": "Storage",
|
|
4
|
+
"storage.home.cover.text": "Det ska vara enkelt att hantera innehåll",
|
|
5
|
+
"storage.resources.title": "Storage",
|
|
6
|
+
"storage.resources.beta": "Beta",
|
|
7
|
+
"storage.resources.add": "Lägg till",
|
|
8
|
+
"storage.resources.createFolder": "Skapa mapp",
|
|
9
|
+
"storage.resources.uploadFile": "Ladda upp fil",
|
|
10
|
+
"storage.resources.newFolderDefault": "Ny mapp",
|
|
11
|
+
"storage.resources.errorTitle": "Något gick fel",
|
|
12
|
+
"storage.resources.errorText": "Vi kunde inte hämta data att visa",
|
|
13
|
+
"storage.resources.emptyDirectory": "Tom katalog",
|
|
14
|
+
"storage.resources.removeDirectoryTitle": "Ta bort mapp",
|
|
15
|
+
"storage.resources.removeDirectoryText": "Är du säker på att du vill ta bort den här mappen och allt innehåll?",
|
|
16
|
+
"storage.resources.cancel": "Avbryt",
|
|
17
|
+
"storage.resources.remove": "Ta bort",
|
|
18
|
+
"storage.resources.move": "Flytta",
|
|
19
|
+
"storage.resources.contextRemove": "Ta bort"
|
|
20
|
+
}
|