fix(frontend): align sharing UI with the merged role-grants backend
The merge brought in main's ReBAC→role-grants migration, which changed the grant contract the Svelte sharing UI (branched before it) was written against: GrantDto dropped `permission` and now carries an explicit `role` (owner/editor/viewer/commenter/contributor), and the "admin" role was renamed "owner". Left unchanged, the share UI derived roles from a now-absent `permission` field and showed every member as "viewer". - grants.ts: ShareRole is now viewer|editor|owner; Grant carries `role` (not `permission`); `roleFromPermissions` → `displayRole`, which collapses the unexposed commenter→viewer and contributor→editor. - ShareDialog.svelte: read each subject's role directly (role-grants emits one row per subject); role picker exposes Owner instead of Admin. - shared/+page.svelte (My Shares): same owner rename; role badges run through displayRole so server-only roles render sensibly. Create/update already POST `role`, so only the read/display path and the role literal needed fixing. npm run check, test:unit (36) and build pass.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import { goto } from '$app/navigation';
|
||||
import { onMount } from 'svelte';
|
||||
import {
|
||||
displayRole,
|
||||
expiryToIso,
|
||||
fetchMyShares,
|
||||
notifyGrantRecipient,
|
||||
@@ -33,12 +34,12 @@
|
||||
];
|
||||
|
||||
const ROLES: { v: ShareRole; l: string; icon: string }[] = [
|
||||
{ v: 'admin', l: t('share.role.canManage', 'Can manage'), icon: 'crown' },
|
||||
{ v: 'owner', l: t('share.role.canManage', 'Can manage'), icon: 'crown' },
|
||||
{ v: 'editor', l: t('share.role.canEdit', 'Can edit'), icon: 'pencil-alt' },
|
||||
{ v: 'viewer', l: t('share.role.canView', 'Can view'), icon: 'eye' }
|
||||
];
|
||||
function roleMeta(r: string) {
|
||||
return ROLES.find((x) => x.v === r) ?? ROLES[2];
|
||||
return ROLES.find((x) => x.v === displayRole(r)) ?? ROLES[2];
|
||||
}
|
||||
|
||||
let raw = $state<OutgoingGrantItem[]>([]);
|
||||
|
||||
Reference in New Issue
Block a user