permission check update

This commit is contained in:
Nate Kelley 2025-09-20 13:40:42 -06:00
parent 9efdf2c67b
commit f406dd5ca3
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 21 additions and 20 deletions

View File

@ -80,10 +80,8 @@ export const ReportThreeDotMenu = React.memo(
isEffectiveOwner && !isViewingOldVersion && shareMenu,
saveToLibrary,
favoriteItem,
{ type: 'divider' },
...undoRedo,
{ type: 'divider' },
versionHistory,
...(isEditor ? [{ type: 'divider' }, ...undoRedo] : []),
...(isEditor ? [{ type: 'divider' }, versionHistory] : []),
// verificationItem, // Hidden - not supported yet
{ type: 'divider' },
isEditor && refreshReportItem,

View File

@ -6,11 +6,7 @@ import {
import type { User } from '@buster/database/queries';
import type { AssetType } from '@buster/database/schema-types';
import type { AssetPermissionRole, OrganizationMembership, WorkspaceSharing } from '../types';
import {
getHighestPermission,
isPermissionSufficient,
isPermissionSufficientForAny,
} from '../types/asset-permissions';
import { getHighestPermission, isPermissionSufficientForAny } from '../types/asset-permissions';
import { getCachedPermission, setCachedPermission } from './cache';
import { checkCascadingPermissions } from './cascading-permissions';
@ -40,6 +36,7 @@ export async function checkPermission(check: AssetPermissionCheck): Promise<Asse
// Check cache first (using serialized array as key)
const cached = getCachedPermission(userId, assetId, assetType, requiredRoles);
if (cached !== undefined) {
return cached;
}
@ -157,18 +154,24 @@ export function computeEffectivePermission(
* Map workspace sharing level to permission role
*/
function mapWorkspaceSharingToRole(workspaceSharing: WorkspaceSharing): AssetPermissionRole | null {
switch (workspaceSharing) {
case 'can_view':
return 'can_view';
case 'can_edit':
return 'can_edit';
case 'full_access':
return 'full_access';
case 'none':
return null;
default:
return null;
if (workspaceSharing === 'can_view') {
return 'can_view';
}
if (workspaceSharing === 'can_edit') {
return 'can_edit';
}
if (workspaceSharing === 'full_access') {
return 'full_access';
}
if (workspaceSharing === 'none') {
return null;
}
const _exhaustiveCheck: never = workspaceSharing;
return null;
}
/**