@ossy/storage 3.0.9 → 3.5.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 +419 -71
- package/src/en.translations.json +16 -1
- package/src/local-storage.api.js +8 -3
- package/src/sv.translations.json +16 -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.5.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": "23167600f991596f122765a53f2b9df08314e115"
|
|
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 {
|
|
@@ -10,7 +22,7 @@ import {
|
|
|
10
22
|
last,
|
|
11
23
|
} from 'ramda'
|
|
12
24
|
import { Text, Overlay, Switch, DropZone, Breadcrumbs, Guide, DelayedRender, useDocumentTitle, View, Button, ContextMenu, Dropdown, Page, Tags, useLocale, preloadStorageIcons } from '@ossy/design-system'
|
|
13
|
-
import { useActivePath, ResourcePanel, ResourceList, ResourceDialogMove, useSelectedResourceId } from '@ossy/resources'
|
|
25
|
+
import { useActivePath, ResourcePanel, ResourceList, ResourceGrid, ResourceDialogMove, useSelectedResourceId } from '@ossy/resources'
|
|
14
26
|
import { useRouter, useSearchParams } from '@ossy/router-react'
|
|
15
27
|
|
|
16
28
|
const Path = ({ path, ...props }) => (
|
|
@@ -30,9 +42,15 @@ 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
|
|
|
49
|
+
const ViewMode = {
|
|
50
|
+
List: 'list',
|
|
51
|
+
Grid: 'grid',
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
export const ResourcesPage = () => {
|
|
37
55
|
const router = useRouter()
|
|
38
56
|
const searchParams = useSearchParams()
|
|
@@ -40,6 +58,12 @@ export const ResourcesPage = () => {
|
|
|
40
58
|
const sdk = useSdk()
|
|
41
59
|
const { data: workspace = {} } = sdk.read(GetWorkspace)
|
|
42
60
|
const [overlay, setOverlay] = useState(Overlays.None)
|
|
61
|
+
const [viewMode, setViewMode] = useState(ViewMode.List)
|
|
62
|
+
const [addMenuOpen, setAddMenuOpen] = useState(false)
|
|
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)
|
|
43
67
|
const { selectedResourceId, setSelectedResourceId, clearSelectedResourceId } = useSelectedResourceId()
|
|
44
68
|
const activePath = useActivePath()
|
|
45
69
|
const lastSuccessfulResourcesRef = useRef([])
|
|
@@ -48,6 +72,12 @@ export const ResourcesPage = () => {
|
|
|
48
72
|
preloadStorageIcons()
|
|
49
73
|
}, [])
|
|
50
74
|
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
setBatchSelectedIds(new Set())
|
|
77
|
+
setSelectionAnchorId(null)
|
|
78
|
+
setSelectionMode(false)
|
|
79
|
+
}, [activePath])
|
|
80
|
+
|
|
51
81
|
const {
|
|
52
82
|
status: resourcesStatus,
|
|
53
83
|
data: resources = [],
|
|
@@ -142,6 +172,65 @@ export const ResourcesPage = () => {
|
|
|
142
172
|
|
|
143
173
|
}
|
|
144
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
|
+
|
|
195
|
+
const openCreateFolder = useCallback(() => {
|
|
196
|
+
setIsCreatingFolder(true)
|
|
197
|
+
setNewFolderName(t('storage.resources.newFolderDefault'))
|
|
198
|
+
}, [t])
|
|
199
|
+
|
|
200
|
+
const handleAddMenuOpenChange = useCallback((open) => {
|
|
201
|
+
setAddMenuOpen(open)
|
|
202
|
+
if (!open) setAddMenuPosition(null)
|
|
203
|
+
}, [])
|
|
204
|
+
|
|
205
|
+
const handleAddTriggerClick = useCallback(() => {
|
|
206
|
+
setAddMenuPosition(null)
|
|
207
|
+
}, [])
|
|
208
|
+
|
|
209
|
+
const handleDropZoneContextMenu = useCallback((event) => {
|
|
210
|
+
event.preventDefault()
|
|
211
|
+
setAddMenuPosition({ top: event.clientY, left: event.clientX })
|
|
212
|
+
setAddMenuOpen(true)
|
|
213
|
+
}, [])
|
|
214
|
+
|
|
215
|
+
const addMenu = (
|
|
216
|
+
<View inset="xs" surface="primary" roundness="s">
|
|
217
|
+
<ContextMenu roundness="s" surface="primary">
|
|
218
|
+
<ContextMenu.Item
|
|
219
|
+
prefix="folder-add"
|
|
220
|
+
onClick={openCreateFolder}
|
|
221
|
+
>
|
|
222
|
+
{t('storage.resources.createFolder')}
|
|
223
|
+
</ContextMenu.Item>
|
|
224
|
+
<ContextMenu.Item
|
|
225
|
+
prefix="software-upload"
|
|
226
|
+
href={router.getHref(`@upload-media?location=${activePath}`)}
|
|
227
|
+
>
|
|
228
|
+
{t('storage.resources.uploadFile')}
|
|
229
|
+
</ContextMenu.Item>
|
|
230
|
+
</ContextMenu>
|
|
231
|
+
</View>
|
|
232
|
+
)
|
|
233
|
+
|
|
145
234
|
const getActivePath = () => pipe(
|
|
146
235
|
split('/'),
|
|
147
236
|
filter(identity),
|
|
@@ -175,14 +264,16 @@ export const ResourcesPage = () => {
|
|
|
175
264
|
return {
|
|
176
265
|
...resource,
|
|
177
266
|
href: storageHomeHref(`location=${folderLocation}`),
|
|
178
|
-
onClick:
|
|
267
|
+
onClick: (item, event) => {
|
|
268
|
+
if (isMultiSelectGesture(event)) return
|
|
269
|
+
openLocation(folderLocation)(event)
|
|
270
|
+
},
|
|
179
271
|
onDrop: onMoveResource(dropLocation),
|
|
180
272
|
onFilesDrop: onUploadFiles(dropLocation),
|
|
181
273
|
actions: [
|
|
182
274
|
<ContextMenu.Item
|
|
183
275
|
prefix="mail-forward"
|
|
184
276
|
href={storageHomeHref(`location=${activePath}${resource.name}`)}
|
|
185
|
-
onClick={event => { event.stopPropagation() }}
|
|
186
277
|
key="details"
|
|
187
278
|
>
|
|
188
279
|
Open
|
|
@@ -192,40 +283,51 @@ export const ResourcesPage = () => {
|
|
|
192
283
|
variant="command-danger"
|
|
193
284
|
prefix="trash-empty"
|
|
194
285
|
key="remove"
|
|
195
|
-
onClick={
|
|
196
|
-
event.stopPropagation()
|
|
197
|
-
onRemoveResource(resource)
|
|
198
|
-
}}
|
|
286
|
+
onClick={() => onRemoveResource(resource)}
|
|
199
287
|
>{t('storage.resources.contextRemove')}
|
|
200
288
|
</ContextMenu.Item>
|
|
201
289
|
]
|
|
202
290
|
}
|
|
203
291
|
}
|
|
204
292
|
|
|
293
|
+
const downloadHref = isDownloadableResource(resource)
|
|
294
|
+
? resourceDownloadHref(resource)
|
|
295
|
+
: null
|
|
296
|
+
|
|
205
297
|
return {
|
|
206
298
|
...resource,
|
|
207
299
|
dragData: resource.id,
|
|
208
|
-
onClick: () =>
|
|
300
|
+
onClick: (item, event) => {
|
|
301
|
+
if (isMultiSelectGesture(event)) return
|
|
302
|
+
setSelectedResourceId(resource.id)
|
|
303
|
+
},
|
|
209
304
|
actions: [
|
|
210
305
|
<ContextMenu.Item
|
|
211
306
|
key="details"
|
|
212
307
|
prefix="details-more"
|
|
213
|
-
onClick={
|
|
214
|
-
event.stopPropagation()
|
|
215
|
-
setSelectedResourceId(resource.id)}
|
|
216
|
-
}
|
|
308
|
+
onClick={() => setSelectedResourceId(resource.id)}
|
|
217
309
|
>
|
|
218
310
|
View
|
|
219
311
|
</ContextMenu.Item>,
|
|
312
|
+
...(downloadHref
|
|
313
|
+
? [
|
|
314
|
+
<ContextMenu.Item
|
|
315
|
+
key="download"
|
|
316
|
+
prefix="software-download"
|
|
317
|
+
href={downloadHref}
|
|
318
|
+
download={resource.name}
|
|
319
|
+
>
|
|
320
|
+
{t('storage.resources.download')}
|
|
321
|
+
</ContextMenu.Item>,
|
|
322
|
+
]
|
|
323
|
+
: []),
|
|
220
324
|
<ContextMenu.Item
|
|
221
|
-
key="
|
|
325
|
+
key="move"
|
|
222
326
|
prefix="details-more"
|
|
223
|
-
onClick={
|
|
224
|
-
event.stopPropagation()
|
|
327
|
+
onClick={() => {
|
|
225
328
|
setSelectedResourceId(resource.id)
|
|
226
329
|
setOverlay(Overlays.MoveResource)
|
|
227
|
-
}
|
|
228
|
-
}
|
|
330
|
+
}}
|
|
229
331
|
>
|
|
230
332
|
{t('storage.resources.move')}
|
|
231
333
|
</ContextMenu.Item>,
|
|
@@ -234,10 +336,7 @@ export const ResourcesPage = () => {
|
|
|
234
336
|
key="remove"
|
|
235
337
|
variant="command-danger"
|
|
236
338
|
prefix="trash-empty"
|
|
237
|
-
onClick={
|
|
238
|
-
event.stopPropagation()
|
|
239
|
-
onRemoveResource(resource)
|
|
240
|
-
}}
|
|
339
|
+
onClick={() => onRemoveResource(resource)}
|
|
241
340
|
>Remove
|
|
242
341
|
</ContextMenu.Item>
|
|
243
342
|
]
|
|
@@ -251,6 +350,107 @@ export const ResourcesPage = () => {
|
|
|
251
350
|
if (!aDir && bDir) return 1
|
|
252
351
|
}), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onUploadFiles, onRemoveResource, setSelectedResourceId, t])
|
|
253
352
|
|
|
353
|
+
const orderedResourceIds = useMemo(
|
|
354
|
+
() => filterResources.map((resource) => resource.id).filter(Boolean),
|
|
355
|
+
[filterResources],
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
const highlightedIds = useMemo(() => {
|
|
359
|
+
if (batchSelectedIds.size > 0) return batchSelectedIds
|
|
360
|
+
return selectedResourceId ? new Set([selectedResourceId]) : new Set()
|
|
361
|
+
}, [batchSelectedIds, selectedResourceId])
|
|
362
|
+
|
|
363
|
+
const selectedDownloadableResources = useMemo(() => {
|
|
364
|
+
if (batchSelectedIds.size === 0) return []
|
|
365
|
+
return filterDownloadableResources(
|
|
366
|
+
filterResources.filter((resource) => batchSelectedIds.has(resource.id)),
|
|
367
|
+
)
|
|
368
|
+
}, [batchSelectedIds, filterResources])
|
|
369
|
+
|
|
370
|
+
const selectedBatchResources = useMemo(() => {
|
|
371
|
+
if (batchSelectedIds.size === 0) return []
|
|
372
|
+
return filterResources.filter((resource) => batchSelectedIds.has(resource.id))
|
|
373
|
+
}, [batchSelectedIds, filterResources])
|
|
374
|
+
|
|
375
|
+
const handleResourceActivate = useCallback((resource, event) => {
|
|
376
|
+
if (!resource?.id) return
|
|
377
|
+
|
|
378
|
+
if (selectionMode || isMultiSelectGesture(event)) {
|
|
379
|
+
event?.preventDefault?.()
|
|
380
|
+
const gestureEvent = selectionMode && !isMultiSelectGesture(event)
|
|
381
|
+
? { metaKey: true }
|
|
382
|
+
: event
|
|
383
|
+
const { nextSelectedIds, nextAnchorId } = applyResourceSelectionGesture({
|
|
384
|
+
selectedIds: batchSelectedIds,
|
|
385
|
+
orderedIds: orderedResourceIds,
|
|
386
|
+
targetId: resource.id,
|
|
387
|
+
event: gestureEvent,
|
|
388
|
+
anchorId: selectionAnchorId,
|
|
389
|
+
})
|
|
390
|
+
setBatchSelectedIds(nextSelectedIds)
|
|
391
|
+
setSelectionAnchorId(nextAnchorId)
|
|
392
|
+
if (!selectionMode) setSelectionMode(true)
|
|
393
|
+
clearSelectedResourceId()
|
|
394
|
+
return
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
clearBatchSelection()
|
|
398
|
+
}, [
|
|
399
|
+
selectionMode,
|
|
400
|
+
batchSelectedIds,
|
|
401
|
+
orderedResourceIds,
|
|
402
|
+
selectionAnchorId,
|
|
403
|
+
clearSelectedResourceId,
|
|
404
|
+
clearBatchSelection,
|
|
405
|
+
])
|
|
406
|
+
|
|
407
|
+
const handleToggleSelect = useCallback((resource) => {
|
|
408
|
+
if (!resource?.id) return
|
|
409
|
+
if (!selectionMode) setSelectionMode(true)
|
|
410
|
+
const { nextSelectedIds, nextAnchorId } = applyResourceSelectionGesture({
|
|
411
|
+
selectedIds: batchSelectedIds,
|
|
412
|
+
orderedIds: orderedResourceIds,
|
|
413
|
+
targetId: resource.id,
|
|
414
|
+
event: { metaKey: true },
|
|
415
|
+
anchorId: selectionAnchorId,
|
|
416
|
+
})
|
|
417
|
+
setBatchSelectedIds(nextSelectedIds)
|
|
418
|
+
setSelectionAnchorId(nextAnchorId)
|
|
419
|
+
clearSelectedResourceId()
|
|
420
|
+
}, [
|
|
421
|
+
selectionMode,
|
|
422
|
+
batchSelectedIds,
|
|
423
|
+
orderedResourceIds,
|
|
424
|
+
selectionAnchorId,
|
|
425
|
+
clearSelectedResourceId,
|
|
426
|
+
])
|
|
427
|
+
|
|
428
|
+
const handleBatchDownload = useCallback(() => {
|
|
429
|
+
if (selectedDownloadableResources.length === 0) return
|
|
430
|
+
triggerResourceDownloads(selectedDownloadableResources).catch((error) => {
|
|
431
|
+
console.error('[storage] batch download failed', error)
|
|
432
|
+
})
|
|
433
|
+
}, [selectedDownloadableResources])
|
|
434
|
+
|
|
435
|
+
const handleBatchRemoveConfirm = useCallback(async () => {
|
|
436
|
+
const resources = selectedBatchResources
|
|
437
|
+
setOverlay(Overlays.None)
|
|
438
|
+
try {
|
|
439
|
+
for (const resource of resources) {
|
|
440
|
+
await removeResource(sdk, resource.id, resource.location || activePath)
|
|
441
|
+
}
|
|
442
|
+
} catch (error) {
|
|
443
|
+
console.error('[storage] batch remove failed', error)
|
|
444
|
+
} finally {
|
|
445
|
+
exitSelectionMode()
|
|
446
|
+
}
|
|
447
|
+
}, [selectedBatchResources, sdk, activePath, exitSelectionMode])
|
|
448
|
+
|
|
449
|
+
const selectionCount = batchSelectedIds.size
|
|
450
|
+
const selectionLabel = selectionCount === 1
|
|
451
|
+
? t('storage.resources.selectedOne')
|
|
452
|
+
: t('storage.resources.selectedMany').replace('{count}', String(selectionCount))
|
|
453
|
+
const showSelectionControls = selectionMode
|
|
254
454
|
return (
|
|
255
455
|
<>
|
|
256
456
|
<style>
|
|
@@ -310,33 +510,120 @@ export const ResourcesPage = () => {
|
|
|
310
510
|
{ activePath !== '/' && getActivePath() }
|
|
311
511
|
</Breadcrumbs>
|
|
312
512
|
|
|
313
|
-
<
|
|
314
|
-
<
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
513
|
+
<View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
|
|
514
|
+
<Button
|
|
515
|
+
prefix="check-r"
|
|
516
|
+
variant="command"
|
|
517
|
+
aria-label={t('storage.resources.selectMode')}
|
|
518
|
+
aria-pressed={selectionMode}
|
|
519
|
+
label={selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode'}
|
|
520
|
+
onClick={toggleSelectionMode}
|
|
521
|
+
style={{
|
|
522
|
+
height: '32px',
|
|
523
|
+
...(selectionMode
|
|
524
|
+
? { background: 'var(--background-active)', color: 'var(--foreground-active, var(--foreground))' }
|
|
525
|
+
: {}),
|
|
526
|
+
}}
|
|
527
|
+
/>
|
|
528
|
+
<Dropdown
|
|
529
|
+
trigger={(
|
|
530
|
+
<Button
|
|
531
|
+
prefix={viewMode === ViewMode.Grid ? 'layout-grid' : 'layout-list'}
|
|
532
|
+
variant="command"
|
|
533
|
+
aria-label={t('storage.resources.layout')}
|
|
534
|
+
style={{ height: '32px' }}
|
|
535
|
+
/>
|
|
536
|
+
)}
|
|
537
|
+
>
|
|
538
|
+
<View inset="xs" surface="primary" roundness="s">
|
|
539
|
+
<ContextMenu roundness="s" surface="primary">
|
|
540
|
+
<ContextMenu.Item
|
|
541
|
+
prefix="layout-list"
|
|
542
|
+
suffix={viewMode === ViewMode.List ? 'check' : undefined}
|
|
543
|
+
onClick={() => setViewMode(ViewMode.List)}
|
|
544
|
+
>
|
|
545
|
+
{t('storage.resources.viewList')}
|
|
546
|
+
</ContextMenu.Item>
|
|
547
|
+
<ContextMenu.Item
|
|
548
|
+
prefix="layout-grid"
|
|
549
|
+
suffix={viewMode === ViewMode.Grid ? 'check' : undefined}
|
|
550
|
+
onClick={() => setViewMode(ViewMode.Grid)}
|
|
551
|
+
>
|
|
552
|
+
{t('storage.resources.viewGrid')}
|
|
553
|
+
</ContextMenu.Item>
|
|
554
|
+
</ContextMenu>
|
|
555
|
+
</View>
|
|
556
|
+
</Dropdown>
|
|
557
|
+
<Dropdown
|
|
558
|
+
trigger={(
|
|
559
|
+
<Button
|
|
560
|
+
prefix="add"
|
|
561
|
+
variant="command"
|
|
562
|
+
style={{ height: '32px' }}
|
|
563
|
+
label="storage.resources.add"
|
|
564
|
+
onClick={handleAddTriggerClick}
|
|
565
|
+
/>
|
|
566
|
+
)}
|
|
567
|
+
open={addMenuOpen}
|
|
568
|
+
onOpenChange={handleAddMenuOpenChange}
|
|
569
|
+
position={addMenuPosition}
|
|
570
|
+
>
|
|
571
|
+
{addMenu}
|
|
572
|
+
</Dropdown>
|
|
573
|
+
</View>
|
|
334
574
|
|
|
335
575
|
</View.Item>
|
|
336
576
|
|
|
577
|
+
{selectionMode && (
|
|
578
|
+
<View.Item
|
|
579
|
+
data-surface="primary"
|
|
580
|
+
layout="row"
|
|
581
|
+
style={{
|
|
582
|
+
alignItems: 'center',
|
|
583
|
+
justifyContent: 'space-between',
|
|
584
|
+
padding: 'var(--space-xs) var(--space-m)',
|
|
585
|
+
gap: 'var(--space-m)',
|
|
586
|
+
minHeight: '40px',
|
|
587
|
+
flexShrink: 0,
|
|
588
|
+
borderBottom: '1px solid var(--separator-primary)',
|
|
589
|
+
}}
|
|
590
|
+
>
|
|
591
|
+
<Text variant="small">
|
|
592
|
+
{selectionCount > 0 ? selectionLabel : t('storage.resources.selectModeHint')}
|
|
593
|
+
</Text>
|
|
594
|
+
<View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
|
|
595
|
+
<Button
|
|
596
|
+
prefix="software-download"
|
|
597
|
+
variant="command"
|
|
598
|
+
disabled={selectedDownloadableResources.length === 0}
|
|
599
|
+
onClick={handleBatchDownload}
|
|
600
|
+
style={{ height: '32px' }}
|
|
601
|
+
>
|
|
602
|
+
{t('storage.resources.downloadSelected')}
|
|
603
|
+
</Button>
|
|
604
|
+
<Button
|
|
605
|
+
prefix="trash-empty"
|
|
606
|
+
variant="command-danger"
|
|
607
|
+
disabled={selectedBatchResources.length === 0}
|
|
608
|
+
onClick={() => setOverlay(Overlays.RemoveBatch)}
|
|
609
|
+
style={{ height: '32px' }}
|
|
610
|
+
>
|
|
611
|
+
{t('storage.resources.removeSelected')}
|
|
612
|
+
</Button>
|
|
613
|
+
<Button
|
|
614
|
+
variant="command"
|
|
615
|
+
onClick={exitSelectionMode}
|
|
616
|
+
style={{ height: '32px' }}
|
|
617
|
+
>
|
|
618
|
+
{t('storage.resources.doneSelecting')}
|
|
619
|
+
</Button>
|
|
620
|
+
</View>
|
|
621
|
+
</View.Item>
|
|
622
|
+
)}
|
|
623
|
+
|
|
337
624
|
<View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto', minHeight: 0 }}>
|
|
338
625
|
<DropZone onFilesDrop={onUploadFiles(activePath)}>
|
|
339
|
-
<View style={{ minHeight: '100%' }}>
|
|
626
|
+
<View style={{ minHeight: '100%' }} onContextMenu={handleDropZoneContextMenu}>
|
|
340
627
|
<Switch on={resourcesListStatus}>
|
|
341
628
|
|
|
342
629
|
<Switch.Case match={[ResourcesListStatus.Error]}>
|
|
@@ -352,41 +639,60 @@ export const ResourcesPage = () => {
|
|
|
352
639
|
|
|
353
640
|
<Switch.Case match={[ResourcesListStatus.Loading]}>
|
|
354
641
|
<DelayedRender>
|
|
355
|
-
{
|
|
356
|
-
|
|
357
|
-
<
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
<div className="d-flex align-center">
|
|
362
|
-
<span
|
|
363
|
-
className="inline-m"
|
|
642
|
+
{viewMode === ViewMode.Grid
|
|
643
|
+
? (
|
|
644
|
+
<View layout="row-wrap" gap="m" inset="m">
|
|
645
|
+
{[1, 2, 3, 4, 5, 6].map(n => (
|
|
646
|
+
<View
|
|
647
|
+
key={n}
|
|
364
648
|
style={{
|
|
365
|
-
width:
|
|
366
|
-
height:
|
|
367
|
-
flexShrink: 0,
|
|
649
|
+
width: 160,
|
|
650
|
+
height: 160,
|
|
368
651
|
background: 'hsl(0, 0%, 50%)',
|
|
369
|
-
borderRadius: '
|
|
370
|
-
|
|
371
|
-
/>
|
|
372
|
-
<span
|
|
373
|
-
style={{
|
|
374
|
-
width: '300px',
|
|
375
|
-
height: '18px',
|
|
376
|
-
background: 'hsl(0, 0%, 50%)',
|
|
377
|
-
borderRadius: '16px'
|
|
652
|
+
borderRadius: 'var(--roundness-m, 12px)',
|
|
653
|
+
opacity: 0.35,
|
|
378
654
|
}}
|
|
379
655
|
/>
|
|
656
|
+
))}
|
|
657
|
+
</View>
|
|
658
|
+
)
|
|
659
|
+
: [1, 2, 3].map(n => (
|
|
660
|
+
<View.Item key={n}>
|
|
661
|
+
<div
|
|
662
|
+
className="inset-m cursor-pointer sans-serif d-flex align-center justify-between"
|
|
663
|
+
style={{ height: '56px', }}
|
|
664
|
+
>
|
|
665
|
+
<div className="d-flex align-center">
|
|
666
|
+
<span
|
|
667
|
+
className="inline-m"
|
|
668
|
+
style={{
|
|
669
|
+
width: '24px',
|
|
670
|
+
height: '24px',
|
|
671
|
+
flexShrink: 0,
|
|
672
|
+
background: 'hsl(0, 0%, 50%)',
|
|
673
|
+
borderRadius: '16px'
|
|
674
|
+
}}
|
|
675
|
+
/>
|
|
676
|
+
<span
|
|
677
|
+
style={{
|
|
678
|
+
width: '300px',
|
|
679
|
+
height: '18px',
|
|
680
|
+
background: 'hsl(0, 0%, 50%)',
|
|
681
|
+
borderRadius: '16px'
|
|
682
|
+
}}
|
|
683
|
+
/>
|
|
684
|
+
</div>
|
|
380
685
|
</div>
|
|
381
|
-
</
|
|
382
|
-
|
|
383
|
-
))}
|
|
686
|
+
</View.Item>
|
|
687
|
+
))}
|
|
384
688
|
</DelayedRender>
|
|
385
689
|
</Switch.Case>
|
|
386
690
|
|
|
387
691
|
<Switch.Case match={[ResourcesListStatus.Empty]}>
|
|
388
692
|
{isCreatingFolder
|
|
389
|
-
?
|
|
693
|
+
? (viewMode === ViewMode.Grid
|
|
694
|
+
? <ResourceGrid resources={[]} inlineFolder={inlineFolder} />
|
|
695
|
+
: <ResourceList resources={[]} inlineFolder={inlineFolder} />)
|
|
390
696
|
: (
|
|
391
697
|
<Guide
|
|
392
698
|
data-region="content"
|
|
@@ -401,7 +707,27 @@ export const ResourcesPage = () => {
|
|
|
401
707
|
</Switch.Case>
|
|
402
708
|
|
|
403
709
|
<Switch.Case match={[ResourcesListStatus.Success]}>
|
|
404
|
-
|
|
710
|
+
{viewMode === ViewMode.Grid
|
|
711
|
+
? (
|
|
712
|
+
<ResourceGrid
|
|
713
|
+
resources={filterResources}
|
|
714
|
+
inlineFolder={inlineFolder}
|
|
715
|
+
selectedIds={highlightedIds}
|
|
716
|
+
showSelectionControls={showSelectionControls}
|
|
717
|
+
onClick={handleResourceActivate}
|
|
718
|
+
onToggleSelect={handleToggleSelect}
|
|
719
|
+
/>
|
|
720
|
+
)
|
|
721
|
+
: (
|
|
722
|
+
<ResourceList
|
|
723
|
+
resources={filterResources}
|
|
724
|
+
inlineFolder={inlineFolder}
|
|
725
|
+
selectedIds={highlightedIds}
|
|
726
|
+
showSelectionControls={showSelectionControls}
|
|
727
|
+
onClick={handleResourceActivate}
|
|
728
|
+
onToggleSelect={handleToggleSelect}
|
|
729
|
+
/>
|
|
730
|
+
)}
|
|
405
731
|
</Switch.Case>
|
|
406
732
|
|
|
407
733
|
</Switch>
|
|
@@ -443,6 +769,29 @@ export const ResourcesPage = () => {
|
|
|
443
769
|
)
|
|
444
770
|
}
|
|
445
771
|
|
|
772
|
+
{
|
|
773
|
+
overlay === Overlays.RemoveBatch && (
|
|
774
|
+
<Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
|
|
775
|
+
<View layout="off-center-s" style={{ height: '100%' }}>
|
|
776
|
+
<View data-region="content">
|
|
777
|
+
<View surface="primary" roundness="s">
|
|
778
|
+
<View surface="primary" inset="l" roundness="s">
|
|
779
|
+
<Guide
|
|
780
|
+
title={t('storage.resources.removeSelectedTitle')}
|
|
781
|
+
text={t('storage.resources.removeSelectedText').replace('{count}', String(selectionCount))}
|
|
782
|
+
actions={[
|
|
783
|
+
{ label: t('storage.resources.cancel'), variant: 'command', onClick: () => setOverlay(Overlays.None) },
|
|
784
|
+
{ label: t('storage.resources.removeSelected'), variant: 'command-danger', onClick: handleBatchRemoveConfirm },
|
|
785
|
+
]}
|
|
786
|
+
/>
|
|
787
|
+
</View>
|
|
788
|
+
</View>
|
|
789
|
+
</View>
|
|
790
|
+
</View>
|
|
791
|
+
</Overlay>
|
|
792
|
+
)
|
|
793
|
+
}
|
|
794
|
+
|
|
446
795
|
{
|
|
447
796
|
overlay === Overlays.MoveResource && (
|
|
448
797
|
<Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
|
|
@@ -455,4 +804,3 @@ export const ResourcesPage = () => {
|
|
|
455
804
|
</>
|
|
456
805
|
)
|
|
457
806
|
}
|
|
458
|
-
|
package/src/en.translations.json
CHANGED
|
@@ -19,5 +19,20 @@
|
|
|
19
19
|
"storage.resources.cancel": "Cancel",
|
|
20
20
|
"storage.resources.remove": "Remove",
|
|
21
21
|
"storage.resources.move": "Move",
|
|
22
|
-
"storage.resources.
|
|
22
|
+
"storage.resources.download": "Download",
|
|
23
|
+
"storage.resources.downloadSelected": "Download selected",
|
|
24
|
+
"storage.resources.removeSelected": "Remove selected",
|
|
25
|
+
"storage.resources.removeSelectedTitle": "Remove selected",
|
|
26
|
+
"storage.resources.removeSelectedText": "Are you sure you want to remove {count} selected items? Folders and their contents will be deleted.",
|
|
27
|
+
"storage.resources.selectMode": "Select",
|
|
28
|
+
"storage.resources.selectModeActive": "Selecting",
|
|
29
|
+
"storage.resources.selectModeHint": "Tap items to select them",
|
|
30
|
+
"storage.resources.doneSelecting": "Done",
|
|
31
|
+
"storage.resources.clearSelection": "Clear selection",
|
|
32
|
+
"storage.resources.selectedOne": "1 selected",
|
|
33
|
+
"storage.resources.selectedMany": "{count} selected",
|
|
34
|
+
"storage.resources.contextRemove": "Remove",
|
|
35
|
+
"storage.resources.layout": "Layout",
|
|
36
|
+
"storage.resources.viewList": "List view",
|
|
37
|
+
"storage.resources.viewGrid": "Grid view"
|
|
23
38
|
}
|
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
|
@@ -19,5 +19,20 @@
|
|
|
19
19
|
"storage.resources.cancel": "Avbryt",
|
|
20
20
|
"storage.resources.remove": "Ta bort",
|
|
21
21
|
"storage.resources.move": "Flytta",
|
|
22
|
-
"storage.resources.
|
|
22
|
+
"storage.resources.download": "Ladda ner",
|
|
23
|
+
"storage.resources.downloadSelected": "Ladda ner markerade",
|
|
24
|
+
"storage.resources.removeSelected": "Ta bort markerade",
|
|
25
|
+
"storage.resources.removeSelectedTitle": "Ta bort markerade",
|
|
26
|
+
"storage.resources.removeSelectedText": "Är du säker på att du vill ta bort {count} markerade objekt? Mappar och deras innehåll tas bort.",
|
|
27
|
+
"storage.resources.selectMode": "Markera",
|
|
28
|
+
"storage.resources.selectModeActive": "Markerar",
|
|
29
|
+
"storage.resources.selectModeHint": "Tryck på objekt för att markera dem",
|
|
30
|
+
"storage.resources.doneSelecting": "Klar",
|
|
31
|
+
"storage.resources.clearSelection": "Rensa markering",
|
|
32
|
+
"storage.resources.selectedOne": "1 markerad",
|
|
33
|
+
"storage.resources.selectedMany": "{count} markerade",
|
|
34
|
+
"storage.resources.contextRemove": "Ta bort",
|
|
35
|
+
"storage.resources.layout": "Layout",
|
|
36
|
+
"storage.resources.viewList": "Listvy",
|
|
37
|
+
"storage.resources.viewGrid": "Rutnätsvy"
|
|
23
38
|
}
|