fix: install plugins permissions (#18870)
This commit is contained in:
parent
bed47dffb9
commit
58a929edd5
3 changed files with 28 additions and 3 deletions
|
|
@ -3,6 +3,8 @@ import { useAppContext } from '@/context/app-context'
|
|||
import Toast from '../../base/toast'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useInvalidatePermissions, useMutationPermissions, usePermissions } from '@/service/use-plugins'
|
||||
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
||||
import { useMemo } from 'react'
|
||||
|
||||
const hasPermission = (permission: PermissionType | undefined, isAdmin: boolean) => {
|
||||
if (!permission)
|
||||
|
|
@ -43,4 +45,17 @@ const usePermission = () => {
|
|||
}
|
||||
}
|
||||
|
||||
export const useCanInstallPluginFromMarketplace = () => {
|
||||
const { enable_marketplace } = useAppContextSelector(s => s.systemFeatures)
|
||||
const { canManagement } = usePermission()
|
||||
|
||||
const canInstallPluginFromMarketplace = useMemo(() => {
|
||||
return enable_marketplace && canManagement
|
||||
}, [enable_marketplace, canManagement])
|
||||
|
||||
return {
|
||||
canInstallPluginFromMarketplace,
|
||||
}
|
||||
}
|
||||
|
||||
export default usePermission
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue