@ossy/storage 3.8.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.8.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": "14548dfc2019e7258e8c75db527acbf66fe829bd"
33
+ "gitHead": "53ff8456920e09151c9d88df4a6c3ee958d811eb"
34
34
  }
@@ -1,16 +1,47 @@
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,
7
6
  isDownloadableResource,
8
7
  isMultiSelectGesture,
8
+ isShareableResource,
9
9
  moveResource,
10
10
  removeResource,
11
11
  resourceDownloadHref,
12
12
  triggerResourceDownloads,
13
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,
14
45
  } from '@ossy/resources'
15
46
  import { GetWorkspace } from '@ossy/workspaces'
16
47
  import { AsyncStatus, useSdk } from '@ossy/sdk-react'
@@ -22,7 +53,6 @@ import {
22
53
  last,
23
54
  } from 'ramda'
24
55
  import { Text, Overlay, Switch, DropZone, Breadcrumbs, Guide, DelayedRender, useDocumentTitle, View, Button, ContextMenu, Dropdown, Page, Tags, useLocale, preloadStorageIcons } from '@ossy/design-system'
25
- import { useActivePath, ResourcePanel, ResourceList, ResourceGrid, ResourceDialogMove, useSelectedResourceId } from '@ossy/resources'
26
56
  import { useRouter, useSearchParams } from '@ossy/router-react'
27
57
 
28
58
  const Path = ({ path, ...props }) => (
@@ -41,9 +71,10 @@ const ResourcesListStatus = {
41
71
 
42
72
  const Overlays = {
43
73
  None: 'None',
44
- Removedirectory : 'RemoveDirectory',
74
+ RemoveDirectory: 'RemoveDirectory',
45
75
  RemoveBatch: 'RemoveBatch',
46
- MoveResource: 'MoveResource'
76
+ MoveResource: 'MoveResource',
77
+ ShareResource: 'ShareResource',
47
78
  }
48
79
 
49
80
  const ViewMode = {
@@ -51,6 +82,19 @@ const ViewMode = {
51
82
  Grid: 'grid',
52
83
  }
53
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
+
54
98
  export const ResourcesPage = () => {
55
99
  const router = useRouter()
56
100
  const searchParams = useSearchParams()
@@ -62,11 +106,14 @@ export const ResourcesPage = () => {
62
106
  const [addMenuOpen, setAddMenuOpen] = useState(false)
63
107
  const [addMenuPosition, setAddMenuPosition] = useState(null)
64
108
  const [batchSelectedIds, setBatchSelectedIds] = useState(() => new Set())
109
+ const [selectedResourcesById, setSelectedResourcesById] = useState(() => new Map())
65
110
  const [selectionAnchorId, setSelectionAnchorId] = useState(null)
66
111
  const [selectionMode, setSelectionMode] = useState(false)
112
+ const [pendingDirectoryDeleteId, setPendingDirectoryDeleteId] = useState(null)
67
113
  const { selectedResourceId, setSelectedResourceId, clearSelectedResourceId } = useSelectedResourceId()
68
114
  const activePath = useActivePath()
69
115
  const lastSuccessfulResourcesRef = useRef([])
116
+ const lastSuccessfulTotalRef = useRef(0)
70
117
 
71
118
  useEffect(() => {
72
119
  preloadStorageIcons()
@@ -74,30 +121,49 @@ export const ResourcesPage = () => {
74
121
 
75
122
  useEffect(() => {
76
123
  setBatchSelectedIds(new Set())
124
+ setSelectedResourcesById(new Map())
77
125
  setSelectionAnchorId(null)
78
126
  setSelectionMode(false)
79
127
  }, [activePath])
80
128
 
81
129
  const {
130
+ items: resourceItems = [],
131
+ total: resourceTotal = 0,
82
132
  status: resourcesStatus,
83
- data: resources = [],
84
- } = 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
+ })
85
148
 
86
149
  if (resourcesStatus === AsyncStatus.Success) {
87
- lastSuccessfulResourcesRef.current = resources
150
+ lastSuccessfulResourcesRef.current = resourceItems
151
+ lastSuccessfulTotalRef.current = resourceTotal
88
152
  }
89
153
 
90
154
  const displayResources =
91
- resourcesStatus === AsyncStatus.Success ? resources : lastSuccessfulResourcesRef.current
155
+ resourcesStatus === AsyncStatus.Success ? resourceItems : lastSuccessfulResourcesRef.current
156
+ const displayTotal =
157
+ resourcesStatus === AsyncStatus.Success ? resourceTotal : lastSuccessfulTotalRef.current
92
158
 
93
159
  const resourcesListStatus = useMemo(() => {
94
160
  if (resourcesStatus === AsyncStatus.Error) return ResourcesListStatus.Error
95
161
  if (resourcesStatus === AsyncStatus.Success) {
96
- return resources.length === 0 ? ResourcesListStatus.Empty : ResourcesListStatus.Success
162
+ return resourceTotal === 0 ? ResourcesListStatus.Empty : ResourcesListStatus.Success
97
163
  }
98
- if (displayResources.length > 0) return ResourcesListStatus.Success
164
+ if (displayResources.length > 0 || displayTotal > 0) return ResourcesListStatus.Success
99
165
  return ResourcesListStatus.Loading
100
- }, [resourcesStatus, resources.length, displayResources.length])
166
+ }, [resourcesStatus, resourceTotal, displayResources.length, displayTotal])
101
167
 
102
168
  const [isCreatingFolder, setIsCreatingFolder] = useState(false)
103
169
  const [newFolderName, setNewFolderName] = useState(() => t('storage.resources.newFolderDefault'))
@@ -129,16 +195,27 @@ export const ResourcesPage = () => {
129
195
  const storageHomeHref = useCallback((locationQuery = '') => {
130
196
  const parts = []
131
197
  if (locationQuery) parts.push(locationQuery)
198
+ const listQuery = resourceListQuerySearchString({
199
+ pageIndex: 0,
200
+ sortBy,
201
+ sortOrder,
202
+ })
203
+ if (listQuery) parts.push(listQuery)
132
204
  if (selectedResourceId) parts.push(`r=${selectedResourceId}`)
133
205
  const search = parts.length ? `?${parts.join('&')}` : ''
134
206
  return router.getHref(`@storage/home${search}`)
135
- }, [router, selectedResourceId])
207
+ }, [router, selectedResourceId, sortBy, sortOrder])
136
208
 
137
209
  const navigateToLocation = useCallback((locationPath) => {
138
210
  const normalized = locationPath.startsWith('/') ? locationPath : `/${locationPath}`
139
211
  const withSlash = normalized.endsWith('/') ? normalized : `${normalized}/`
212
+ if (typeof searchParams.patch === 'function') {
213
+ searchParams.patch({ location: withSlash, page: null })
214
+ return
215
+ }
140
216
  searchParams.set('location', withSlash)
141
- }, [searchParams.set])
217
+ searchParams.delete('page')
218
+ }, [searchParams.patch, searchParams.set, searchParams.delete])
142
219
 
143
220
  const openLocation = useCallback((locationPath) => (event) => {
144
221
  if (event?.metaKey || event?.ctrlKey || event?.shiftKey || event?.button === 1) return
@@ -162,21 +239,27 @@ export const ResourcesPage = () => {
162
239
  }, [sdk])
163
240
 
164
241
  const onRemoveResource = resource => {
165
- setSelectedResourceId(resource.id)
166
-
167
242
  if (resource.type === '@ossy/platform/schema/directory' || resource.type === 'directory') {
243
+ setPendingDirectoryDeleteId(resource.id)
168
244
  setOverlay(Overlays.RemoveDirectory)
169
- } else {
170
- removeResource(sdk, resource.id, resource.location)
245
+ return
171
246
  }
172
247
 
248
+ setSelectedResourceId(resource.id)
249
+ removeResource(sdk, resource.id, resource.location)
173
250
  }
174
251
 
175
252
  const clearBatchSelection = useCallback(() => {
176
253
  setBatchSelectedIds(new Set())
254
+ setSelectedResourcesById(new Map())
177
255
  setSelectionAnchorId(null)
178
256
  }, [])
179
257
 
258
+ const applyBatchSelection = useCallback((nextSelectedIds, knownResources) => {
259
+ setBatchSelectedIds(nextSelectedIds)
260
+ setSelectedResourcesById((prev) => syncSelectedResources(nextSelectedIds, prev, knownResources))
261
+ }, [])
262
+
180
263
  const exitSelectionMode = useCallback(() => {
181
264
  setSelectionMode(false)
182
265
  clearBatchSelection()
@@ -260,7 +343,7 @@ export const ResourcesPage = () => {
260
343
  )(activePath)
261
344
 
262
345
  const filterResources = useMemo(() => displayResources
263
- //filter out the @ossy resources, it is resources that the system creates
346
+ // System folders (@ossy/…) stay out of the storage UI.
264
347
  .filter(resource => !resource?.name?.startsWith?.('@ossy'))
265
348
  .map(resource => {
266
349
 
@@ -286,9 +369,11 @@ export const ResourcesPage = () => {
286
369
  </ContextMenu.Item>,
287
370
  <ContextMenu.Separator key="separator"></ContextMenu.Separator>,
288
371
  <ContextMenu.Item
372
+ {...OpenDeleteDirectory}
289
373
  variant="command-danger"
290
374
  prefix="trash-empty"
291
375
  key="remove"
376
+ label={undefined}
292
377
  onClick={() => onRemoveResource(resource)}
293
378
  >{t('storage.resources.contextRemove')}
294
379
  </ContextMenu.Item>
@@ -315,9 +400,25 @@ export const ResourcesPage = () => {
315
400
  >
316
401
  View
317
402
  </ContextMenu.Item>,
403
+ ...(isShareableResource(resource)
404
+ ? [
405
+ <ContextMenu.Item
406
+ {...OpenShare}
407
+ key="share"
408
+ prefix="share"
409
+ onClick={() => {
410
+ setSelectedResourceId(resource.id)
411
+ setOverlay(Overlays.ShareResource)
412
+ }}
413
+ >
414
+ {t('storage.resources.share')}
415
+ </ContextMenu.Item>,
416
+ ]
417
+ : []),
318
418
  ...(downloadHref
319
419
  ? [
320
420
  <ContextMenu.Item
421
+ {...DownloadResource}
321
422
  key="download"
322
423
  prefix="software-download"
323
424
  href={downloadHref}
@@ -328,6 +429,7 @@ export const ResourcesPage = () => {
328
429
  ]
329
430
  : []),
330
431
  <ContextMenu.Item
432
+ {...OpenMove}
331
433
  key="move"
332
434
  prefix="details-more"
333
435
  onClick={() => {
@@ -343,22 +445,19 @@ export const ResourcesPage = () => {
343
445
  variant="command-danger"
344
446
  prefix="trash-empty"
345
447
  onClick={() => onRemoveResource(resource)}
346
- >Remove
448
+ >{t('storage.resources.contextRemove')}
347
449
  </ContextMenu.Item>
348
450
  ]
349
451
  }
350
452
 
351
- })
352
- .sort((a, b) => {
353
- const aDir = a.type === '@ossy/platform/schema/directory' || a.type === 'directory'
354
- const bDir = b.type === '@ossy/platform/schema/directory' || b.type === 'directory'
355
- if (aDir && !bDir) return -1
356
- if (!aDir && bDir) return 1
357
453
  }), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onUploadFiles, onRemoveResource, setSelectedResourceId, t])
358
454
 
455
+ // Server already sorted + paginated.
456
+ const visibleResources = filterResources
457
+
359
458
  const orderedResourceIds = useMemo(
360
- () => filterResources.map((resource) => resource.id).filter(Boolean),
361
- [filterResources],
459
+ () => visibleResources.map((resource) => resource.id).filter(Boolean),
460
+ [visibleResources],
362
461
  )
363
462
 
364
463
  const highlightedIds = useMemo(() => {
@@ -366,17 +465,17 @@ export const ResourcesPage = () => {
366
465
  return selectedResourceId ? new Set([selectedResourceId]) : new Set()
367
466
  }, [batchSelectedIds, selectedResourceId])
368
467
 
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
468
  const selectedBatchResources = useMemo(() => {
377
469
  if (batchSelectedIds.size === 0) return []
378
- return filterResources.filter((resource) => batchSelectedIds.has(resource.id))
379
- }, [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
+ )
380
479
 
381
480
  const handleResourceActivate = useCallback((resource, event) => {
382
481
  if (!resource?.id) return
@@ -393,7 +492,7 @@ export const ResourcesPage = () => {
393
492
  event: gestureEvent,
394
493
  anchorId: selectionAnchorId,
395
494
  })
396
- setBatchSelectedIds(nextSelectedIds)
495
+ applyBatchSelection(nextSelectedIds, displayResources)
397
496
  setSelectionAnchorId(nextAnchorId)
398
497
  if (!selectionMode) setSelectionMode(true)
399
498
  clearSelectedResourceId()
@@ -406,6 +505,8 @@ export const ResourcesPage = () => {
406
505
  batchSelectedIds,
407
506
  orderedResourceIds,
408
507
  selectionAnchorId,
508
+ displayResources,
509
+ applyBatchSelection,
409
510
  clearSelectedResourceId,
410
511
  clearBatchSelection,
411
512
  ])
@@ -420,7 +521,7 @@ export const ResourcesPage = () => {
420
521
  event: { metaKey: true },
421
522
  anchorId: selectionAnchorId,
422
523
  })
423
- setBatchSelectedIds(nextSelectedIds)
524
+ applyBatchSelection(nextSelectedIds, displayResources)
424
525
  setSelectionAnchorId(nextAnchorId)
425
526
  clearSelectedResourceId()
426
527
  }, [
@@ -428,6 +529,8 @@ export const ResourcesPage = () => {
428
529
  batchSelectedIds,
429
530
  orderedResourceIds,
430
531
  selectionAnchorId,
532
+ displayResources,
533
+ applyBatchSelection,
431
534
  clearSelectedResourceId,
432
535
  ])
433
536
 
@@ -507,11 +610,13 @@ export const ResourcesPage = () => {
507
610
 
508
611
  <View layout="row" gap="s" alignItems="center" style={{ minWidth: 0, flex: 1 }}>
509
612
  <Button
613
+ {...ToggleSelectionMode}
510
614
  prefix="check-r"
511
615
  variant="command"
512
616
  aria-label={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
513
617
  aria-pressed={selectionMode}
514
618
  title={t(selectionMode ? 'storage.resources.selectModeActive' : 'storage.resources.selectMode')}
619
+ data-selection-mode={selectionMode ? 'on' : 'off'}
515
620
  onClick={toggleSelectionMode}
516
621
  style={{
517
622
  height: '32px',
@@ -546,6 +651,74 @@ export const ResourcesPage = () => {
546
651
  <Dropdown
547
652
  trigger={(
548
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}
549
722
  prefix={viewMode === ViewMode.Grid ? 'layout-grid' : 'layout-list'}
550
723
  variant="command"
551
724
  aria-label={t('storage.resources.layout')}
@@ -556,6 +729,7 @@ export const ResourcesPage = () => {
556
729
  <View inset="xs" surface="primary" roundness="s">
557
730
  <ContextMenu roundness="s" surface="primary">
558
731
  <ContextMenu.Item
732
+ {...ViewList}
559
733
  prefix="layout-list"
560
734
  suffix={viewMode === ViewMode.List ? 'check' : undefined}
561
735
  onClick={() => setViewMode(ViewMode.List)}
@@ -563,6 +737,7 @@ export const ResourcesPage = () => {
563
737
  {t('storage.resources.viewList')}
564
738
  </ContextMenu.Item>
565
739
  <ContextMenu.Item
740
+ {...ViewGrid}
566
741
  prefix="layout-grid"
567
742
  suffix={viewMode === ViewMode.Grid ? 'check' : undefined}
568
743
  onClick={() => setViewMode(ViewMode.Grid)}
@@ -595,6 +770,7 @@ export const ResourcesPage = () => {
595
770
  {selectionMode && (
596
771
  <View.Item
597
772
  data-surface="primary"
773
+ data-selection-mode="on"
598
774
  layout="row"
599
775
  style={{
600
776
  alignItems: 'center',
@@ -611,6 +787,7 @@ export const ResourcesPage = () => {
611
787
  </Text>
612
788
  <View layout="row" gap="xs" alignItems="center" style={{ flexShrink: 0 }}>
613
789
  <Button
790
+ {...DownloadSelected}
614
791
  prefix="software-download"
615
792
  variant="command"
616
793
  disabled={selectedDownloadableResources.length === 0}
@@ -620,6 +797,7 @@ export const ResourcesPage = () => {
620
797
  {t('storage.resources.downloadSelected')}
621
798
  </Button>
622
799
  <Button
800
+ {...OpenRemoveSelected}
623
801
  prefix="trash-empty"
624
802
  variant="command-danger"
625
803
  disabled={selectedBatchResources.length === 0}
@@ -629,6 +807,7 @@ export const ResourcesPage = () => {
629
807
  {t('storage.resources.removeSelected')}
630
808
  </Button>
631
809
  <Button
810
+ {...DoneSelecting}
632
811
  variant="command"
633
812
  onClick={exitSelectionMode}
634
813
  style={{ height: '32px' }}
@@ -639,7 +818,14 @@ export const ResourcesPage = () => {
639
818
  </View.Item>
640
819
  )}
641
820
 
642
- <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
+ >
643
829
  <DropZone onFilesDrop={onUploadFiles(activePath)}>
644
830
  <View style={{ minHeight: '100%' }} onContextMenu={handleDropZoneContextMenu}>
645
831
  <Switch on={resourcesListStatus}>
@@ -725,27 +911,27 @@ export const ResourcesPage = () => {
725
911
  </Switch.Case>
726
912
 
727
913
  <Switch.Case match={[ResourcesListStatus.Success]}>
728
- {viewMode === ViewMode.Grid
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
- )}
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
+ )}
749
935
  </Switch.Case>
750
936
 
751
937
  </Switch>
@@ -753,6 +939,54 @@ export const ResourcesPage = () => {
753
939
  </DropZone>
754
940
  </View.Item>
755
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
+
756
990
  </View>
757
991
  </View.Item>
758
992
 
@@ -763,7 +997,10 @@ export const ResourcesPage = () => {
763
997
 
764
998
  {
765
999
  overlay === Overlays.RemoveDirectory && (
766
- <Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
1000
+ <Overlay isVisible={true} onClose={() => {
1001
+ setPendingDirectoryDeleteId(null)
1002
+ setOverlay(Overlays.None)
1003
+ }}>
767
1004
  <View layout="off-center-s" style={{ height: '100%' }}>
768
1005
  <View data-region="content">
769
1006
  <View surface="primary" roundness="s">
@@ -772,11 +1009,26 @@ export const ResourcesPage = () => {
772
1009
  title={t('storage.resources.removeDirectoryTitle')}
773
1010
  text={t('storage.resources.removeDirectoryText')}
774
1011
  actions={[
775
- { label: t('storage.resources.cancel'), variant: "command", onClick: () => setOverlay(Overlays.None) },
776
- { label: t('storage.resources.remove'), variant: 'command-danger', onClick: () => {
777
- removeResource(sdk, selectedResourceId, activePath)
778
- setOverlay(Overlays.None)
779
- }}
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
+ },
780
1032
  ]}
781
1033
  />
782
1034
  </View>
@@ -799,7 +1051,12 @@ export const ResourcesPage = () => {
799
1051
  text={t('storage.resources.removeSelectedText').replace('{count}', String(selectionCount))}
800
1052
  actions={[
801
1053
  { label: t('storage.resources.cancel'), variant: 'command', onClick: () => setOverlay(Overlays.None) },
802
- { 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
+ },
803
1060
  ]}
804
1061
  />
805
1062
  </View>
@@ -812,12 +1069,20 @@ export const ResourcesPage = () => {
812
1069
 
813
1070
  {
814
1071
  overlay === Overlays.MoveResource && (
815
- <Overlay isVisible={true} onClose={() => setOverlay(Overlays.None)}>
816
- <ResourceDialogMove onClose={() => setOverlay(Overlays.None)} resourceId={selectedResourceId}/>
817
- </Overlay>
1072
+ <ResourceDialogMove
1073
+ isVisible={true}
1074
+ onClose={() => setOverlay(Overlays.None)}
1075
+ resourceId={selectedResourceId}
1076
+ />
818
1077
  )
819
1078
  }
820
1079
 
1080
+ <ResourceShareDialog
1081
+ resourceId={selectedResourceId}
1082
+ isVisible={overlay === Overlays.ShareResource}
1083
+ onClose={() => setOverlay(Overlays.None)}
1084
+ />
1085
+
821
1086
  </Page>
822
1087
  </>
823
1088
  )
@@ -20,6 +20,7 @@
20
20
  "storage.resources.cancel": "Cancel",
21
21
  "storage.resources.remove": "Remove",
22
22
  "storage.resources.move": "Move",
23
+ "storage.resources.share": "Share",
23
24
  "storage.resources.download": "Download",
24
25
  "storage.resources.downloadSelected": "Download selected",
25
26
  "storage.resources.removeSelected": "Remove selected",
@@ -35,5 +36,17 @@
35
36
  "storage.resources.contextRemove": "Remove",
36
37
  "storage.resources.layout": "Layout",
37
38
  "storage.resources.viewList": "List view",
38
- "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"
39
52
  }
@@ -20,6 +20,7 @@
20
20
  "storage.resources.cancel": "Avbryt",
21
21
  "storage.resources.remove": "Ta bort",
22
22
  "storage.resources.move": "Flytta",
23
+ "storage.resources.share": "Dela",
23
24
  "storage.resources.download": "Ladda ner",
24
25
  "storage.resources.downloadSelected": "Ladda ner markerade",
25
26
  "storage.resources.removeSelected": "Ta bort markerade",
@@ -35,5 +36,17 @@
35
36
  "storage.resources.contextRemove": "Ta bort",
36
37
  "storage.resources.layout": "Layout",
37
38
  "storage.resources.viewList": "Listvy",
38
- "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"
39
52
  }