diff --git a/web/app/components/plugins/plugin-page/__tests__/use-reference-setting.spec.ts b/web/app/components/plugins/plugin-page/__tests__/use-reference-setting.spec.ts index 2ab99dfe878..9d5958e2718 100644 --- a/web/app/components/plugins/plugin-page/__tests__/use-reference-setting.spec.ts +++ b/web/app/components/plugins/plugin-page/__tests__/use-reference-setting.spec.ts @@ -128,7 +128,7 @@ describe('useReferenceSetting Hook', () => { expect(result.current.canDebugger).toBe(true) }) - it('should ignore legacy admin permission for managers without plugin keys', () => { + it('should allow debug for managers with legacy admin permission when RBAC is disabled', () => { vi.mocked(useAppContext).mockReturnValue({ isCurrentWorkspaceManager: true, isCurrentWorkspaceOwner: false, @@ -146,10 +146,10 @@ describe('useReferenceSetting Hook', () => { const { result } = renderHook(() => useReferenceSetting(PluginCategoryEnum.tool)) expect(result.current.canManagement).toBe(false) - expect(result.current.canDebugger).toBe(false) + expect(result.current.canDebugger).toBe(true) }) - it('should ignore legacy admin permission for owners without plugin keys', () => { + it('should allow debug for owners with legacy admin permission when RBAC is disabled', () => { vi.mocked(useAppContext).mockReturnValue({ isCurrentWorkspaceManager: false, isCurrentWorkspaceOwner: true, @@ -167,7 +167,30 @@ describe('useReferenceSetting Hook', () => { const { result } = renderHook(() => useReferenceSetting(PluginCategoryEnum.tool)) expect(result.current.canManagement).toBe(false) - expect(result.current.canDebugger).toBe(false) + expect(result.current.canDebugger).toBe(true) + }) + + it('should allow debug for normal users when legacy debug permission is everyone and RBAC is disabled', () => { + vi.mocked(useAppContext).mockReturnValue({ + isCurrentWorkspaceManager: false, + isCurrentWorkspaceOwner: false, + langGeniusVersionInfo: { current_version: '1.0.0', latest_version: '', version: '' }, + workspacePermissionKeys: ['plugin.install'], + } as ReturnType) + + vi.mocked(usePluginPermissionSettings).mockReturnValue({ + data: { + install_permission: PermissionType.everyone, + debug_permission: PermissionType.everyone, + }, + } as ReturnType) + + const { result } = renderHook(() => useReferenceSetting(PluginCategoryEnum.tool), { + systemFeatures: { rbac_enabled: false }, + }) + + expect(result.current.canDebugPlugin).toBe(true) + expect(result.current.canDebugger).toBe(true) }) it('should use plugin keys even when legacy admin permission is configured and RBAC is enabled', () => { diff --git a/web/app/components/plugins/plugin-page/use-reference-setting.ts b/web/app/components/plugins/plugin-page/use-reference-setting.ts index 20c306658fc..b2bce30f75c 100644 --- a/web/app/components/plugins/plugin-page/use-reference-setting.ts +++ b/web/app/components/plugins/plugin-page/use-reference-setting.ts @@ -52,7 +52,9 @@ export const usePluginSettingsAccess = () => { const canInstallPlugin = hasPermission(workspacePermissionKeys, 'plugin.install') && legacyCanInstallPlugin const canUpdatePlugin = hasPermission(workspacePermissionKeys, 'plugin.install') && legacyCanInstallPlugin const canDeletePlugin = hasPermission(workspacePermissionKeys, 'plugin.delete') && legacyCanInstallPlugin - const canDebugPlugin = hasPermission(workspacePermissionKeys, 'plugin.debug') && legacyCanDebugPlugin + const canDebugPlugin = rbacEnabled + ? hasPermission(workspacePermissionKeys, 'plugin.debug') + : legacyCanDebugPlugin return { permission: permissions,