fix: update agent permission check logic in AgentPanel to simplify condition

This commit is contained in:
Atef Bellaaj 2025-06-23 13:39:50 +02:00 committed by Danny Avila
parent 8ea2329cff
commit 7d8a29a7b4
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
3 changed files with 4 additions and 2 deletions

View file

@ -1,6 +1,7 @@
jest.mock('~/models', () => ({ jest.mock('~/models', () => ({
initializeRoles: jest.fn(), initializeRoles: jest.fn(),
seedDefaultRoles: jest.fn(), seedDefaultRoles: jest.fn(),
ensureDefaultCategories: jest.fn(),
})); }));
jest.mock('~/models/Role', () => ({ jest.mock('~/models/Role', () => ({
updateAccessPermissions: jest.fn(), updateAccessPermissions: jest.fn(),

View file

@ -29,6 +29,7 @@ jest.mock('./Files/Firebase/initialize', () => ({
jest.mock('~/models', () => ({ jest.mock('~/models', () => ({
initializeRoles: jest.fn(), initializeRoles: jest.fn(),
seedDefaultRoles: jest.fn(), seedDefaultRoles: jest.fn(),
ensureDefaultCategories: jest.fn(),
})); }));
jest.mock('~/models/Role', () => ({ jest.mock('~/models/Role', () => ({
updateAccessPermissions: jest.fn(), updateAccessPermissions: jest.fn(),

View file

@ -280,12 +280,12 @@ export default function AgentPanel({
return true; return true;
} }
if (agentQuery.data?.author === user?.id || user?.role === SystemRoles.ADMIN) { if (user?.role === SystemRoles.ADMIN) {
return true; return true;
} }
return canEdit; return canEdit;
}, [agentQuery.data?.author, agentQuery.data?.id, user?.id, user?.role, canEdit]); }, [agentQuery.data?.id, user?.id, user?.role, canEdit]);
return ( return (
<FormProvider {...methods}> <FormProvider {...methods}>