chore: chagne mangament attr name

This commit is contained in:
Joel 2024-10-15 21:35:56 +08:00
parent 70a5d78cc5
commit 31ece363c3
5 changed files with 8 additions and 8 deletions

View File

@ -49,7 +49,7 @@ const PluginSettingModal: FC<Props> = ({
</div>
<div className='flex px-6 py-3 flex-col justify-center items-start gap-4 self-stretch'>
{[
{ title: t(`${i18nPrefix}.whoCanInstall`), key: 'canInstall', value: tempPrivilege.canInstall },
{ title: t(`${i18nPrefix}.whoCanInstall`), key: 'canManagement', value: tempPrivilege.canManagement },
{ title: t(`${i18nPrefix}.whoCanDebug`), key: 'canDebugger', value: tempPrivilege.canDebugger },
].map(({ title, key, value }) => (
<div key={key} className='flex flex-col items-start gap-1 self-stretch'>

View File

@ -22,7 +22,7 @@ export type PluginPageContextValue = {
export const PluginPageContext = createContext<PluginPageContextValue>({
containerRef: { current: null },
permissions: {
canInstall: PermissionType.noOne,
canManagement: PermissionType.noOne,
canDebugger: PermissionType.noOne,
},
setPermissions: () => { },
@ -41,7 +41,7 @@ export const PluginPageContextProvider = ({
}: PluginPageContextProviderProps) => {
const containerRef = useRef<HTMLDivElement>(null)
const [permissions, setPermissions] = useState<PluginPageContextValue['permissions']>({
canInstall: PermissionType.noOne,
canManagement: PermissionType.noOne,
canDebugger: PermissionType.noOne,
})

View File

@ -36,7 +36,7 @@ const PluginPage = ({
}: PluginPageProps) => {
const { t } = useTranslation()
const {
canInstall,
canManagement,
canDebugger,
canSetPermissions,
permissions,
@ -88,7 +88,7 @@ const PluginPage = ({
/>
</div>
<div className='flex flex-shrink-0 items-center gap-1'>
{canInstall && (
{canManagement && (
<InstallPluginDropdown />
)}
{

View File

@ -23,12 +23,12 @@ const usePermission = () => {
useEffect(() => {
// TODO: fetch permissions from server
setPermissions({
canInstall: PermissionType.everyone,
canManagement: PermissionType.everyone,
canDebugger: PermissionType.everyone,
})
}, [])
return {
canInstall: hasPermission(permissions.canInstall, isAdmin),
canManagement: hasPermission(permissions.canManagement, isAdmin),
canDebugger: hasPermission(permissions.canDebugger, isAdmin),
canSetPermissions: isAdmin,
permissions,

View File

@ -33,6 +33,6 @@ export enum PermissionType {
}
export type Permissions = {
canInstall: PermissionType
canManagement: PermissionType
canDebugger: PermissionType
}