From 9baccd3407650a8fa76b366d73076ef40979cdd1 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 20 Aug 2026 22:31:56 +0530 Subject: [PATCH] fix(permissions): render member roles instead of marking them unresolvable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parsePermission only recognised user and team, so a member role fell through to the invalid branch: it rendered as a raw truncated string in the styling reserved for a deleted entity, and its hover card showed the missing-entity avatar — presenting a perfectly valid grant as broken. It also called onNotFound. Nothing passes that callback today, but d36135f5b wired it to auto-remove stale roles before row.svelte moved to runes turned the event into a prop and left the consumer behind. If that wiring is restored, member roles would be silently deleted from any resource a user merely opened. A membership can only be read through its team or its user, and the role string carries neither, so the ID stands in for a name. That is still an improvement on the raw role: the badge now reads Member and the hover card offers the membership ID to copy. --- src/lib/components/permissions/custom.svelte | 4 +- src/lib/components/permissions/row.svelte | 56 +++++++++++++++++--- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/lib/components/permissions/custom.svelte b/src/lib/components/permissions/custom.svelte index 64c08d9fc..832db9157 100644 --- a/src/lib/components/permissions/custom.svelte +++ b/src/lib/components/permissions/custom.svelte @@ -34,8 +34,8 @@ required id="custom-permission" label="Role" - placeholder="user:[USER_ID] or team:[TEAM_ID]/[ROLE]" - helper="A permission should be formatted as: user:[USER_ID] or team:[TEAM_ID]/[ROLE]¸" + placeholder="user:[USER_ID], team:[TEAM_ID]/[ROLE] or member:[MEMBERSHIP_ID]" + helper="A permission should be formatted as: user:[USER_ID], team:[TEAM_ID]/[ROLE] or member:[MEMBERSHIP_ID]" bind:value /> diff --git a/src/lib/components/permissions/row.svelte b/src/lib/components/permissions/row.svelte index aa44cb73a..c9e8c36d4 100644 --- a/src/lib/components/permissions/row.svelte +++ b/src/lib/components/permissions/row.svelte @@ -16,7 +16,7 @@ Typography } from '@appwrite.io/pink-svelte'; import Avatar from '../avatar.svelte'; - import { IconAnonymous, IconMinusSm } from '@appwrite.io/pink-icons-svelte'; + import { IconAnonymous, IconMinusSm, IconUsers } from '@appwrite.io/pink-icons-svelte'; import { page } from '$app/state'; import { menuOpen } from '$lib/components/menu/store'; import { base } from '$app/paths'; @@ -39,8 +39,10 @@ let { role, placement = 'bottom-start', children, onNotFound }: Props = $props(); + const parsedRole = $derived(parsePermission(role)); + type ParsedPermission = { - type: 'user' | 'team' | 'other'; + type: 'user' | 'team' | 'member' | 'other'; id: string; roleName?: string; isValid: boolean; @@ -58,9 +60,9 @@ return { type: 'other', id: permission, isValid: false }; } - if (type === 'user' || type === 'team') { + if (type === 'user' || type === 'team' || type === 'member') { return { - type: type as 'user' | 'team', + type: type as 'user' | 'team' | 'member', id, roleName, isValid: true @@ -78,6 +80,12 @@ return { notFound: true, roleName: parsed.roleName, customName: parsed.id }; } + // A membership can only be read through its team or its user, neither of which the role + // carries, so the ID is shown as-is rather than reported as a role that no longer exists. + if (parsed.type === 'member') { + return { roleName: parsed.roleName, customName: parsed.id }; + } + if (parsed.type === 'user') { try { return await sdk @@ -177,7 +185,7 @@ {role} {:then data} {formatName( - data.name ?? data?.email ?? data?.phone ?? '-', + data.name ?? data?.email ?? data?.phone ?? data?.customName ?? '-', $isSmallViewport ? 16 : 20 )} {/await} @@ -185,7 +193,11 @@ + content={parsedRole.type === 'member' + ? 'Member' + : parsedRole.type === 'user' + ? 'User' + : 'Team'} /> {/if} @@ -205,7 +217,37 @@ {:then data} - {#if data.notFound} + {#if parsedRole.type === 'member'} + + + + + + + + + + Team membership + + + + + + + {:else if data.notFound}