1
- import { Text , useColorModeValue , VStack } from "@hope-ui/solid"
1
+ import { Text , useColorModeValue , VStack , Button } from "@hope-ui/solid"
2
2
import {
3
3
createEffect ,
4
4
createMemo ,
@@ -19,7 +19,9 @@ import {
19
19
recordHistory ,
20
20
setPassword ,
21
21
/*layout,*/ State ,
22
+ me ,
22
23
} from "~/store"
24
+ import { UserMethods } from "~/types"
23
25
24
26
const Folder = lazy ( ( ) => import ( "./folder/Folder" ) )
25
27
const File = lazy ( ( ) => import ( "./file/File" ) )
@@ -33,7 +35,7 @@ export { objBoxRef }
33
35
export const Obj = ( ) => {
34
36
const t = useT ( )
35
37
const cardBg = useColorModeValue ( "white" , "$neutral3" )
36
- const { pathname, searchParams, isShare } = useRouter ( )
38
+ const { pathname, searchParams, isShare, to } = useRouter ( )
37
39
const { handlePathChange, refresh } = usePath ( )
38
40
const pagination = getPagination ( )
39
41
const page = createMemo ( ( ) => {
@@ -57,6 +59,23 @@ export const Obj = () => {
57
59
await handlePathChange ( pathname , page )
58
60
} ) ,
59
61
)
62
+
63
+ const isStorageError = createMemo ( ( ) => {
64
+ const err = objStore . err
65
+ return (
66
+ err . includes ( "storage not found" ) || err . includes ( "please add a storage" )
67
+ )
68
+ } )
69
+
70
+ const shouldShowStorageButton = createMemo ( ( ) => {
71
+ return isStorageError ( ) && UserMethods . is_admin ( me ( ) )
72
+ } )
73
+
74
+ const storageErrorActions = ( ) => (
75
+ < Button colorScheme = "accent" onClick = { ( ) => to ( "/@manage/storages" ) } >
76
+ { t ( "global.go_to_storages" ) }
77
+ </ Button >
78
+ )
60
79
return (
61
80
< VStack
62
81
ref = { ( el : HTMLDivElement ) => setObjBoxRef ( el ) }
@@ -71,7 +90,13 @@ export const Obj = () => {
71
90
< Suspense fallback = { < FullLoading /> } >
72
91
< Switch >
73
92
< Match when = { objStore . err } >
74
- < Error msg = { objStore . err } disableColor />
93
+ < Error
94
+ msg = { objStore . err }
95
+ disableColor
96
+ actions = {
97
+ shouldShowStorageButton ( ) ? storageErrorActions ( ) : undefined
98
+ }
99
+ />
75
100
</ Match >
76
101
< Match
77
102
when = { [ State . FetchingObj , State . FetchingObjs ] . includes (
0 commit comments