@ossy/storage 3.4.0 → 3.8.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 +2 -2
- package/src/ResourcesPage.jsx +300 -16
- package/src/en.translations.json +13 -0
- package/src/local-storage.api.js +8 -3
- package/src/sv.translations.json +13 -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": "3.
|
|
4
|
+
"version": "3.8.0",
|
|
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": "14548dfc2019e7258e8c75db527acbf66fe829bd"
|
|
34
34
|
}
|
package/src/ResourcesPage.jsx
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ListResources,
|
|
4
|
+
applyResourceSelectionGesture,
|
|
5
|
+
createDirectory,
|
|
6
|
+
filterDownloadableResources,
|
|
7
|
+
isDownloadableResource,
|
|
8
|
+
isMultiSelectGesture,
|
|
9
|
+
moveResource,
|
|
10
|
+
removeResource,
|
|
11
|
+
resourceDownloadHref,
|
|
12
|
+
triggerResourceDownloads,
|
|
13
|
+
uploadFile,
|
|
14
|
+
} from '@ossy/resources'
|
|
3
15
|
import { GetWorkspace } from '@ossy/workspaces'
|
|
4
16
|
import { AsyncStatus, useSdk } from '@ossy/sdk-react'
|
|
5
17
|
import {
|
|
@@ -30,6 +42,7 @@ const ResourcesListStatus = {
|
|
|
30
42
|
const Overlays = {
|
|
31
43
|
None: 'None',
|
|
32
44
|
Removedirectory : 'RemoveDirectory',
|
|
45
|
+
RemoveBatch: 'RemoveBatch',
|
|
33
46
|
MoveResource: 'MoveResource'
|
|
34
47
|
}
|
|
35
48
|
|
|
@@ -48,6 +61,9 @@ export const ResourcesPage = () => {
|
|
|
48
61
|
const [viewMode, setViewMode] = useState(ViewMode.List)
|
|
49
62
|
const [addMenuOpen, setAddMenuOpen] = useState(false)
|
|
50
63
|
const [addMenuPosition, setAddMenuPosition] = useState(null)
|
|
64
|
+
const [batchSelectedIds, setBatchSelectedIds] = useState(() => new Set())
|
|
65
|
+
const [selectionAnchorId, setSelectionAnchorId] = useState(null)
|
|
66
|
+
const [selectionMode, setSelectionMode] = useState(false)
|
|
51
67
|
const { selectedResourceId, setSelectedResourceId, clearSelectedResourceId } = useSelectedResourceId()
|
|
52
68
|
const activePath = useActivePath()
|
|
53
69
|
const lastSuccessfulResourcesRef = useRef([])
|
|
@@ -56,6 +72,12 @@ export const ResourcesPage = () => {
|
|
|
56
72
|
preloadStorageIcons()
|
|
57
73
|
}, [])
|
|
58
74
|
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
setBatchSelectedIds(new Set())
|
|
77
|
+
setSelectionAnchorId(null)
|
|
78
|
+
setSelectionMode(false)
|
|
79
|
+
}, [activePath])
|
|
80
|
+
|
|
59
81
|
const {
|
|
60
82
|
status: resourcesStatus,
|
|
61
83
|
data: resources = [],
|
|
@@ -150,6 +172,26 @@ export const ResourcesPage = () => {
|
|
|
150
172
|
|
|
151
173
|
}
|
|
152
174
|
|
|
175
|
+
const clearBatchSelection = useCallback(() => {
|
|
176
|
+
setBatchSelectedIds(new Set())
|
|
177
|
+
setSelectionAnchorId(null)
|
|
178
|
+
}, [])
|
|
179
|
+
|
|
180
|
+
const exitSelectionMode = useCallback(() => {
|
|
181
|
+
setSelectionMode(false)
|
|
182
|
+
clearBatchSelection()
|
|
183
|
+
}, [clearBatchSelection])
|
|
184
|
+
|
|
185
|
+
const enterSelectionMode = useCallback(() => {
|
|
186
|
+
setSelectionMode(true)
|
|
187
|
+
clearSelectedResourceId()
|
|
188
|
+
}, [clearSelectedResourceId])
|
|
189
|
+
|
|
190
|
+
const toggleSelectionMode = useCallback(() => {
|
|
191
|
+
if (selectionMode) exitSelectionMode()
|
|
192
|
+
else enterSelectionMode()
|
|
193
|
+
}, [selectionMode, exitSelectionMode, enterSelectionMode])
|
|
194
|
+
|
|
153
195
|
const openCreateFolder = useCallback(() => {
|
|
154
196
|
setIsCreatingFolder(true)
|
|
155
197
|
setNewFolderName(t('storage.resources.newFolderDefault'))
|
|
@@ -179,6 +221,12 @@ export const ResourcesPage = () => {
|
|
|
179
221
|
>
|
|
180
222
|
{t('storage.resources.createFolder')}
|
|
181
223
|
</ContextMenu.Item>
|
|
224
|
+
<ContextMenu.Item
|
|
225
|
+
prefix="file-document"
|
|
226
|
+
href={router.getHref(`@create-document?location=${encodeURIComponent(activePath)}`)}
|
|
227
|
+
>
|
|
228
|
+
{t('storage.resources.createDocument')}
|
|
229
|
+
</ContextMenu.Item>
|
|
182
230
|
<ContextMenu.Item
|
|
183
231
|
prefix="software-upload"
|
|
184
232
|
href={router.getHref(`@upload-media?location=${activePath}`)}
|
|
@@ -222,7 +270,10 @@ export const ResourcesPage = () => {
|
|
|
222
270
|
return {
|
|
223
271
|
...resource,
|
|
224
272
|
href: storageHomeHref(`location=${folderLocation}`),
|
|
225
|
-
onClick:
|
|
273
|
+
onClick: (item, event) => {
|
|
274
|
+
if (isMultiSelectGesture(event)) return
|
|
275
|
+
openLocation(folderLocation)(event)
|
|
276
|
+
},
|
|
226
277
|
onDrop: onMoveResource(dropLocation),
|
|
227
278
|
onFilesDrop: onUploadFiles(dropLocation),
|
|
228
279
|
actions: [
|
|
@@ -245,10 +296,17 @@ export const ResourcesPage = () => {
|
|
|
245
296
|
}
|
|
246
297
|
}
|
|
247
298
|
|
|
299
|
+
const downloadHref = isDownloadableResource(resource)
|
|
300
|
+
? resourceDownloadHref(resource)
|
|
301
|
+
: null
|
|
302
|
+
|
|
248
303
|
return {
|
|
249
304
|
...resource,
|
|
250
305
|
dragData: resource.id,
|
|
251
|
-
onClick: () =>
|
|
306
|
+
onClick: (item, event) => {
|
|
307
|
+
if (isMultiSelectGesture(event)) return
|
|
308
|
+
setSelectedResourceId(resource.id)
|
|
309
|
+
},
|
|
252
310
|
actions: [
|
|
253
311
|
<ContextMenu.Item
|
|
254
312
|
key="details"
|
|
@@ -257,6 +315,18 @@ export const ResourcesPage = () => {
|
|
|
257
315
|
>
|
|
258
316
|
View
|
|
259
317
|
</ContextMenu.Item>,
|
|
318
|
+
...(downloadHref
|
|
319
|
+
? [
|
|
320
|
+
<ContextMenu.Item
|
|
321
|
+
key="download"
|
|
322
|
+
prefix="software-download"
|
|
323
|
+
href={downloadHref}
|
|
324
|
+
download={resource.name}
|
|
325
|
+
>
|
|
326
|
+
{t('storage.resources.download')}
|
|
327
|
+
</ContextMenu.Item>,
|
|
328
|
+
]
|
|
329
|
+
: []),
|
|
260
330
|
<ContextMenu.Item
|
|
261
331
|
key="move"
|
|
262
332
|
prefix="details-more"
|
|
@@ -286,6 +356,107 @@ export const ResourcesPage = () => {
|
|
|
286
356
|
if (!aDir && bDir) return 1
|
|
287
357
|
}), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onUploadFiles, onRemoveResource, setSelectedResourceId, t])
|
|
288
358
|
|
|
359
|
+
const orderedResourceIds = useMemo(
|
|
360
|
+
() => filterResources.map((resource) => resource.id).filter(Boolean),
|
|
361
|
+
[filterResources],
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
const highlightedIds = useMemo(() => {
|
|
365
|
+
if (batchSelectedIds.size > 0) return batchSelectedIds
|
|
366
|
+
return selectedResourceId ? new Set([selectedResourceId]) : new Set()
|
|
367
|
+
}, [batchSelectedIds, selectedResourceId])
|
|
368
|
+
|
|
369
|
+
const selectedDownloadableResources = useMemo(() => {
|
|
370
|
+
if (batchSelectedIds.size === 0) return []
|
|
371
|
+
return filterDownloadableResources(
|
|
372
|
+
filterResources.filter((resource) => batchSelectedIds.has(resource.id)),
|
|
373
|
+
)
|
|
374
|
+
}, [batchSelectedIds, filterResources])
|
|
375
|
+
|
|
376
|
+
const selectedBatchResources = useMemo(() => {
|
|
377
|
+
if (batchSelectedIds.size === 0) return []
|
|
378
|
+
return filterResources.filter((resource) => batchSelectedIds.has(resource.id))
|
|
379
|
+
}, [batchSelectedIds, filterResources])
|
|
380
|
+
|
|
381
|
+
const handleResourceActivate = useCallback((resource, event) => {
|
|
382
|
+
if (!resource?.id) return
|
|
383
|
+
|
|
384
|
+
if (selectionMode || isMultiSelectGesture(event)) {
|
|
385
|
+
event?.preventDefault?.()
|
|
386
|
+
const gestureEvent = selectionMode && !isMultiSelectGesture(event)
|
|
387
|
+
? { metaKey: true }
|
|
388
|
+
: event
|
|
389
|
+
const { nextSelectedIds, nextAnchorId } = applyResourceSelectionGesture({
|
|
390
|
+
selectedIds: batchSelectedIds,
|
|
391
|
+
orderedIds: orderedResourceIds,
|
|
392
|
+
targetId: resource.id,
|
|
393
|
+
event: gestureEvent,
|
|
394
|
+
anchorId: selectionAnchorId,
|
|
395
|
+
})
|
|
396
|
+
setBatchSelectedIds(nextSelectedIds)
|
|
397
|
+
setSelectionAnchorId(nextAnchorId)
|
|
398
|
+
if (!selectionMode) setSelectionMode(true)
|
|
399
|
+
clearSelectedResourceId()
|
|
400
|
+
return
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
clearBatchSelection()
|
|
404
|
+
}, [
|
|
405
|
+
selectionMode,
|
|
406
|
+
batchSelectedIds,
|
|
407
|
+
orderedResourceIds,
|
|
408
|
+
selectionAnchorId,
|
|
409
|
+
clearSelectedResourceId,
|
|
410
|
+
clearBatchSelection,
|
|
411
|
+
])
|
|
412
|
+
|
|
413
|
+
const handleToggleSelect = useCallback((resource) => {
|
|
414
|
+
if (!resource?.id) return
|
|
415
|
+
if (!selectionMode) setSelectionMode(true)
|
|
416
|
+
const { nextSelectedIds, nextAnchorId } = applyResourceSelectionGesture({
|
|
417
|
+
selectedIds: batchSelectedIds,
|
|
418
|
+
orderedIds: orderedResourceIds,
|
|
419
|
+
targetId: resource.id,
|
|
420
|
+
event: { metaKey: true },
|
|
421
|
+
anchorId: selectionAnchorId,
|
|
422
|
+
})
|
|
423
|
+
setBatchSelectedIds(nextSelectedIds)
|
|
424
|
+
setSelectionAnchorId(nextAnchorId)
|
|
425
|
+
clearSelectedResourceId()
|
|
426
|
+
}, [
|
|
427
|
+
selectionMode,
|
|
428
|
+
batchSelectedIds,
|
|
429
|
+
orderedResourceIds,
|
|
430
|
+
selectionAnchorId,
|
|
431
|
+
clearSelectedResourceId,
|
|
432
|
+
])
|
|
433
|
+
|
|
434
|
+
const handleBatchDownload = useCallback(() => {
|
|
435
|
+
if (selectedDownloadableResources.length === 0) return
|
|
436
|
+
triggerResourceDownloads(selectedDownloadableResources).catch((error) => {
|
|
437
|
+
console.error('[storage] batch download failed', error)
|
|
438
|
+
})
|
|
439
|
+
}, [selectedDownloadableResources])
|
|
440
|
+
|
|
441
|
+
const handleBatchRemoveConfirm = useCallback(async () => {
|
|
442
|
+
const resources = selectedBatchResources
|
|
443
|
+
setOverlay(Overlays.None)
|
|
444
|
+
try {
|
|
445
|
+
for (const resource of resources) {
|
|
446
|
+
await removeResource(sdk, resource.id, resource.location || activePath)
|
|
447
|
+
}
|
|
448
|
+
} catch (error) {
|
|
449
|
+
console.error('[storage] batch remove failed', error)
|
|
450
|
+
} finally {
|
|
451
|
+
exitSelectionMode()
|
|
452
|
+
}
|
|
453
|
+
}, [selectedBatchResources, sdk, activePath, exitSelectionMode])
|
|
454
|
+
|
|
455
|
+
const selectionCount = batchSelectedIds.size
|
|
456
|
+
const selectionLabel = selectionCount === 1
|
|
457
|
+
? t('storage.resources.selectedOne')
|
|
458
|
+
: t('storage.resources.selectedMany').replace('{count}', String(selectionCount))
|
|
459
|
+
const showSelectionControls = selectionMode
|
|
289
460
|
return (
|
|
290
461
|
<>
|
|
291
462
|
<style>
|
|
@@ -334,16 +505,42 @@ export const ResourcesPage = () => {
|
|
|
334
505
|
}}
|
|
335
506
|
>
|
|
336
507
|
|
|
337
|
-
<
|
|
338
|
-
<
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
508
|
+
<View layout="row" gap="s" alignItems="center" style={{ minWidth: 0, flex: 1 }}>
|
|
509
|
+
<Button
|
|
510
|
+
prefix="check-r"
|
|
511
|
+
variant="command"
|
|
512
|
+
aria-label={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
|
|
513
|
+
aria-pressed={selectionMode}
|
|
514
|
+
title={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
|
|
515
|
+
onClick={toggleSelectionMode}
|
|
516
|
+
style={{
|
|
517
|
+
height: '32px',
|
|
518
|
+
flexShrink: 0,
|
|
519
|
+
...(selectionMode
|
|
520
|
+
? { background: 'var(--background-active)', color: 'var(--foreground-active, var(--foreground))' }
|
|
521
|
+
: {}),
|
|
522
|
+
}}
|
|
523
|
+
/>
|
|
524
|
+
<View
|
|
525
|
+
aria-hidden="true"
|
|
526
|
+
style={{
|
|
527
|
+
width: '1px',
|
|
528
|
+
height: '16px',
|
|
529
|
+
background: 'var(--separator-primary)',
|
|
530
|
+
flexShrink: 0,
|
|
531
|
+
}}
|
|
532
|
+
/>
|
|
533
|
+
<Breadcrumbs>
|
|
534
|
+
<DropZone
|
|
535
|
+
onDrop={activePath === '/' ? undefined : onMoveResource('/')}
|
|
536
|
+
onFilesDrop={onUploadFiles('/')}
|
|
537
|
+
>
|
|
538
|
+
<Button prefix="home-alt" variant="command" onClick={openLocation('/')} href={storageHomeHref()} />
|
|
539
|
+
</DropZone>
|
|
540
|
+
|
|
541
|
+
{ activePath !== '/' && getActivePath() }
|
|
542
|
+
</Breadcrumbs>
|
|
543
|
+
</View>
|
|
347
544
|
|
|
348
545
|
<View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
|
|
349
546
|
<Dropdown
|
|
@@ -395,6 +592,53 @@ export const ResourcesPage = () => {
|
|
|
395
592
|
|
|
396
593
|
</View.Item>
|
|
397
594
|
|
|
595
|
+
{selectionMode && (
|
|
596
|
+
<View.Item
|
|
597
|
+
data-surface="primary"
|
|
598
|
+
layout="row"
|
|
599
|
+
style={{
|
|
600
|
+
alignItems: 'center',
|
|
601
|
+
justifyContent: 'space-between',
|
|
602
|
+
padding: 'var(--space-xs) var(--space-m)',
|
|
603
|
+
gap: 'var(--space-m)',
|
|
604
|
+
minHeight: '40px',
|
|
605
|
+
flexShrink: 0,
|
|
606
|
+
borderBottom: '1px solid var(--separator-primary)',
|
|
607
|
+
}}
|
|
608
|
+
>
|
|
609
|
+
<Text variant="small">
|
|
610
|
+
{selectionCount > 0 ? selectionLabel : t('storage.resources.selectModeHint')}
|
|
611
|
+
</Text>
|
|
612
|
+
<View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
|
|
613
|
+
<Button
|
|
614
|
+
prefix="software-download"
|
|
615
|
+
variant="command"
|
|
616
|
+
disabled={selectedDownloadableResources.length === 0}
|
|
617
|
+
onClick={handleBatchDownload}
|
|
618
|
+
style={{ height: '32px' }}
|
|
619
|
+
>
|
|
620
|
+
{t('storage.resources.downloadSelected')}
|
|
621
|
+
</Button>
|
|
622
|
+
<Button
|
|
623
|
+
prefix="trash-empty"
|
|
624
|
+
variant="command-danger"
|
|
625
|
+
disabled={selectedBatchResources.length === 0}
|
|
626
|
+
onClick={() => setOverlay(Overlays.RemoveBatch)}
|
|
627
|
+
style={{ height: '32px' }}
|
|
628
|
+
>
|
|
629
|
+
{t('storage.resources.removeSelected')}
|
|
630
|
+
</Button>
|
|
631
|
+
<Button
|
|
632
|
+
variant="command"
|
|
633
|
+
onClick={exitSelectionMode}
|
|
634
|
+
style={{ height: '32px' }}
|
|
635
|
+
>
|
|
636
|
+
{t('storage.resources.doneSelecting')}
|
|
637
|
+
</Button>
|
|
638
|
+
</View>
|
|
639
|
+
</View.Item>
|
|
640
|
+
)}
|
|
641
|
+
|
|
398
642
|
<View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto', minHeight: 0 }}>
|
|
399
643
|
<DropZone onFilesDrop={onUploadFiles(activePath)}>
|
|
400
644
|
<View style={{ minHeight: '100%' }} onContextMenu={handleDropZoneContextMenu}>
|
|
@@ -482,8 +726,26 @@ export const ResourcesPage = () => {
|
|
|
482
726
|
|
|
483
727
|
<Switch.Case match={[ResourcesListStatus.Success]}>
|
|
484
728
|
{viewMode === ViewMode.Grid
|
|
485
|
-
?
|
|
486
|
-
|
|
729
|
+
? (
|
|
730
|
+
<ResourceGrid
|
|
731
|
+
resources={filterResources}
|
|
732
|
+
inlineFolder={inlineFolder}
|
|
733
|
+
selectedIds={highlightedIds}
|
|
734
|
+
showSelectionControls={showSelectionControls}
|
|
735
|
+
onClick={handleResourceActivate}
|
|
736
|
+
onToggleSelect={handleToggleSelect}
|
|
737
|
+
/>
|
|
738
|
+
)
|
|
739
|
+
: (
|
|
740
|
+
<ResourceList
|
|
741
|
+
resources={filterResources}
|
|
742
|
+
inlineFolder={inlineFolder}
|
|
743
|
+
selectedIds={highlightedIds}
|
|
744
|
+
showSelectionControls={showSelectionControls}
|
|
745
|
+
onClick={handleResourceActivate}
|
|
746
|
+
onToggleSelect={handleToggleSelect}
|
|
747
|
+
/>
|
|
748
|
+
)}
|
|
487
749
|
</Switch.Case>
|
|
488
750
|
|
|
489
751
|
</Switch>
|
|
@@ -525,6 +787,29 @@ export const ResourcesPage = () => {
|
|
|
525
787
|
)
|
|
526
788
|
}
|
|
527
789
|
|
|
790
|
+
{
|
|
791
|
+
overlay === Overlays.RemoveBatch && (
|
|
792
|
+
<Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
|
|
793
|
+
<View layout="off-center-s" style={{ height: '100%' }}>
|
|
794
|
+
<View data-region="content">
|
|
795
|
+
<View surface="primary" roundness="s">
|
|
796
|
+
<View surface="primary" inset="l" roundness="s">
|
|
797
|
+
<Guide
|
|
798
|
+
title={t('storage.resources.removeSelectedTitle')}
|
|
799
|
+
text={t('storage.resources.removeSelectedText').replace('{count}', String(selectionCount))}
|
|
800
|
+
actions={[
|
|
801
|
+
{ label: t('storage.resources.cancel'), variant: 'command', onClick: () => setOverlay(Overlays.None) },
|
|
802
|
+
{ label: t('storage.resources.removeSelected'), variant: 'command-danger', onClick: handleBatchRemoveConfirm },
|
|
803
|
+
]}
|
|
804
|
+
/>
|
|
805
|
+
</View>
|
|
806
|
+
</View>
|
|
807
|
+
</View>
|
|
808
|
+
</View>
|
|
809
|
+
</Overlay>
|
|
810
|
+
)
|
|
811
|
+
}
|
|
812
|
+
|
|
528
813
|
{
|
|
529
814
|
overlay === Overlays.MoveResource && (
|
|
530
815
|
<Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
|
|
@@ -537,4 +822,3 @@ export const ResourcesPage = () => {
|
|
|
537
822
|
</>
|
|
538
823
|
)
|
|
539
824
|
}
|
|
540
|
-
|
package/src/en.translations.json
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"storage.resources.beta": "Beta",
|
|
9
9
|
"storage.resources.add": "Add",
|
|
10
10
|
"storage.resources.createFolder": "Create folder",
|
|
11
|
+
"storage.resources.createDocument": "Create document",
|
|
11
12
|
"storage.resources.uploadFile": "Upload file",
|
|
12
13
|
"storage.resources.newFolderDefault": "New folder",
|
|
13
14
|
"storage.resources.errorTitle": "Something went wrong",
|
|
@@ -19,6 +20,18 @@
|
|
|
19
20
|
"storage.resources.cancel": "Cancel",
|
|
20
21
|
"storage.resources.remove": "Remove",
|
|
21
22
|
"storage.resources.move": "Move",
|
|
23
|
+
"storage.resources.download": "Download",
|
|
24
|
+
"storage.resources.downloadSelected": "Download selected",
|
|
25
|
+
"storage.resources.removeSelected": "Remove selected",
|
|
26
|
+
"storage.resources.removeSelectedTitle": "Remove selected",
|
|
27
|
+
"storage.resources.removeSelectedText": "Are you sure you want to remove {count} selected items? Folders and their contents will be deleted.",
|
|
28
|
+
"storage.resources.selectMode": "Select",
|
|
29
|
+
"storage.resources.selectModeActive": "Selecting",
|
|
30
|
+
"storage.resources.selectModeHint": "Tap items to select them",
|
|
31
|
+
"storage.resources.doneSelecting": "Done",
|
|
32
|
+
"storage.resources.clearSelection": "Clear selection",
|
|
33
|
+
"storage.resources.selectedOne": "1 selected",
|
|
34
|
+
"storage.resources.selectedMany": "{count} selected",
|
|
22
35
|
"storage.resources.contextRemove": "Remove",
|
|
23
36
|
"storage.resources.layout": "Layout",
|
|
24
37
|
"storage.resources.viewList": "List view",
|
package/src/local-storage.api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StorageClient } from '@ossy/platform'
|
|
2
2
|
import { assertStorageKey } from '@ossy/platform/storage-keys'
|
|
3
3
|
import { createLogger } from '@ossy/observability'
|
|
4
|
+
import { assertUploadAccessForStorageKey } from '@ossy/resources/server'
|
|
4
5
|
|
|
5
6
|
const log = createLogger('local-storage')
|
|
6
7
|
|
|
@@ -44,17 +45,21 @@ export default async function handle (req, res) {
|
|
|
44
45
|
return
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
// PUT — receive raw file bytes
|
|
48
|
+
// PUT — receive raw file bytes (same pattern as S3 presigned PUT, with session auth)
|
|
48
49
|
if (req.method === 'PUT') {
|
|
49
50
|
try {
|
|
51
|
+
await assertUploadAccessForStorageKey(key, req)
|
|
50
52
|
const chunks = []
|
|
51
53
|
for await (const chunk of req) chunks.push(chunk)
|
|
52
54
|
const body = Buffer.concat(chunks)
|
|
53
55
|
await StorageClient.save(key, body)
|
|
54
56
|
res.status(200).end()
|
|
55
57
|
} catch (err) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
const status = err?.status ?? 500
|
|
59
|
+
if (status >= 500) {
|
|
60
|
+
log.error('[local-storage] PUT failed', undefined, err)
|
|
61
|
+
}
|
|
62
|
+
res.status(status).json({ error: err.message })
|
|
58
63
|
}
|
|
59
64
|
return
|
|
60
65
|
}
|
package/src/sv.translations.json
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"storage.resources.beta": "Beta",
|
|
9
9
|
"storage.resources.add": "Lägg till",
|
|
10
10
|
"storage.resources.createFolder": "Skapa mapp",
|
|
11
|
+
"storage.resources.createDocument": "Skapa dokument",
|
|
11
12
|
"storage.resources.uploadFile": "Ladda upp fil",
|
|
12
13
|
"storage.resources.newFolderDefault": "Ny mapp",
|
|
13
14
|
"storage.resources.errorTitle": "Något gick fel",
|
|
@@ -19,6 +20,18 @@
|
|
|
19
20
|
"storage.resources.cancel": "Avbryt",
|
|
20
21
|
"storage.resources.remove": "Ta bort",
|
|
21
22
|
"storage.resources.move": "Flytta",
|
|
23
|
+
"storage.resources.download": "Ladda ner",
|
|
24
|
+
"storage.resources.downloadSelected": "Ladda ner markerade",
|
|
25
|
+
"storage.resources.removeSelected": "Ta bort markerade",
|
|
26
|
+
"storage.resources.removeSelectedTitle": "Ta bort markerade",
|
|
27
|
+
"storage.resources.removeSelectedText": "Är du säker på att du vill ta bort {count} markerade objekt? Mappar och deras innehåll tas bort.",
|
|
28
|
+
"storage.resources.selectMode": "Markera",
|
|
29
|
+
"storage.resources.selectModeActive": "Markerar",
|
|
30
|
+
"storage.resources.selectModeHint": "Tryck på objekt för att markera dem",
|
|
31
|
+
"storage.resources.doneSelecting": "Klar",
|
|
32
|
+
"storage.resources.clearSelection": "Rensa markering",
|
|
33
|
+
"storage.resources.selectedOne": "1 markerad",
|
|
34
|
+
"storage.resources.selectedMany": "{count} markerade",
|
|
22
35
|
"storage.resources.contextRemove": "Ta bort",
|
|
23
36
|
"storage.resources.layout": "Layout",
|
|
24
37
|
"storage.resources.viewList": "Listvy",
|