Skip to content

Commit 1c09aff

Browse files
authored
Merge pull request #2559 from appwrite/fix-SER-414-more-permissions-ui-issues
Fix: few permissions UI improvements
2 parents 4f69195 + 754ea7d commit 1c09aff

2 files changed

Lines changed: 33 additions & 26 deletions

File tree

src/lib/components/permissions/permissions.svelte

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import { IconPlus, IconX } from '@appwrite.io/pink-icons-svelte';
2121
import type { PinkColumn } from '$lib/helpers/types';
2222
import { Card } from '$lib/components';
23+
import { TableScroll } from '$lib/elements/table';
2324
2425
export let withCreate = false;
2526
export let permissions: string[] = [];
@@ -124,7 +125,7 @@
124125
</script>
125126

126127
{#if [...$groups]?.length}
127-
<div class="table-wrapper">
128+
<TableScroll>
128129
<Table.Root {columns} let:root>
129130
<svelte:fragment slot="header" let:root>
130131
<Table.Header.Cell column="role" {root}>Role</Table.Header.Cell>
@@ -139,7 +140,7 @@
139140
{#each [...$groups] as [role, permission] (role)}
140141
<Table.Row.Base {root}>
141142
<Table.Cell column="role" {root}>
142-
<Row {role} />
143+
<Row {role} onNotFound={() => deleteRole(role)} />
143144
</Table.Cell>
144145
<Table.Cell column="create" {root}>
145146
<Selector.Checkbox
@@ -174,7 +175,7 @@
174175
</Table.Row.Base>
175176
{/each}
176177
</Table.Root>
177-
</div>
178+
</TableScroll>
178179

179180
<div>
180181
<Actions
@@ -210,14 +211,3 @@
210211
</Layout.Stack>
211212
</Card>
212213
{/if}
213-
214-
<style lang="scss">
215-
.table-wrapper {
216-
scrollbar-width: none;
217-
-ms-overflow-style: none;
218-
219-
&::-webkit-scrollbar {
220-
display: none;
221-
}
222-
}
223-
</style>

src/lib/components/permissions/row.svelte

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { type ComponentProps, type Snippet } from 'svelte';
2+
import { type ComponentProps, type Snippet, onMount } from 'svelte';
33
import { sdk } from '$lib/stores/sdk';
44
import type { Models } from '@appwrite.io/console';
55
import { AvatarInitials } from '../';
@@ -34,9 +34,10 @@
3434
role: string;
3535
placement?: ComponentProps<Popover>['placement'];
3636
children?: Snippet;
37+
onNotFound?: (role: string) => void;
3738
}
3839
39-
let { role, placement = 'bottom-start', children }: Props = $props();
40+
let { role, placement = 'bottom-start', children, onNotFound }: Props = $props();
4041
4142
type ParsedPermission = {
4243
type: 'user' | 'team' | 'other';
@@ -111,6 +112,21 @@
111112
return fetchPromise;
112113
}
113114
115+
async function verifyExistence() {
116+
try {
117+
const data = await getData(role);
118+
if (data?.notFound) {
119+
onNotFound?.(role);
120+
}
121+
} catch {
122+
// Intentionally ignore fetch/parse errors; UI handles missing data state
123+
}
124+
}
125+
126+
onMount(() => {
127+
verifyExistence();
128+
});
129+
114130
let isMouseOverTooltip = $state(false);
115131
function hidePopover(hideTooltip: () => void, timeout = true) {
116132
if (!timeout) {
@@ -162,7 +178,7 @@
162178
{:then data}
163179
{formatName(
164180
data.name ?? data?.email ?? data?.phone ?? '-',
165-
$isSmallViewport ? 16 : 18
181+
$isSmallViewport ? 16 : 20
166182
)}
167183
{/await}
168184
</Typography.Text>
@@ -281,20 +297,21 @@
281297
<Divider />
282298
<Layout.Stack gap="xxs" alignItems="flex-start">
283299
{#if data.email}
284-
<Typography.Text
285-
size="xs"
286-
variant="m-400"
300+
<Typography.Caption
301+
variant="400"
287302
color="--fgcolor-neutral-secondary">
288-
Email: {data.email}
289-
</Typography.Text>
303+
Email: {formatName(
304+
data.email,
305+
$isSmallViewport ? 24 : 32
306+
)}
307+
</Typography.Caption>
290308
{/if}
291309
{#if data.phone}
292-
<Typography.Text
293-
size="xs"
294-
variant="m-400"
310+
<Typography.Caption
311+
variant="400"
295312
color="--fgcolor-neutral-secondary">
296313
Phone: {data.phone}
297-
</Typography.Text>
314+
</Typography.Caption>
298315
{/if}
299316
</Layout.Stack>
300317
{/if}

0 commit comments

Comments
 (0)