@ossy/storage 3.9.0 → 3.11.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 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.9.0",
4
+ "version": "3.11.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": "f404be69becb27a1fd853a6ff1903554e76e7d17"
33
+ "gitHead": "53ff8456920e09151c9d88df4a6c3ee958d811eb"
34
34
  }
@@ -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
- Removedirectory : 'RemoveDirectory',
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
- data: resources = [],
86
- } = sdk.read(ListResources, { location: activePath })
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 = resources
150
+ lastSuccessfulResourcesRef.current = resourceItems
151
+ lastSuccessfulTotalRef.current = resourceTotal
90
152
  }
91
153
 
92
154
  const displayResources =
93
- resourcesStatus === AsyncStatus.Success ? resources : lastSuccessfulResourcesRef.current
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 resources.length === 0 ? ResourcesListStatus.Empty : ResourcesListStatus.Success
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, resources.length, displayResources.length])
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
- }, [searchParams.set])
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
- } else {
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
- //filter out the @ossy resources, it is resources that the system creates
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
- () => filterResources.map((resource) => resource.id).filter(Boolean),
377
- [filterResources],
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 filterResources.filter((resource) => batchSelectedIds.has(resource.id))
395
- }, [batchSelectedIds, filterResources])
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
- setBatchSelectedIds(nextSelectedIds)
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
- setBatchSelectedIds(nextSelectedIds)
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
 
@@ -523,11 +610,13 @@ export const ResourcesPage = () => {
523
610
 
524
611
  <View layout="row" gap="s" alignItems="center" style={{ minWidth: 0, flex: 1 }}>
525
612
  <Button
613
+ {...ToggleSelectionMode}
526
614
  prefix="check-r"
527
615
  variant="command"
528
616
  aria-label={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
529
617
  aria-pressed={selectionMode}
530
618
  title={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
619
+ data-selection-mode={selectionMode ? 'on' : 'off'}
531
620
  onClick={toggleSelectionMode}
532
621
  style={{
533
622
  height: '32px',
@@ -562,6 +651,74 @@ export const ResourcesPage = () => {
562
651
  <Dropdown
563
652
  trigger={(
564
653
  <Button
654
+ {...OpenSort}
655
+ prefix={sortOrder === SortOrder.Desc ? 'sort-za' : 'sort-az'}
656
+ variant="command"
657
+ aria-label={t('storage.resources.sort')}
658
+ title={t('storage.resources.sort')}
659
+ style={{ height: '32px' }}
660
+ />
661
+ )}
662
+ >
663
+ <View inset="xs" surface="primary" roundness="s">
664
+ <ContextMenu roundness="s" surface="primary">
665
+ <ContextMenu.Item
666
+ {...SortByName}
667
+ suffix={sortBy === SortBy.Name ? 'check' : undefined}
668
+ onClick={() => setSort(SortBy.Name, sortOrder)}
669
+ >
670
+ {t('storage.resources.sortByName')}
671
+ </ContextMenu.Item>
672
+ <ContextMenu.Item
673
+ {...SortByCreated}
674
+ suffix={sortBy === SortBy.Created ? 'check' : undefined}
675
+ onClick={() => setSort(SortBy.Created, sortOrder)}
676
+ >
677
+ {t('storage.resources.sortByCreated')}
678
+ </ContextMenu.Item>
679
+ <ContextMenu.Item
680
+ {...SortByLastUpdated}
681
+ suffix={sortBy === SortBy.LastUpdated ? 'check' : undefined}
682
+ onClick={() => setSort(SortBy.LastUpdated, sortOrder)}
683
+ >
684
+ {t('storage.resources.sortByUpdated')}
685
+ </ContextMenu.Item>
686
+ <ContextMenu.Item
687
+ {...SortBySize}
688
+ suffix={sortBy === SortBy.Size ? 'check' : undefined}
689
+ onClick={() => setSort(SortBy.Size, sortOrder)}
690
+ >
691
+ {t('storage.resources.sortBySize')}
692
+ </ContextMenu.Item>
693
+ <ContextMenu.Item
694
+ {...SortByType}
695
+ suffix={sortBy === SortBy.Type ? 'check' : undefined}
696
+ onClick={() => setSort(SortBy.Type, sortOrder)}
697
+ >
698
+ {t('storage.resources.sortByType')}
699
+ </ContextMenu.Item>
700
+ <ContextMenu.Separator />
701
+ <ContextMenu.Item
702
+ {...SortAscending}
703
+ suffix={sortOrder === SortOrder.Asc ? 'check' : undefined}
704
+ onClick={() => setSort(sortBy, SortOrder.Asc)}
705
+ >
706
+ {t('storage.resources.sortAscending')}
707
+ </ContextMenu.Item>
708
+ <ContextMenu.Item
709
+ {...SortDescending}
710
+ suffix={sortOrder === SortOrder.Desc ? 'check' : undefined}
711
+ onClick={() => setSort(sortBy, SortOrder.Desc)}
712
+ >
713
+ {t('storage.resources.sortDescending')}
714
+ </ContextMenu.Item>
715
+ </ContextMenu>
716
+ </View>
717
+ </Dropdown>
718
+ <Dropdown
719
+ trigger={(
720
+ <Button
721
+ {...OpenView}
565
722
  prefix={viewMode === ViewMode.Grid ? 'layout-grid' : 'layout-list'}
566
723
  variant="command"
567
724
  aria-label={t('storage.resources.layout')}
@@ -572,6 +729,7 @@ export const ResourcesPage = () => {
572
729
  <View inset="xs" surface="primary" roundness="s">
573
730
  <ContextMenu roundness="s" surface="primary">
574
731
  <ContextMenu.Item
732
+ {...ViewList}
575
733
  prefix="layout-list"
576
734
  suffix={viewMode === ViewMode.List ? 'check' : undefined}
577
735
  onClick={() => setViewMode(ViewMode.List)}
@@ -579,6 +737,7 @@ export const ResourcesPage = () => {
579
737
  {t('storage.resources.viewList')}
580
738
  </ContextMenu.Item>
581
739
  <ContextMenu.Item
740
+ {...ViewGrid}
582
741
  prefix="layout-grid"
583
742
  suffix={viewMode === ViewMode.Grid ? 'check' : undefined}
584
743
  onClick={() => setViewMode(ViewMode.Grid)}
@@ -611,6 +770,7 @@ export const ResourcesPage = () => {
611
770
  {selectionMode && (
612
771
  <View.Item
613
772
  data-surface="primary"
773
+ data-selection-mode="on"
614
774
  layout="row"
615
775
  style={{
616
776
  alignItems: 'center',
@@ -627,6 +787,7 @@ export const ResourcesPage = () => {
627
787
  </Text>
628
788
  <View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
629
789
  <Button
790
+ {...DownloadSelected}
630
791
  prefix="software-download"
631
792
  variant="command"
632
793
  disabled={selectedDownloadableResources.length === 0}
@@ -636,6 +797,7 @@ export const ResourcesPage = () => {
636
797
  {t('storage.resources.downloadSelected')}
637
798
  </Button>
638
799
  <Button
800
+ {...OpenRemoveSelected}
639
801
  prefix="trash-empty"
640
802
  variant="command-danger"
641
803
  disabled={selectedBatchResources.length === 0}
@@ -645,6 +807,7 @@ export const ResourcesPage = () => {
645
807
  {t('storage.resources.removeSelected')}
646
808
  </Button>
647
809
  <Button
810
+ {...DoneSelecting}
648
811
  variant="command"
649
812
  onClick={exitSelectionMode}
650
813
  style={{ height: '32px' }}
@@ -655,7 +818,14 @@ export const ResourcesPage = () => {
655
818
  </View.Item>
656
819
  )}
657
820
 
658
- <View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto', minHeight: 0 }}>
821
+ <View.Item
822
+ fill
823
+ data-scrollbar="hide"
824
+ data-view-mode={viewMode}
825
+ data-sort-by={sortBy}
826
+ data-sort-order={sortOrder}
827
+ style={{ overflowY: 'auto', minHeight: 0 }}
828
+ >
659
829
  <DropZone onFilesDrop={onUploadFiles(activePath)}>
660
830
  <View style={{ minHeight: '100%' }} onContextMenu={handleDropZoneContextMenu}>
661
831
  <Switch on={resourcesListStatus}>
@@ -741,27 +911,27 @@ export const ResourcesPage = () => {
741
911
  </Switch.Case>
742
912
 
743
913
  <Switch.Case match={[ResourcesListStatus.Success]}>
744
- {viewMode === ViewMode.Grid
745
- ? (
746
- <ResourceGrid
747
- resources={filterResources}
748
- inlineFolder={inlineFolder}
749
- selectedIds={highlightedIds}
750
- showSelectionControls={showSelectionControls}
751
- onClick={handleResourceActivate}
752
- onToggleSelect={handleToggleSelect}
753
- />
754
- )
755
- : (
756
- <ResourceList
757
- resources={filterResources}
758
- inlineFolder={inlineFolder}
759
- selectedIds={highlightedIds}
760
- showSelectionControls={showSelectionControls}
761
- onClick={handleResourceActivate}
762
- onToggleSelect={handleToggleSelect}
763
- />
764
- )}
914
+ {viewMode === ViewMode.Grid
915
+ ? (
916
+ <ResourceGrid
917
+ resources={visibleResources}
918
+ inlineFolder={inlineFolder}
919
+ selectedIds={highlightedIds}
920
+ showSelectionControls={showSelectionControls}
921
+ onClick={handleResourceActivate}
922
+ onToggleSelect={handleToggleSelect}
923
+ />
924
+ )
925
+ : (
926
+ <ResourceList
927
+ resources={visibleResources}
928
+ inlineFolder={inlineFolder}
929
+ selectedIds={highlightedIds}
930
+ showSelectionControls={showSelectionControls}
931
+ onClick={handleResourceActivate}
932
+ onToggleSelect={handleToggleSelect}
933
+ />
934
+ )}
765
935
  </Switch.Case>
766
936
 
767
937
  </Switch>
@@ -769,6 +939,54 @@ export const ResourcesPage = () => {
769
939
  </DropZone>
770
940
  </View.Item>
771
941
 
942
+ {resourcesListStatus === ResourcesListStatus.Success && displayTotal > pageLimit && (
943
+ <View.Item
944
+ data-surface="primary"
945
+ layout="row"
946
+ style={{
947
+ alignItems: 'center',
948
+ justifyContent: 'space-between',
949
+ padding: 'var(--space-xs) var(--space-m)',
950
+ gap: 'var(--space-m)',
951
+ minHeight: '40px',
952
+ flexShrink: 0,
953
+ borderTop: '1px solid var(--separator-primary)',
954
+ }}
955
+ >
956
+ <Text variant="small">
957
+ {t('storage.resources.paginationLabel', {
958
+ from: safePageIndex * pageLimit + 1,
959
+ to: Math.min((safePageIndex + 1) * pageLimit, displayTotal),
960
+ total: displayTotal,
961
+ })}
962
+ </Text>
963
+ <View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
964
+ <Button
965
+ prefix="arrow-left"
966
+ variant="command"
967
+ aria-label={t('storage.resources.paginationPrevious')}
968
+ disabled={!hasPreviousPage}
969
+ onClick={() => setPage(safePageIndex - 1)}
970
+ style={{ height: '32px' }}
971
+ />
972
+ <Text variant="small">
973
+ {t('storage.resources.paginationPage', {
974
+ page: safePageIndex + 1,
975
+ pages: pageCount,
976
+ })}
977
+ </Text>
978
+ <Button
979
+ prefix="arrow-right"
980
+ variant="command"
981
+ aria-label={t('storage.resources.paginationNext')}
982
+ disabled={!hasNextPage}
983
+ onClick={() => setPage(safePageIndex + 1)}
984
+ style={{ height: '32px' }}
985
+ />
986
+ </View>
987
+ </View.Item>
988
+ )}
989
+
772
990
  </View>
773
991
  </View.Item>
774
992
 
@@ -779,7 +997,10 @@ export const ResourcesPage = () => {
779
997
 
780
998
  {
781
999
  overlay === Overlays.RemoveDirectory && (
782
- <Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
1000
+ <Overlay isVisible={true} onClose={() => {
1001
+ setPendingDirectoryDeleteId(null)
1002
+ setOverlay(Overlays.None)
1003
+ }}>
783
1004
  <View layout="off-center-s" style={{ height: '100%' }}>
784
1005
  <View data-region="content">
785
1006
  <View surface="primary" roundness="s">
@@ -788,11 +1009,26 @@ export const ResourcesPage = () => {
788
1009
  title={t('storage.resources.removeDirectoryTitle')}
789
1010
  text={t('storage.resources.removeDirectoryText')}
790
1011
  actions={[
791
- { label: t('storage.resources.cancel'), variant: "command", onClick: () => setOverlay(Overlays.None) },
792
- { label: t('storage.resources.remove'), variant: 'command-danger', onClick: () => {
793
- removeResource(sdk, selectedResourceId, activePath)
794
- setOverlay(Overlays.None)
795
- }}
1012
+ {
1013
+ label: t('storage.resources.cancel'),
1014
+ variant: "command",
1015
+ onClick: () => {
1016
+ setPendingDirectoryDeleteId(null)
1017
+ setOverlay(Overlays.None)
1018
+ },
1019
+ },
1020
+ {
1021
+ ...DeleteResource,
1022
+ label: 'storage.resources.remove',
1023
+ variant: 'command-danger',
1024
+ onClick: () => {
1025
+ if (pendingDirectoryDeleteId) {
1026
+ removeResource(sdk, pendingDirectoryDeleteId, activePath)
1027
+ }
1028
+ setPendingDirectoryDeleteId(null)
1029
+ setOverlay(Overlays.None)
1030
+ },
1031
+ },
796
1032
  ]}
797
1033
  />
798
1034
  </View>
@@ -815,7 +1051,12 @@ export const ResourcesPage = () => {
815
1051
  text={t('storage.resources.removeSelectedText').replace('{count}', String(selectionCount))}
816
1052
  actions={[
817
1053
  { label: t('storage.resources.cancel'), variant: 'command', onClick: () => setOverlay(Overlays.None) },
818
- { label: t('storage.resources.removeSelected'), variant: 'command-danger', onClick: handleBatchRemoveConfirm },
1054
+ {
1055
+ ...DeleteResource,
1056
+ label: 'storage.resources.removeSelected',
1057
+ variant: 'command-danger',
1058
+ onClick: handleBatchRemoveConfirm,
1059
+ },
819
1060
  ]}
820
1061
  />
821
1062
  </View>
@@ -828,9 +1069,11 @@ export const ResourcesPage = () => {
828
1069
 
829
1070
  {
830
1071
  overlay === Overlays.MoveResource && (
831
- <Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
832
- <ResourceDialogMove onClose={() => setOverlay(Overlays.None)} resourceId={selectedResourceId}/>
833
- </Overlay>
1072
+ <ResourceDialogMove
1073
+ isVisible={true}
1074
+ onClose={() => setOverlay(Overlays.None)}
1075
+ resourceId={selectedResourceId}
1076
+ />
834
1077
  )
835
1078
  }
836
1079
 
@@ -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
  }
@@ -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
  }