@ossy/storage 3.0.4 → 3.0.6
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/ResourcesPage.jsx +104 -77
- package/src/en.translations.json +1 -1
- package/src/storage.page.jsx +17 -13
- package/src/sv.translations.json +1 -1
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": "3.0.
|
|
4
|
+
"version": "3.0.6",
|
|
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": "3e1c558069c7738dd751e429c69b10e52d247d8c"
|
|
34
34
|
}
|
package/src/ResourcesPage.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'
|
|
2
|
-
import { ListResources, createDirectory, moveResource, removeResource } from '@ossy/resources'
|
|
2
|
+
import { ListResources, createDirectory, moveResource, removeResource, uploadFile } from '@ossy/resources'
|
|
3
3
|
import { GetWorkspace } from '@ossy/workspaces'
|
|
4
4
|
import { AsyncStatus, useSdk } from '@ossy/sdk-react'
|
|
5
5
|
import {
|
|
@@ -124,6 +124,13 @@ export const ResourcesPage = () => {
|
|
|
124
124
|
moveResource(sdk, resourceId, newLocation, activePath)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
const onUploadFiles = useCallback((location) => (files) => {
|
|
128
|
+
if (!files?.length) return
|
|
129
|
+
Promise.all(files.map((file) => uploadFile(sdk, location, file))).catch((error) => {
|
|
130
|
+
console.error('[storage] upload failed', error)
|
|
131
|
+
})
|
|
132
|
+
}, [sdk])
|
|
133
|
+
|
|
127
134
|
const onRemoveResource = resource => {
|
|
128
135
|
setSelectedResourceId(resource.id)
|
|
129
136
|
|
|
@@ -146,7 +153,11 @@ export const ResourcesPage = () => {
|
|
|
146
153
|
const isLast = i === (paths.length - 1)
|
|
147
154
|
if (isLast) return <Path key={path} path={path} onClick={goTo(path)} />
|
|
148
155
|
return (
|
|
149
|
-
<DropZone
|
|
156
|
+
<DropZone
|
|
157
|
+
key={path}
|
|
158
|
+
onDrop={onMoveResource(`${path}/`)}
|
|
159
|
+
onFilesDrop={onUploadFiles(`${path}/`)}
|
|
160
|
+
>
|
|
150
161
|
<Path path={path} onClick={openLocation(`${path}/`)} href={storageHomeHref(`location=${path}`)} />
|
|
151
162
|
</DropZone>
|
|
152
163
|
)
|
|
@@ -160,11 +171,13 @@ export const ResourcesPage = () => {
|
|
|
160
171
|
|
|
161
172
|
if (resource.type === '@ossy/platform/schema/directory' || resource.type === 'directory') {
|
|
162
173
|
const folderLocation = `${activePath}${resource.name}`
|
|
174
|
+
const dropLocation = `${resource.location}${resource.name}/`
|
|
163
175
|
return {
|
|
164
176
|
...resource,
|
|
165
177
|
href: storageHomeHref(`location=${folderLocation}`),
|
|
166
178
|
onClick: openLocation(folderLocation),
|
|
167
|
-
onDrop: onMoveResource(
|
|
179
|
+
onDrop: onMoveResource(dropLocation),
|
|
180
|
+
onFilesDrop: onUploadFiles(dropLocation),
|
|
168
181
|
actions: [
|
|
169
182
|
<ContextMenu.Item
|
|
170
183
|
prefix="mail-forward"
|
|
@@ -236,7 +249,7 @@ export const ResourcesPage = () => {
|
|
|
236
249
|
const bDir = b.type === '@ossy/platform/schema/directory' || b.type === 'directory'
|
|
237
250
|
if (aDir && !bDir) return -1
|
|
238
251
|
if (!aDir && bDir) return 1
|
|
239
|
-
}), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onRemoveResource, setSelectedResourceId, t])
|
|
252
|
+
}), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onUploadFiles, onRemoveResource, setSelectedResourceId, t])
|
|
240
253
|
|
|
241
254
|
return (
|
|
242
255
|
<>
|
|
@@ -255,16 +268,23 @@ export const ResourcesPage = () => {
|
|
|
255
268
|
</style>
|
|
256
269
|
|
|
257
270
|
<Page
|
|
271
|
+
scroll
|
|
258
272
|
title="storage.resources.title"
|
|
259
273
|
description="storage.resources.description"
|
|
260
274
|
near={<Tags tags={[t('storage.resources.beta')]} size="s" />}
|
|
261
275
|
style={{ minHeight: 0 }}
|
|
276
|
+
contentStyle={{
|
|
277
|
+
overflow: 'hidden',
|
|
278
|
+
display: 'flex',
|
|
279
|
+
flexDirection: 'column',
|
|
280
|
+
minHeight: 0,
|
|
281
|
+
}}
|
|
262
282
|
>
|
|
263
283
|
|
|
264
|
-
<View stack horizontal gap="xs" style={{
|
|
284
|
+
<View stack horizontal gap="xs" style={{ height: '100%', minHeight: 0, flex: '1 1 auto' }}>
|
|
265
285
|
|
|
266
|
-
<View.Item fill surface="primary" roundness="xs" >
|
|
267
|
-
<View stack bordered style={{ height: '100%' }}>
|
|
286
|
+
<View.Item fill surface="primary" roundness="xs" style={{ minHeight: 0, minWidth: 0 }}>
|
|
287
|
+
<View stack bordered style={{ height: '100%', minHeight: 0 }}>
|
|
268
288
|
|
|
269
289
|
<View.Item
|
|
270
290
|
data-surface="primary"
|
|
@@ -280,7 +300,10 @@ export const ResourcesPage = () => {
|
|
|
280
300
|
>
|
|
281
301
|
|
|
282
302
|
<Breadcrumbs>
|
|
283
|
-
<DropZone
|
|
303
|
+
<DropZone
|
|
304
|
+
onDrop={activePath === '/' ? undefined : onMoveResource('/')}
|
|
305
|
+
onFilesDrop={onUploadFiles('/')}
|
|
306
|
+
>
|
|
284
307
|
<Button prefix="home-alt" variant="command" onClick={openLocation('/')} href={storageHomeHref()} />
|
|
285
308
|
</DropZone>
|
|
286
309
|
|
|
@@ -311,75 +334,79 @@ export const ResourcesPage = () => {
|
|
|
311
334
|
|
|
312
335
|
</View.Item>
|
|
313
336
|
|
|
314
|
-
<View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto'
|
|
315
|
-
<
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
<
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
{[
|
|
331
|
-
<
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
className="
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
337
|
+
<View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto', minHeight: 0 }}>
|
|
338
|
+
<DropZone onFilesDrop={onUploadFiles(activePath)}>
|
|
339
|
+
<View style={{ minHeight: '100%' }}>
|
|
340
|
+
<Switch on={resourcesListStatus}>
|
|
341
|
+
|
|
342
|
+
<Switch.Case match={[ResourcesListStatus.Error]}>
|
|
343
|
+
<View layout="off-center" style={{ height: '100%' }}>
|
|
344
|
+
<Guide
|
|
345
|
+
data-region="content"
|
|
346
|
+
title={t('storage.resources.errorTitle')}
|
|
347
|
+
text={t('storage.resources.errorText')}
|
|
348
|
+
style={{ width: '100vw', maxWidth: '350px' }}
|
|
349
|
+
/>
|
|
350
|
+
</View>
|
|
351
|
+
</Switch.Case>
|
|
352
|
+
|
|
353
|
+
<Switch.Case match={[ResourcesListStatus.Loading]}>
|
|
354
|
+
<DelayedRender>
|
|
355
|
+
{[1, 2, 3].map(n => (
|
|
356
|
+
<View.Item key={n}>
|
|
357
|
+
<div
|
|
358
|
+
className="inset-m cursor-pointer sans-serif d-flex align-center justify-between"
|
|
359
|
+
style={{ height: '56px', }}
|
|
360
|
+
>
|
|
361
|
+
<div className="d-flex align-center">
|
|
362
|
+
<span
|
|
363
|
+
className="inline-m"
|
|
364
|
+
style={{
|
|
365
|
+
width: '24px',
|
|
366
|
+
height: '24px',
|
|
367
|
+
flexShrink: 0,
|
|
368
|
+
background: 'hsl(0, 0%, 50%)',
|
|
369
|
+
borderRadius: '16px'
|
|
370
|
+
}}
|
|
371
|
+
/>
|
|
372
|
+
<span
|
|
373
|
+
style={{
|
|
374
|
+
width: '300px',
|
|
375
|
+
height: '18px',
|
|
376
|
+
background: 'hsl(0, 0%, 50%)',
|
|
377
|
+
borderRadius: '16px'
|
|
378
|
+
}}
|
|
379
|
+
/>
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
382
|
+
</View.Item>
|
|
383
|
+
))}
|
|
384
|
+
</DelayedRender>
|
|
385
|
+
</Switch.Case>
|
|
386
|
+
|
|
387
|
+
<Switch.Case match={[ResourcesListStatus.Empty]}>
|
|
388
|
+
{isCreatingFolder
|
|
389
|
+
? <ResourceList resources={[]} inlineFolder={inlineFolder} />
|
|
390
|
+
: (
|
|
391
|
+
<Guide
|
|
392
|
+
data-region="content"
|
|
393
|
+
title={t('storage.resources.emptyTitle')}
|
|
394
|
+
titleVariant="heading-tertiary"
|
|
395
|
+
text={t('storage.resources.emptyText')}
|
|
396
|
+
align="left"
|
|
397
|
+
style={{ maxWidth: '350px', padding: 'var(--space-m)' }}
|
|
398
|
+
/>
|
|
399
|
+
)
|
|
400
|
+
}
|
|
401
|
+
</Switch.Case>
|
|
402
|
+
|
|
403
|
+
<Switch.Case match={[ResourcesListStatus.Success]}>
|
|
404
|
+
<ResourceList resources={filterResources} inlineFolder={inlineFolder} />
|
|
405
|
+
</Switch.Case>
|
|
406
|
+
|
|
407
|
+
</Switch>
|
|
408
|
+
</View>
|
|
409
|
+
</DropZone>
|
|
383
410
|
</View.Item>
|
|
384
411
|
|
|
385
412
|
</View>
|
package/src/en.translations.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"storage.resources.errorTitle": "Something went wrong",
|
|
13
13
|
"storage.resources.errorText": "We could not fetch the data to display",
|
|
14
14
|
"storage.resources.emptyTitle": "Empty folder",
|
|
15
|
-
"storage.resources.emptyText": "Create a folder
|
|
15
|
+
"storage.resources.emptyText": "Create a folder, upload a file, or drop files here to get started.",
|
|
16
16
|
"storage.resources.removeDirectoryTitle": "Remove directory",
|
|
17
17
|
"storage.resources.removeDirectoryText": "Are you sure you want to remove this directory and everything in it?",
|
|
18
18
|
"storage.resources.cancel": "Cancel",
|
package/src/storage.page.jsx
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { useLocale } from '@ossy/design-system'
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
3
2
|
import { ResourcesPage } from './ResourcesPage.jsx'
|
|
4
3
|
import { useApp } from '@ossy/app/shell'
|
|
5
|
-
import {
|
|
6
|
-
import SalesSection from './SalesSection.jsx'
|
|
4
|
+
import { useRouter } from '@ossy/router-react'
|
|
7
5
|
|
|
8
6
|
export const metadata = {
|
|
9
7
|
id: 'storage/home',
|
|
@@ -11,19 +9,25 @@ export const metadata = {
|
|
|
11
9
|
sv: '/storage',
|
|
12
10
|
en: '/storage',
|
|
13
11
|
},
|
|
12
|
+
layout: '@ossy/app/layout/workspace',
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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} />
|
|
15
|
+
const PACKAGE_DETAIL = {
|
|
16
|
+
id: 'packages/detail',
|
|
17
|
+
params: { packageSlug: 'storage' },
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
export default function StorageHomePage () {
|
|
27
21
|
const app = useApp()
|
|
28
|
-
|
|
22
|
+
const router = useRouter()
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (app && !app.isAuthenticated) {
|
|
26
|
+
router.navigate(PACKAGE_DETAIL)
|
|
27
|
+
}
|
|
28
|
+
}, [app, router])
|
|
29
|
+
|
|
30
|
+
if (!app?.isAuthenticated) return null
|
|
31
|
+
|
|
32
|
+
return <ResourcesPage />
|
|
29
33
|
}
|
package/src/sv.translations.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"storage.resources.errorTitle": "Något gick fel",
|
|
13
13
|
"storage.resources.errorText": "Vi kunde inte hämta data att visa",
|
|
14
14
|
"storage.resources.emptyTitle": "Tom mapp",
|
|
15
|
-
"storage.resources.emptyText": "Skapa en mapp
|
|
15
|
+
"storage.resources.emptyText": "Skapa en mapp, ladda upp en fil eller släpp filer här för att komma igång.",
|
|
16
16
|
"storage.resources.removeDirectoryTitle": "Ta bort mapp",
|
|
17
17
|
"storage.resources.removeDirectoryText": "Är du säker på att du vill ta bort den här mappen och allt innehåll?",
|
|
18
18
|
"storage.resources.cancel": "Avbryt",
|