@@ -5,13 +5,15 @@ import { HStack, Icon, Text, useColorMode, Image } from "@hope-ui/solid"
55import { operations } from "../toolbar/operations"
66import { For , Show } from "solid-js"
77import { bus , convertURL , notify } from "~/utils"
8- import { ObjType , UserMethods , UserPermissions } from "~/types"
8+ import { ObjType , UserMethods } from "~/types"
99import {
1010 getSettingBool ,
1111 haveSelected ,
1212 me ,
13+ objStore ,
1314 oneChecked ,
1415 selectedObjs ,
16+ userCan ,
1517} from "~/store"
1618import { players } from "../previews/video_box"
1719import { BsPlayCircleFill } from "solid-icons/bs"
@@ -50,13 +52,10 @@ export const ContextMenu = () => {
5052 theme = { colorMode ( ) !== "dark" ? "light" : "dark" }
5153 style = "z-index: var(--hope-zIndices-popover)"
5254 >
53- < For each = { [ "rename" , "move" , "copy" , "delete" , "share" ] } >
55+ < For each = { [ "rename" , "move" , "copy" , "delete" ] as const } >
5456 { ( name ) => (
5557 < Item
56- hidden = { ( ) => {
57- const index = UserPermissions . findIndex ( ( item ) => item === name )
58- return isShare ( ) || ! UserMethods . can ( me ( ) , index )
59- } }
58+ hidden = { ! userCan ( name ) || ! objStore . write || isShare ( ) }
6059 onClick = { ( ) => {
6160 bus . emit ( "tool" , name )
6261 } }
@@ -65,14 +64,20 @@ export const ContextMenu = () => {
6564 </ Item >
6665 ) }
6766 </ For >
67+ < Item
68+ hidden = { ! userCan ( "share" ) }
69+ onClick = { ( ) => {
70+ bus . emit ( "tool" , "share" )
71+ } }
72+ >
73+ < ItemContent name = "share" />
74+ </ Item >
6875 < Item
6976 hidden = { ( ) => {
70- const index = UserPermissions . findIndex (
71- ( item ) => item === "decompress" ,
72- )
7377 return (
7478 isShare ( ) ||
75- ! UserMethods . can ( me ( ) , index ) ||
79+ ! userCan ( "decompress" ) ||
80+ ! objStore . write ||
7681 selectedObjs ( ) . some ( ( o ) => o . is_dir ) ||
7782 selectedObjs ( ) . some ( ( o ) => ! isArchive ( o . name ) )
7883 )
0 commit comments