@ossy/storage 1.10.0 → 1.10.2

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/storage",
3
3
  "description": "Analytics module — workspace analytics for website traffic",
4
- "version": "1.10.0",
4
+ "version": "1.10.2",
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": "d9d31182be64a448d575da432af2830d909ad4b9"
33
+ "gitHead": "2b8745d57fee8b6c08787e2755b4df489291a5cd"
34
34
  }
@@ -1,5 +1,7 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import { useResources, useWorkspace, AsyncStatus } from '@ossy/sdk-react'
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,
@@ -50,7 +52,8 @@ const Overlays = {
50
52
  export const ResourcesPage = () => {
51
53
  const router = useRouter()
52
54
  const { t } = useLocale()
53
- const { workspace } = useWorkspace()
55
+ const sdk = useSdk()
56
+ const { data: workspace = {} } = sdk.read(GetWorkspace)
54
57
  const [overlay, setOverlay] = useState(Overlays.None)
55
58
  const [selectedResourceId, setSelectedResourceId] = useState()
56
59
  const [resourcesListStatus, setResourcesListStatus] = useState(ResourcesListStatus.Loading)
@@ -58,11 +61,8 @@ export const ResourcesPage = () => {
58
61
 
59
62
  const {
60
63
  status: resourcesStatus,
61
- resources,
62
- removeResource,
63
- moveResource,
64
- createDirectory,
65
- } = useResources(activePath)
64
+ data: resources = [],
65
+ } = sdk.read(ListResources, { location: activePath })
66
66
 
67
67
  const [isCreatingFolder, setIsCreatingFolder] = useState(false)
68
68
  const [newFolderName, setNewFolderName] = useState(() => t('storage.resources.newFolderDefault'))
@@ -73,7 +73,7 @@ export const ResourcesPage = () => {
73
73
  onCreateFolderCancel()
74
74
  return
75
75
  }
76
- createDirectory({ name: folderName, location: activePath })
76
+ createDirectory(sdk, { name: folderName, location: activePath })
77
77
  .finally(() => {
78
78
  setIsCreatingFolder(false)
79
79
  setNewFolderName(t('storage.resources.newFolderDefault'))
@@ -96,7 +96,7 @@ export const ResourcesPage = () => {
96
96
  }
97
97
 
98
98
  const onMoveResource = newLocation => resourceId => {
99
- moveResource(resourceId, newLocation)
99
+ moveResource(sdk, resourceId, newLocation, activePath)
100
100
  }
101
101
 
102
102
  const onRemoveResource = resource => {
@@ -105,7 +105,7 @@ export const ResourcesPage = () => {
105
105
  if (resource.type === 'directory') {
106
106
  setOverlay(Overlays.RemoveDirectory)
107
107
  } else {
108
- removeResource(resource.id)
108
+ removeResource(sdk, resource.id, resource.location)
109
109
  }
110
110
 
111
111
  }
@@ -386,7 +386,7 @@ export const ResourcesPage = () => {
386
386
  actions={[
387
387
  { label: t('storage.resources.cancel'), variant: "command", onClick: () => setOverlay(Overlays.None) },
388
388
  { label: t('storage.resources.remove'), variant: 'command-danger', onClick: () => {
389
- removeResource(selectedResourceId)
389
+ removeResource(sdk, selectedResourceId, activePath)
390
390
  setOverlay(Overlays.None)
391
391
  }}
392
392
  ]}
@@ -1,5 +1,5 @@
1
1
  {
2
- "storage.home.documentTitle": "Storage – Ossy",
2
+ "storage/home.documentTitle": "Storage – Ossy",
3
3
  "storage.home.cover.title": "Storage",
4
4
  "storage.home.cover.text": "Managing content should be easy",
5
5
  "storage.resources.title": "Storage",
package/src/features.js CHANGED
@@ -11,22 +11,23 @@ export const features = [
11
11
  "icon": "user-list"
12
12
  },
13
13
  {
14
- "title": "React hooks",
15
- "text": "Load content with useResources by passing a folder path.",
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
- // Layout / SiteDocumentHead
20
- import { WorkspaceProvider, useResources } from '@ossy/sdk-react'
19
+ import { WorkspaceProvider, useSdk } from '@ossy/sdk-react'
20
+ import { ListResources } from '@ossy/resources'
21
21
 
22
22
  export const App = () => (
23
- <WorkspaceProvider workspaceId="your-workspace-id">
23
+ <WorkspaceProvider sdk={sdk}>
24
24
  <MyComponent />
25
25
  </WorkspaceProvider>
26
26
  )
27
27
 
28
28
  const MyComponent = () => {
29
- const { status, resources } = useResources('/folder/path/in/cms')
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...</>
@@ -1,5 +1,5 @@
1
1
  {
2
- "storage.home.documentTitle": "Storage",
2
+ "storage/home.documentTitle": "Storage",
3
3
  "storage.home.cover.title": "Storage",
4
4
  "storage.home.cover.text": "Det ska vara enkelt att hantera innehåll",
5
5
  "storage.resources.title": "Storage",