@ossy/storage 3.9.0 → 3.14.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 +339 -71
- package/src/en.translations.json +13 -1
- package/src/sv.translations.json +13 -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.
|
|
4
|
+
"version": "3.14.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": "539cc1b14a57e9f6472a89648939e21821dc204d"
|
|
34
34
|
}
|
package/src/ResourcesPage.jsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'
|
|
2
2
|
import {
|
|
3
|
-
ListResources,
|
|
4
3
|
applyResourceSelectionGesture,
|
|
5
4
|
createDirectory,
|
|
6
5
|
filterDownloadableResources,
|
|
@@ -12,6 +11,37 @@ import {
|
|
|
12
11
|
resourceDownloadHref,
|
|
13
12
|
triggerResourceDownloads,
|
|
14
13
|
uploadFile,
|
|
14
|
+
OpenShare,
|
|
15
|
+
OpenMove,
|
|
16
|
+
OpenDeleteDirectory,
|
|
17
|
+
OpenRemoveSelected,
|
|
18
|
+
DeleteResource,
|
|
19
|
+
DownloadResource,
|
|
20
|
+
DownloadSelected,
|
|
21
|
+
ToggleSelectionMode,
|
|
22
|
+
OpenSort,
|
|
23
|
+
SortByName,
|
|
24
|
+
SortByCreated,
|
|
25
|
+
SortByLastUpdated,
|
|
26
|
+
SortBySize,
|
|
27
|
+
SortByType,
|
|
28
|
+
SortAscending,
|
|
29
|
+
SortDescending,
|
|
30
|
+
OpenView,
|
|
31
|
+
ViewList,
|
|
32
|
+
ViewGrid,
|
|
33
|
+
DoneSelecting,
|
|
34
|
+
DEFAULT_RESOURCE_LIST_LIMIT,
|
|
35
|
+
resourceListQuerySearchString,
|
|
36
|
+
useActivePath,
|
|
37
|
+
useResourceList,
|
|
38
|
+
ResourcePanel,
|
|
39
|
+
ResourceList,
|
|
40
|
+
ResourceGrid,
|
|
41
|
+
ResourceDialogMove,
|
|
42
|
+
ResourceShareDialog,
|
|
43
|
+
useSelectedResourceId,
|
|
44
|
+
syncSelectedResources,
|
|
15
45
|
} from '@ossy/resources'
|
|
16
46
|
import { GetWorkspace } from '@ossy/workspaces'
|
|
17
47
|
import { AsyncStatus, useSdk } from '@ossy/sdk-react'
|
|
@@ -23,7 +53,6 @@ import {
|
|
|
23
53
|
last,
|
|
24
54
|
} from 'ramda'
|
|
25
55
|
import { Text, Overlay, Switch, DropZone, Breadcrumbs, Guide, DelayedRender, useDocumentTitle, View, Button, ContextMenu, Dropdown, Page, Tags, useLocale, preloadStorageIcons } from '@ossy/design-system'
|
|
26
|
-
import { useActivePath, ResourcePanel, ResourceList, ResourceGrid, ResourceDialogMove, ResourceShareDialog, useSelectedResourceId } from '@ossy/resources'
|
|
27
56
|
import { useRouter, useSearchParams } from '@ossy/router-react'
|
|
28
57
|
|
|
29
58
|
const Path = ({ path, ...props }) => (
|
|
@@ -42,7 +71,7 @@ const ResourcesListStatus = {
|
|
|
42
71
|
|
|
43
72
|
const Overlays = {
|
|
44
73
|
None: 'None',
|
|
45
|
-
|
|
74
|
+
RemoveDirectory: 'RemoveDirectory',
|
|
46
75
|
RemoveBatch: 'RemoveBatch',
|
|
47
76
|
MoveResource: 'MoveResource',
|
|
48
77
|
ShareResource: 'ShareResource',
|
|
@@ -53,6 +82,19 @@ const ViewMode = {
|
|
|
53
82
|
Grid: 'grid',
|
|
54
83
|
}
|
|
55
84
|
|
|
85
|
+
const SortBy = {
|
|
86
|
+
Name: 'name',
|
|
87
|
+
Created: 'created',
|
|
88
|
+
LastUpdated: 'lastUpdated',
|
|
89
|
+
Size: 'size',
|
|
90
|
+
Type: 'type',
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const SortOrder = {
|
|
94
|
+
Asc: 'asc',
|
|
95
|
+
Desc: 'desc',
|
|
96
|
+
}
|
|
97
|
+
|
|
56
98
|
export const ResourcesPage = () => {
|
|
57
99
|
const router = useRouter()
|
|
58
100
|
const searchParams = useSearchParams()
|
|
@@ -64,11 +106,14 @@ export const ResourcesPage = () => {
|
|
|
64
106
|
const [addMenuOpen, setAddMenuOpen] = useState(false)
|
|
65
107
|
const [addMenuPosition, setAddMenuPosition] = useState(null)
|
|
66
108
|
const [batchSelectedIds, setBatchSelectedIds] = useState(() => new Set())
|
|
109
|
+
const [selectedResourcesById, setSelectedResourcesById] = useState(() => new Map())
|
|
67
110
|
const [selectionAnchorId, setSelectionAnchorId] = useState(null)
|
|
68
111
|
const [selectionMode, setSelectionMode] = useState(false)
|
|
112
|
+
const [pendingDirectoryDeleteId, setPendingDirectoryDeleteId] = useState(null)
|
|
69
113
|
const { selectedResourceId, setSelectedResourceId, clearSelectedResourceId } = useSelectedResourceId()
|
|
70
114
|
const activePath = useActivePath()
|
|
71
115
|
const lastSuccessfulResourcesRef = useRef([])
|
|
116
|
+
const lastSuccessfulTotalRef = useRef(0)
|
|
72
117
|
|
|
73
118
|
useEffect(() => {
|
|
74
119
|
preloadStorageIcons()
|
|
@@ -76,30 +121,49 @@ export const ResourcesPage = () => {
|
|
|
76
121
|
|
|
77
122
|
useEffect(() => {
|
|
78
123
|
setBatchSelectedIds(new Set())
|
|
124
|
+
setSelectedResourcesById(new Map())
|
|
79
125
|
setSelectionAnchorId(null)
|
|
80
126
|
setSelectionMode(false)
|
|
81
127
|
}, [activePath])
|
|
82
128
|
|
|
83
129
|
const {
|
|
130
|
+
items: resourceItems = [],
|
|
131
|
+
total: resourceTotal = 0,
|
|
84
132
|
status: resourcesStatus,
|
|
85
|
-
|
|
86
|
-
|
|
133
|
+
pageIndex: safePageIndex,
|
|
134
|
+
pageCount,
|
|
135
|
+
sortBy,
|
|
136
|
+
sortOrder,
|
|
137
|
+
setSort,
|
|
138
|
+
setPage,
|
|
139
|
+
hasPreviousPage,
|
|
140
|
+
hasNextPage,
|
|
141
|
+
limit: pageLimit,
|
|
142
|
+
} = useResourceList({
|
|
143
|
+
location: activePath,
|
|
144
|
+
limit: DEFAULT_RESOURCE_LIST_LIMIT,
|
|
145
|
+
initialSortBy: SortBy.Name,
|
|
146
|
+
initialSortOrder: SortOrder.Asc,
|
|
147
|
+
})
|
|
87
148
|
|
|
88
149
|
if (resourcesStatus === AsyncStatus.Success) {
|
|
89
|
-
lastSuccessfulResourcesRef.current =
|
|
150
|
+
lastSuccessfulResourcesRef.current = resourceItems
|
|
151
|
+
lastSuccessfulTotalRef.current = resourceTotal
|
|
90
152
|
}
|
|
91
153
|
|
|
92
154
|
const displayResources =
|
|
93
|
-
resourcesStatus === AsyncStatus.Success ?
|
|
155
|
+
resourcesStatus === AsyncStatus.Success ? resourceItems : lastSuccessfulResourcesRef.current
|
|
156
|
+
const displayTotal =
|
|
157
|
+
resourcesStatus === AsyncStatus.Success ? resourceTotal : lastSuccessfulTotalRef.current
|
|
94
158
|
|
|
95
159
|
const resourcesListStatus = useMemo(() => {
|
|
96
160
|
if (resourcesStatus === AsyncStatus.Error) return ResourcesListStatus.Error
|
|
97
161
|
if (resourcesStatus === AsyncStatus.Success) {
|
|
98
|
-
return
|
|
162
|
+
return resourceTotal === 0 ? ResourcesListStatus.Empty : ResourcesListStatus.Success
|
|
99
163
|
}
|
|
100
|
-
if (displayResources.length > 0) return ResourcesListStatus.Success
|
|
164
|
+
if (displayResources.length > 0 || displayTotal > 0) return ResourcesListStatus.Success
|
|
101
165
|
return ResourcesListStatus.Loading
|
|
102
|
-
}, [resourcesStatus,
|
|
166
|
+
}, [resourcesStatus, resourceTotal, displayResources.length, displayTotal])
|
|
103
167
|
|
|
104
168
|
const [isCreatingFolder, setIsCreatingFolder] = useState(false)
|
|
105
169
|
const [newFolderName, setNewFolderName] = useState(() => t('storage.resources.newFolderDefault'))
|
|
@@ -131,16 +195,27 @@ export const ResourcesPage = () => {
|
|
|
131
195
|
const storageHomeHref = useCallback((locationQuery = '') => {
|
|
132
196
|
const parts = []
|
|
133
197
|
if (locationQuery) parts.push(locationQuery)
|
|
198
|
+
const listQuery = resourceListQuerySearchString({
|
|
199
|
+
pageIndex: 0,
|
|
200
|
+
sortBy,
|
|
201
|
+
sortOrder,
|
|
202
|
+
})
|
|
203
|
+
if (listQuery) parts.push(listQuery)
|
|
134
204
|
if (selectedResourceId) parts.push(`r=${selectedResourceId}`)
|
|
135
205
|
const search = parts.length ? `?${parts.join('&')}` : ''
|
|
136
206
|
return router.getHref(`@storage/home${search}`)
|
|
137
|
-
}, [router, selectedResourceId])
|
|
207
|
+
}, [router, selectedResourceId, sortBy, sortOrder])
|
|
138
208
|
|
|
139
209
|
const navigateToLocation = useCallback((locationPath) => {
|
|
140
210
|
const normalized = locationPath.startsWith('/') ? locationPath : `/${locationPath}`
|
|
141
211
|
const withSlash = normalized.endsWith('/') ? normalized : `${normalized}/`
|
|
212
|
+
if (typeof searchParams.patch === 'function') {
|
|
213
|
+
searchParams.patch({ location: withSlash, page: null })
|
|
214
|
+
return
|
|
215
|
+
}
|
|
142
216
|
searchParams.set('location', withSlash)
|
|
143
|
-
|
|
217
|
+
searchParams.delete('page')
|
|
218
|
+
}, [searchParams.patch, searchParams.set, searchParams.delete])
|
|
144
219
|
|
|
145
220
|
const openLocation = useCallback((locationPath) => (event) => {
|
|
146
221
|
if (event?.metaKey || event?.ctrlKey || event?.shiftKey || event?.button === 1) return
|
|
@@ -164,21 +239,27 @@ export const ResourcesPage = () => {
|
|
|
164
239
|
}, [sdk])
|
|
165
240
|
|
|
166
241
|
const onRemoveResource = resource => {
|
|
167
|
-
setSelectedResourceId(resource.id)
|
|
168
|
-
|
|
169
242
|
if (resource.type === '@ossy/platform/schema/directory' || resource.type === 'directory') {
|
|
243
|
+
setPendingDirectoryDeleteId(resource.id)
|
|
170
244
|
setOverlay(Overlays.RemoveDirectory)
|
|
171
|
-
|
|
172
|
-
removeResource(sdk, resource.id, resource.location)
|
|
245
|
+
return
|
|
173
246
|
}
|
|
174
247
|
|
|
248
|
+
setSelectedResourceId(resource.id)
|
|
249
|
+
removeResource(sdk, resource.id, resource.location)
|
|
175
250
|
}
|
|
176
251
|
|
|
177
252
|
const clearBatchSelection = useCallback(() => {
|
|
178
253
|
setBatchSelectedIds(new Set())
|
|
254
|
+
setSelectedResourcesById(new Map())
|
|
179
255
|
setSelectionAnchorId(null)
|
|
180
256
|
}, [])
|
|
181
257
|
|
|
258
|
+
const applyBatchSelection = useCallback((nextSelectedIds, knownResources) => {
|
|
259
|
+
setBatchSelectedIds(nextSelectedIds)
|
|
260
|
+
setSelectedResourcesById((prev) => syncSelectedResources(nextSelectedIds, prev, knownResources))
|
|
261
|
+
}, [])
|
|
262
|
+
|
|
182
263
|
const exitSelectionMode = useCallback(() => {
|
|
183
264
|
setSelectionMode(false)
|
|
184
265
|
clearBatchSelection()
|
|
@@ -262,7 +343,7 @@ export const ResourcesPage = () => {
|
|
|
262
343
|
)(activePath)
|
|
263
344
|
|
|
264
345
|
const filterResources = useMemo(() => displayResources
|
|
265
|
-
//
|
|
346
|
+
// System folders (@ossy/…) stay out of the storage UI.
|
|
266
347
|
.filter(resource => !resource?.name?.startsWith?.('@ossy'))
|
|
267
348
|
.map(resource => {
|
|
268
349
|
|
|
@@ -288,9 +369,11 @@ export const ResourcesPage = () => {
|
|
|
288
369
|
</ContextMenu.Item>,
|
|
289
370
|
<ContextMenu.Separator key="separator"></ContextMenu.Separator>,
|
|
290
371
|
<ContextMenu.Item
|
|
372
|
+
{...OpenDeleteDirectory}
|
|
291
373
|
variant="command-danger"
|
|
292
374
|
prefix="trash-empty"
|
|
293
375
|
key="remove"
|
|
376
|
+
label={undefined}
|
|
294
377
|
onClick={() => onRemoveResource(resource)}
|
|
295
378
|
>{t('storage.resources.contextRemove')}
|
|
296
379
|
</ContextMenu.Item>
|
|
@@ -320,6 +403,7 @@ export const ResourcesPage = () => {
|
|
|
320
403
|
...(isShareableResource(resource)
|
|
321
404
|
? [
|
|
322
405
|
<ContextMenu.Item
|
|
406
|
+
{...OpenShare}
|
|
323
407
|
key="share"
|
|
324
408
|
prefix="share"
|
|
325
409
|
onClick={() => {
|
|
@@ -334,6 +418,7 @@ export const ResourcesPage = () => {
|
|
|
334
418
|
...(downloadHref
|
|
335
419
|
? [
|
|
336
420
|
<ContextMenu.Item
|
|
421
|
+
{...DownloadResource}
|
|
337
422
|
key="download"
|
|
338
423
|
prefix="software-download"
|
|
339
424
|
href={downloadHref}
|
|
@@ -344,6 +429,7 @@ export const ResourcesPage = () => {
|
|
|
344
429
|
]
|
|
345
430
|
: []),
|
|
346
431
|
<ContextMenu.Item
|
|
432
|
+
{...OpenMove}
|
|
347
433
|
key="move"
|
|
348
434
|
prefix="details-more"
|
|
349
435
|
onClick={() => {
|
|
@@ -364,17 +450,14 @@ export const ResourcesPage = () => {
|
|
|
364
450
|
]
|
|
365
451
|
}
|
|
366
452
|
|
|
367
|
-
})
|
|
368
|
-
.sort((a, b) => {
|
|
369
|
-
const aDir = a.type === '@ossy/platform/schema/directory' || a.type === 'directory'
|
|
370
|
-
const bDir = b.type === '@ossy/platform/schema/directory' || b.type === 'directory'
|
|
371
|
-
if (aDir && !bDir) return -1
|
|
372
|
-
if (!aDir && bDir) return 1
|
|
373
453
|
}), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onUploadFiles, onRemoveResource, setSelectedResourceId, t])
|
|
374
454
|
|
|
455
|
+
// Server already sorted + paginated.
|
|
456
|
+
const visibleResources = filterResources
|
|
457
|
+
|
|
375
458
|
const orderedResourceIds = useMemo(
|
|
376
|
-
() =>
|
|
377
|
-
[
|
|
459
|
+
() => visibleResources.map((resource) => resource.id).filter(Boolean),
|
|
460
|
+
[visibleResources],
|
|
378
461
|
)
|
|
379
462
|
|
|
380
463
|
const highlightedIds = useMemo(() => {
|
|
@@ -382,17 +465,17 @@ export const ResourcesPage = () => {
|
|
|
382
465
|
return selectedResourceId ? new Set([selectedResourceId]) : new Set()
|
|
383
466
|
}, [batchSelectedIds, selectedResourceId])
|
|
384
467
|
|
|
385
|
-
const selectedDownloadableResources = useMemo(() => {
|
|
386
|
-
if (batchSelectedIds.size === 0) return []
|
|
387
|
-
return filterDownloadableResources(
|
|
388
|
-
filterResources.filter((resource) => batchSelectedIds.has(resource.id)),
|
|
389
|
-
)
|
|
390
|
-
}, [batchSelectedIds, filterResources])
|
|
391
|
-
|
|
392
468
|
const selectedBatchResources = useMemo(() => {
|
|
393
469
|
if (batchSelectedIds.size === 0) return []
|
|
394
|
-
return
|
|
395
|
-
|
|
470
|
+
return [...batchSelectedIds]
|
|
471
|
+
.map((id) => selectedResourcesById.get(id))
|
|
472
|
+
.filter(Boolean)
|
|
473
|
+
}, [batchSelectedIds, selectedResourcesById])
|
|
474
|
+
|
|
475
|
+
const selectedDownloadableResources = useMemo(
|
|
476
|
+
() => filterDownloadableResources(selectedBatchResources),
|
|
477
|
+
[selectedBatchResources],
|
|
478
|
+
)
|
|
396
479
|
|
|
397
480
|
const handleResourceActivate = useCallback((resource, event) => {
|
|
398
481
|
if (!resource?.id) return
|
|
@@ -409,7 +492,7 @@ export const ResourcesPage = () => {
|
|
|
409
492
|
event: gestureEvent,
|
|
410
493
|
anchorId: selectionAnchorId,
|
|
411
494
|
})
|
|
412
|
-
|
|
495
|
+
applyBatchSelection(nextSelectedIds, displayResources)
|
|
413
496
|
setSelectionAnchorId(nextAnchorId)
|
|
414
497
|
if (!selectionMode) setSelectionMode(true)
|
|
415
498
|
clearSelectedResourceId()
|
|
@@ -422,6 +505,8 @@ export const ResourcesPage = () => {
|
|
|
422
505
|
batchSelectedIds,
|
|
423
506
|
orderedResourceIds,
|
|
424
507
|
selectionAnchorId,
|
|
508
|
+
displayResources,
|
|
509
|
+
applyBatchSelection,
|
|
425
510
|
clearSelectedResourceId,
|
|
426
511
|
clearBatchSelection,
|
|
427
512
|
])
|
|
@@ -436,7 +521,7 @@ export const ResourcesPage = () => {
|
|
|
436
521
|
event: { metaKey: true },
|
|
437
522
|
anchorId: selectionAnchorId,
|
|
438
523
|
})
|
|
439
|
-
|
|
524
|
+
applyBatchSelection(nextSelectedIds, displayResources)
|
|
440
525
|
setSelectionAnchorId(nextAnchorId)
|
|
441
526
|
clearSelectedResourceId()
|
|
442
527
|
}, [
|
|
@@ -444,6 +529,8 @@ export const ResourcesPage = () => {
|
|
|
444
529
|
batchSelectedIds,
|
|
445
530
|
orderedResourceIds,
|
|
446
531
|
selectionAnchorId,
|
|
532
|
+
displayResources,
|
|
533
|
+
applyBatchSelection,
|
|
447
534
|
clearSelectedResourceId,
|
|
448
535
|
])
|
|
449
536
|
|
|
@@ -503,9 +590,34 @@ export const ResourcesPage = () => {
|
|
|
503
590
|
}}
|
|
504
591
|
>
|
|
505
592
|
|
|
506
|
-
<View
|
|
507
|
-
|
|
508
|
-
|
|
593
|
+
<View
|
|
594
|
+
data-storage-list-panel=""
|
|
595
|
+
data-storage-has-panel={selectedResourceId ? 'true' : 'false'}
|
|
596
|
+
stack
|
|
597
|
+
horizontal
|
|
598
|
+
gap="xs"
|
|
599
|
+
style={{ height: '100%', minHeight: 0, flex: '1 1 auto' }}
|
|
600
|
+
>
|
|
601
|
+
{/* Match ListPanelLayout compact: panel replaces list under 900px. */}
|
|
602
|
+
<style href="@ossy/storage/list-panel-compact" precedence="medium">{`
|
|
603
|
+
@media (max-width: 900px) {
|
|
604
|
+
[data-storage-list-panel][data-storage-has-panel="true"] > [data-storage-list] {
|
|
605
|
+
display: none;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
[data-storage-list-panel][data-storage-has-panel="true"] > [data-resource-panel] {
|
|
609
|
+
width: 100% !important;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
`}</style>
|
|
613
|
+
|
|
614
|
+
<View.Item
|
|
615
|
+
data-storage-list=""
|
|
616
|
+
fill
|
|
617
|
+
surface="primary"
|
|
618
|
+
roundness="xs"
|
|
619
|
+
style={{ minHeight: 0, minWidth: 0 }}
|
|
620
|
+
>
|
|
509
621
|
<View stack bordered style={{ height: '100%', minHeight: 0 }}>
|
|
510
622
|
|
|
511
623
|
<View.Item
|
|
@@ -523,11 +635,13 @@ export const ResourcesPage = () => {
|
|
|
523
635
|
|
|
524
636
|
<View layout="row" gap="s" alignItems="center" style={{ minWidth: 0, flex: 1 }}>
|
|
525
637
|
<Button
|
|
638
|
+
{...ToggleSelectionMode}
|
|
526
639
|
prefix="check-r"
|
|
527
640
|
variant="command"
|
|
528
641
|
aria-label={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
|
|
529
642
|
aria-pressed={selectionMode}
|
|
530
643
|
title={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
|
|
644
|
+
data-selection-mode={selectionMode ? 'on' : 'off'}
|
|
531
645
|
onClick={toggleSelectionMode}
|
|
532
646
|
style={{
|
|
533
647
|
height: '32px',
|
|
@@ -562,6 +676,74 @@ export const ResourcesPage = () => {
|
|
|
562
676
|
<Dropdown
|
|
563
677
|
trigger={(
|
|
564
678
|
<Button
|
|
679
|
+
{...OpenSort}
|
|
680
|
+
prefix={sortOrder === SortOrder.Desc ? 'sort-za' : 'sort-az'}
|
|
681
|
+
variant="command"
|
|
682
|
+
aria-label={t('storage.resources.sort')}
|
|
683
|
+
title={t('storage.resources.sort')}
|
|
684
|
+
style={{ height: '32px' }}
|
|
685
|
+
/>
|
|
686
|
+
)}
|
|
687
|
+
>
|
|
688
|
+
<View inset="xs" surface="primary" roundness="s">
|
|
689
|
+
<ContextMenu roundness="s" surface="primary">
|
|
690
|
+
<ContextMenu.Item
|
|
691
|
+
{...SortByName}
|
|
692
|
+
suffix={sortBy === SortBy.Name ? 'check' : undefined}
|
|
693
|
+
onClick={() => setSort(SortBy.Name, sortOrder)}
|
|
694
|
+
>
|
|
695
|
+
{t('storage.resources.sortByName')}
|
|
696
|
+
</ContextMenu.Item>
|
|
697
|
+
<ContextMenu.Item
|
|
698
|
+
{...SortByCreated}
|
|
699
|
+
suffix={sortBy === SortBy.Created ? 'check' : undefined}
|
|
700
|
+
onClick={() => setSort(SortBy.Created, sortOrder)}
|
|
701
|
+
>
|
|
702
|
+
{t('storage.resources.sortByCreated')}
|
|
703
|
+
</ContextMenu.Item>
|
|
704
|
+
<ContextMenu.Item
|
|
705
|
+
{...SortByLastUpdated}
|
|
706
|
+
suffix={sortBy === SortBy.LastUpdated ? 'check' : undefined}
|
|
707
|
+
onClick={() => setSort(SortBy.LastUpdated, sortOrder)}
|
|
708
|
+
>
|
|
709
|
+
{t('storage.resources.sortByUpdated')}
|
|
710
|
+
</ContextMenu.Item>
|
|
711
|
+
<ContextMenu.Item
|
|
712
|
+
{...SortBySize}
|
|
713
|
+
suffix={sortBy === SortBy.Size ? 'check' : undefined}
|
|
714
|
+
onClick={() => setSort(SortBy.Size, sortOrder)}
|
|
715
|
+
>
|
|
716
|
+
{t('storage.resources.sortBySize')}
|
|
717
|
+
</ContextMenu.Item>
|
|
718
|
+
<ContextMenu.Item
|
|
719
|
+
{...SortByType}
|
|
720
|
+
suffix={sortBy === SortBy.Type ? 'check' : undefined}
|
|
721
|
+
onClick={() => setSort(SortBy.Type, sortOrder)}
|
|
722
|
+
>
|
|
723
|
+
{t('storage.resources.sortByType')}
|
|
724
|
+
</ContextMenu.Item>
|
|
725
|
+
<ContextMenu.Separator />
|
|
726
|
+
<ContextMenu.Item
|
|
727
|
+
{...SortAscending}
|
|
728
|
+
suffix={sortOrder === SortOrder.Asc ? 'check' : undefined}
|
|
729
|
+
onClick={() => setSort(sortBy, SortOrder.Asc)}
|
|
730
|
+
>
|
|
731
|
+
{t('storage.resources.sortAscending')}
|
|
732
|
+
</ContextMenu.Item>
|
|
733
|
+
<ContextMenu.Item
|
|
734
|
+
{...SortDescending}
|
|
735
|
+
suffix={sortOrder === SortOrder.Desc ? 'check' : undefined}
|
|
736
|
+
onClick={() => setSort(sortBy, SortOrder.Desc)}
|
|
737
|
+
>
|
|
738
|
+
{t('storage.resources.sortDescending')}
|
|
739
|
+
</ContextMenu.Item>
|
|
740
|
+
</ContextMenu>
|
|
741
|
+
</View>
|
|
742
|
+
</Dropdown>
|
|
743
|
+
<Dropdown
|
|
744
|
+
trigger={(
|
|
745
|
+
<Button
|
|
746
|
+
{...OpenView}
|
|
565
747
|
prefix={viewMode === ViewMode.Grid ? 'layout-grid' : 'layout-list'}
|
|
566
748
|
variant="command"
|
|
567
749
|
aria-label={t('storage.resources.layout')}
|
|
@@ -572,6 +754,7 @@ export const ResourcesPage = () => {
|
|
|
572
754
|
<View inset="xs" surface="primary" roundness="s">
|
|
573
755
|
<ContextMenu roundness="s" surface="primary">
|
|
574
756
|
<ContextMenu.Item
|
|
757
|
+
{...ViewList}
|
|
575
758
|
prefix="layout-list"
|
|
576
759
|
suffix={viewMode === ViewMode.List ? 'check' : undefined}
|
|
577
760
|
onClick={() => setViewMode(ViewMode.List)}
|
|
@@ -579,6 +762,7 @@ export const ResourcesPage = () => {
|
|
|
579
762
|
{t('storage.resources.viewList')}
|
|
580
763
|
</ContextMenu.Item>
|
|
581
764
|
<ContextMenu.Item
|
|
765
|
+
{...ViewGrid}
|
|
582
766
|
prefix="layout-grid"
|
|
583
767
|
suffix={viewMode === ViewMode.Grid ? 'check' : undefined}
|
|
584
768
|
onClick={() => setViewMode(ViewMode.Grid)}
|
|
@@ -611,6 +795,7 @@ export const ResourcesPage = () => {
|
|
|
611
795
|
{selectionMode && (
|
|
612
796
|
<View.Item
|
|
613
797
|
data-surface="primary"
|
|
798
|
+
data-selection-mode="on"
|
|
614
799
|
layout="row"
|
|
615
800
|
style={{
|
|
616
801
|
alignItems: 'center',
|
|
@@ -627,6 +812,7 @@ export const ResourcesPage = () => {
|
|
|
627
812
|
</Text>
|
|
628
813
|
<View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
|
|
629
814
|
<Button
|
|
815
|
+
{...DownloadSelected}
|
|
630
816
|
prefix="software-download"
|
|
631
817
|
variant="command"
|
|
632
818
|
disabled={selectedDownloadableResources.length === 0}
|
|
@@ -636,6 +822,7 @@ export const ResourcesPage = () => {
|
|
|
636
822
|
{t('storage.resources.downloadSelected')}
|
|
637
823
|
</Button>
|
|
638
824
|
<Button
|
|
825
|
+
{...OpenRemoveSelected}
|
|
639
826
|
prefix="trash-empty"
|
|
640
827
|
variant="command-danger"
|
|
641
828
|
disabled={selectedBatchResources.length === 0}
|
|
@@ -645,6 +832,7 @@ export const ResourcesPage = () => {
|
|
|
645
832
|
{t('storage.resources.removeSelected')}
|
|
646
833
|
</Button>
|
|
647
834
|
<Button
|
|
835
|
+
{...DoneSelecting}
|
|
648
836
|
variant="command"
|
|
649
837
|
onClick={exitSelectionMode}
|
|
650
838
|
style={{ height: '32px' }}
|
|
@@ -655,7 +843,14 @@ export const ResourcesPage = () => {
|
|
|
655
843
|
</View.Item>
|
|
656
844
|
)}
|
|
657
845
|
|
|
658
|
-
<View.Item
|
|
846
|
+
<View.Item
|
|
847
|
+
fill
|
|
848
|
+
data-scrollbar="hide"
|
|
849
|
+
data-view-mode={viewMode}
|
|
850
|
+
data-sort-by={sortBy}
|
|
851
|
+
data-sort-order={sortOrder}
|
|
852
|
+
style={{ overflowY: 'auto', minHeight: 0 }}
|
|
853
|
+
>
|
|
659
854
|
<DropZone onFilesDrop={onUploadFiles(activePath)}>
|
|
660
855
|
<View style={{ minHeight: '100%' }} onContextMenu={handleDropZoneContextMenu}>
|
|
661
856
|
<Switch on={resourcesListStatus}>
|
|
@@ -741,27 +936,27 @@ export const ResourcesPage = () => {
|
|
|
741
936
|
</Switch.Case>
|
|
742
937
|
|
|
743
938
|
<Switch.Case match={[ResourcesListStatus.Success]}>
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
939
|
+
{viewMode === ViewMode.Grid
|
|
940
|
+
? (
|
|
941
|
+
<ResourceGrid
|
|
942
|
+
resources={visibleResources}
|
|
943
|
+
inlineFolder={inlineFolder}
|
|
944
|
+
selectedIds={highlightedIds}
|
|
945
|
+
showSelectionControls={showSelectionControls}
|
|
946
|
+
onClick={handleResourceActivate}
|
|
947
|
+
onToggleSelect={handleToggleSelect}
|
|
948
|
+
/>
|
|
949
|
+
)
|
|
950
|
+
: (
|
|
951
|
+
<ResourceList
|
|
952
|
+
resources={visibleResources}
|
|
953
|
+
inlineFolder={inlineFolder}
|
|
954
|
+
selectedIds={highlightedIds}
|
|
955
|
+
showSelectionControls={showSelectionControls}
|
|
956
|
+
onClick={handleResourceActivate}
|
|
957
|
+
onToggleSelect={handleToggleSelect}
|
|
958
|
+
/>
|
|
959
|
+
)}
|
|
765
960
|
</Switch.Case>
|
|
766
961
|
|
|
767
962
|
</Switch>
|
|
@@ -769,6 +964,54 @@ export const ResourcesPage = () => {
|
|
|
769
964
|
</DropZone>
|
|
770
965
|
</View.Item>
|
|
771
966
|
|
|
967
|
+
{resourcesListStatus === ResourcesListStatus.Success && displayTotal > pageLimit && (
|
|
968
|
+
<View.Item
|
|
969
|
+
data-surface="primary"
|
|
970
|
+
layout="row"
|
|
971
|
+
style={{
|
|
972
|
+
alignItems: 'center',
|
|
973
|
+
justifyContent: 'space-between',
|
|
974
|
+
padding: 'var(--space-xs) var(--space-m)',
|
|
975
|
+
gap: 'var(--space-m)',
|
|
976
|
+
minHeight: '40px',
|
|
977
|
+
flexShrink: 0,
|
|
978
|
+
borderTop: '1px solid var(--separator-primary)',
|
|
979
|
+
}}
|
|
980
|
+
>
|
|
981
|
+
<Text variant="small">
|
|
982
|
+
{t('storage.resources.paginationLabel', {
|
|
983
|
+
from: safePageIndex * pageLimit + 1,
|
|
984
|
+
to: Math.min((safePageIndex + 1) * pageLimit, displayTotal),
|
|
985
|
+
total: displayTotal,
|
|
986
|
+
})}
|
|
987
|
+
</Text>
|
|
988
|
+
<View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
|
|
989
|
+
<Button
|
|
990
|
+
prefix="arrow-left"
|
|
991
|
+
variant="command"
|
|
992
|
+
aria-label={t('storage.resources.paginationPrevious')}
|
|
993
|
+
disabled={!hasPreviousPage}
|
|
994
|
+
onClick={() => setPage(safePageIndex - 1)}
|
|
995
|
+
style={{ height: '32px' }}
|
|
996
|
+
/>
|
|
997
|
+
<Text variant="small">
|
|
998
|
+
{t('storage.resources.paginationPage', {
|
|
999
|
+
page: safePageIndex + 1,
|
|
1000
|
+
pages: pageCount,
|
|
1001
|
+
})}
|
|
1002
|
+
</Text>
|
|
1003
|
+
<Button
|
|
1004
|
+
prefix="arrow-right"
|
|
1005
|
+
variant="command"
|
|
1006
|
+
aria-label={t('storage.resources.paginationNext')}
|
|
1007
|
+
disabled={!hasNextPage}
|
|
1008
|
+
onClick={() => setPage(safePageIndex + 1)}
|
|
1009
|
+
style={{ height: '32px' }}
|
|
1010
|
+
/>
|
|
1011
|
+
</View>
|
|
1012
|
+
</View.Item>
|
|
1013
|
+
)}
|
|
1014
|
+
|
|
772
1015
|
</View>
|
|
773
1016
|
</View.Item>
|
|
774
1017
|
|
|
@@ -779,7 +1022,10 @@ export const ResourcesPage = () => {
|
|
|
779
1022
|
|
|
780
1023
|
{
|
|
781
1024
|
overlay === Overlays.RemoveDirectory && (
|
|
782
|
-
<Overlay isVisible={true} onClose={() =>
|
|
1025
|
+
<Overlay isVisible={true} onClose={() => {
|
|
1026
|
+
setPendingDirectoryDeleteId(null)
|
|
1027
|
+
setOverlay(Overlays.None)
|
|
1028
|
+
}}>
|
|
783
1029
|
<View layout="off-center-s" style={{ height: '100%' }}>
|
|
784
1030
|
<View data-region="content">
|
|
785
1031
|
<View surface="primary" roundness="s">
|
|
@@ -788,11 +1034,26 @@ export const ResourcesPage = () => {
|
|
|
788
1034
|
title={t('storage.resources.removeDirectoryTitle')}
|
|
789
1035
|
text={t('storage.resources.removeDirectoryText')}
|
|
790
1036
|
actions={[
|
|
791
|
-
{
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
1037
|
+
{
|
|
1038
|
+
label: t('storage.resources.cancel'),
|
|
1039
|
+
variant: "command",
|
|
1040
|
+
onClick: () => {
|
|
1041
|
+
setPendingDirectoryDeleteId(null)
|
|
1042
|
+
setOverlay(Overlays.None)
|
|
1043
|
+
},
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
...DeleteResource,
|
|
1047
|
+
label: 'storage.resources.remove',
|
|
1048
|
+
variant: 'command-danger',
|
|
1049
|
+
onClick: () => {
|
|
1050
|
+
if (pendingDirectoryDeleteId) {
|
|
1051
|
+
removeResource(sdk, pendingDirectoryDeleteId, activePath)
|
|
1052
|
+
}
|
|
1053
|
+
setPendingDirectoryDeleteId(null)
|
|
1054
|
+
setOverlay(Overlays.None)
|
|
1055
|
+
},
|
|
1056
|
+
},
|
|
796
1057
|
]}
|
|
797
1058
|
/>
|
|
798
1059
|
</View>
|
|
@@ -815,7 +1076,12 @@ export const ResourcesPage = () => {
|
|
|
815
1076
|
text={t('storage.resources.removeSelectedText').replace('{count}', String(selectionCount))}
|
|
816
1077
|
actions={[
|
|
817
1078
|
{ label: t('storage.resources.cancel'), variant: 'command', onClick: () => setOverlay(Overlays.None) },
|
|
818
|
-
{
|
|
1079
|
+
{
|
|
1080
|
+
...DeleteResource,
|
|
1081
|
+
label: 'storage.resources.removeSelected',
|
|
1082
|
+
variant: 'command-danger',
|
|
1083
|
+
onClick: handleBatchRemoveConfirm,
|
|
1084
|
+
},
|
|
819
1085
|
]}
|
|
820
1086
|
/>
|
|
821
1087
|
</View>
|
|
@@ -828,9 +1094,11 @@ export const ResourcesPage = () => {
|
|
|
828
1094
|
|
|
829
1095
|
{
|
|
830
1096
|
overlay === Overlays.MoveResource && (
|
|
831
|
-
<
|
|
832
|
-
|
|
833
|
-
|
|
1097
|
+
<ResourceDialogMove
|
|
1098
|
+
isVisible={true}
|
|
1099
|
+
onClose={() => setOverlay(Overlays.None)}
|
|
1100
|
+
resourceId={selectedResourceId}
|
|
1101
|
+
/>
|
|
834
1102
|
)
|
|
835
1103
|
}
|
|
836
1104
|
|
package/src/en.translations.json
CHANGED
|
@@ -36,5 +36,17 @@
|
|
|
36
36
|
"storage.resources.contextRemove": "Remove",
|
|
37
37
|
"storage.resources.layout": "Layout",
|
|
38
38
|
"storage.resources.viewList": "List view",
|
|
39
|
-
"storage.resources.viewGrid": "Grid view"
|
|
39
|
+
"storage.resources.viewGrid": "Grid view",
|
|
40
|
+
"storage.resources.sort": "Sort",
|
|
41
|
+
"storage.resources.sortByName": "Name",
|
|
42
|
+
"storage.resources.sortByCreated": "Date created",
|
|
43
|
+
"storage.resources.sortByUpdated": "Date updated",
|
|
44
|
+
"storage.resources.sortBySize": "Size",
|
|
45
|
+
"storage.resources.sortByType": "Type",
|
|
46
|
+
"storage.resources.sortAscending": "Ascending",
|
|
47
|
+
"storage.resources.sortDescending": "Descending",
|
|
48
|
+
"storage.resources.paginationLabel": "{from}–{to} of {total}",
|
|
49
|
+
"storage.resources.paginationPage": "Page {page} of {pages}",
|
|
50
|
+
"storage.resources.paginationPrevious": "Previous page",
|
|
51
|
+
"storage.resources.paginationNext": "Next page"
|
|
40
52
|
}
|
package/src/sv.translations.json
CHANGED
|
@@ -36,5 +36,17 @@
|
|
|
36
36
|
"storage.resources.contextRemove": "Ta bort",
|
|
37
37
|
"storage.resources.layout": "Layout",
|
|
38
38
|
"storage.resources.viewList": "Listvy",
|
|
39
|
-
"storage.resources.viewGrid": "Rutnätsvy"
|
|
39
|
+
"storage.resources.viewGrid": "Rutnätsvy",
|
|
40
|
+
"storage.resources.sort": "Sortera",
|
|
41
|
+
"storage.resources.sortByName": "Namn",
|
|
42
|
+
"storage.resources.sortByCreated": "Skapad",
|
|
43
|
+
"storage.resources.sortByUpdated": "Uppdaterad",
|
|
44
|
+
"storage.resources.sortBySize": "Storlek",
|
|
45
|
+
"storage.resources.sortByType": "Typ",
|
|
46
|
+
"storage.resources.sortAscending": "Stigande",
|
|
47
|
+
"storage.resources.sortDescending": "Fallande",
|
|
48
|
+
"storage.resources.paginationLabel": "{from}–{to} av {total}",
|
|
49
|
+
"storage.resources.paginationPage": "Sida {page} av {pages}",
|
|
50
|
+
"storage.resources.paginationPrevious": "Föregående sida",
|
|
51
|
+
"storage.resources.paginationNext": "Nästa sida"
|
|
40
52
|
}
|