mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 00:00:50 +00:00
fix: handle node admin action permissions (#12857)
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useGlobalStore } from '@/composables/useGlobalStore';
|
||||
import { hasManagePermissionAccess, hasPermissionAccess } from '@/utils/permission';
|
||||
const slots = useSlots();
|
||||
|
||||
const { isMobile, openMenuTabs } = useGlobalStore();
|
||||
@@ -164,7 +165,15 @@ const closeRightClick = () => {
|
||||
};
|
||||
const disabled = computed(() => {
|
||||
return function (btn: any) {
|
||||
return typeof btn.disabled === 'function' ? btn.disabled(rightClick.value.currentRow) : btn.disabled;
|
||||
let permissionDisabled = false;
|
||||
if (btn.permission === true) {
|
||||
permissionDisabled = !hasManagePermissionAccess();
|
||||
} else if (btn.permission !== undefined) {
|
||||
permissionDisabled = !hasPermissionAccess(btn.permission);
|
||||
}
|
||||
const buttonDisabled =
|
||||
typeof btn.disabled === 'function' ? btn.disabled(rightClick.value.currentRow) : btn.disabled;
|
||||
return permissionDisabled || buttonDisabled;
|
||||
};
|
||||
});
|
||||
const visibleRightButtons = computed(() => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import router from '@/routers';
|
||||
import { GlobalStore } from '@/store';
|
||||
import { normalizeToManageCode } from '@/utils/permission-codes';
|
||||
import { isMasterOnlyPermissionCode, normalizeToManageCode } from '@/utils/permission-codes';
|
||||
|
||||
export type PermissionBindingValue = string | string[] | undefined;
|
||||
export type PermissionMode = 'manage' | 'view';
|
||||
@@ -53,6 +53,14 @@ const hasPermissionAccessByMode = (mode: PermissionMode, value?: PermissionBindi
|
||||
if (normalizedPermissions.length === 0) {
|
||||
return globalStore.isAdmin || globalStore.isNodeAdmin;
|
||||
}
|
||||
if (
|
||||
mode === 'manage' &&
|
||||
globalStore.isNodeAdmin &&
|
||||
!globalStore.isMaster &&
|
||||
normalizedPermissions.some((permission) => !isMasterOnlyPermissionCode(permission))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return normalizedPermissions.some((permission) => globalStore.hasPermission(permission));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user