Skip to content

Commit f8daddc

Browse files
committed
#278 open bookmarks from dashboard as well
1 parent 6e1a6d0 commit f8daddc

2 files changed

Lines changed: 59 additions & 30 deletions

File tree

e2e/bookmarks.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,27 @@ test.describe('Dashboard bookmarks', () => {
117117
await expect(page.getByText('superset.example.com')).toBeVisible();
118118
});
119119

120+
test('opens dashboard bookmark images and titles in a new tab', async ({ page }) => {
121+
await page.goto('/');
122+
await waitForHydration(page);
123+
124+
await page.getByRole('button', { name: addButton }).click();
125+
await page.getByLabel('Name').fill('Dashboards');
126+
await page.getByLabel('URL').fill('https://superset.example.com');
127+
await page.locator('dialog[open]').getByRole('button', { name: addButton }).click();
128+
129+
const bookmarkSection = page.getByLabel('Bookmarks');
130+
const titleLink = bookmarkSection.getByRole('link', { name: 'Dashboards' });
131+
const imageLink = bookmarkSection.getByRole('link', { name: 'Trino' });
132+
133+
await expect(titleLink).toHaveAttribute('href', 'https://superset.example.com');
134+
await expect(titleLink).toHaveAttribute('target', '_blank');
135+
await expect(titleLink).toHaveAttribute('rel', /noopener/);
136+
await expect(imageLink).toHaveAttribute('href', 'https://superset.example.com');
137+
await expect(imageLink).toHaveAttribute('target', '_blank');
138+
await expect(imageLink).toHaveAttribute('rel', /noopener/);
139+
});
140+
120141
test('bookmark persists in localStorage', async ({ page }) => {
121142
await page.goto('/');
122143
await waitForHydration(page);

src/routes/(app)/+page.svelte

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,39 +76,47 @@
7676
{#each bookmarks as bookmark (bookmark.id)}
7777
{@const product = getProduct(bookmark.productId)}
7878
<div class="border-base-300 bg-base-100 flex items-center gap-3 rounded-lg border p-3">
79-
{#if product.logo}
80-
<enhanced:img
81-
src={product.logo}
82-
alt={product.name}
83-
class="size-[38px] shrink-0 rounded-md bg-white object-contain p-1"
84-
onerror={handleProductLogoError}
85-
/>
86-
<span
87-
class="hidden size-[38px] shrink-0 items-center justify-center rounded-md font-mono text-xs font-bold text-white"
88-
style="background-color: {product.color}"
89-
aria-hidden="true"
90-
>
91-
{product.initials}
92-
</span>
93-
{:else}
94-
<span
95-
class="flex size-[38px] shrink-0 items-center justify-center rounded-md font-mono text-xs font-bold text-white"
96-
style="background-color: {product.color}"
97-
aria-hidden="true"
98-
>
99-
{product.initials}
100-
</span>
101-
{/if}
79+
<a href={bookmark.url} target="_blank" rel="noopener noreferrer" class="shrink-0">
80+
{#if product.logo}
81+
<enhanced:img
82+
src={product.logo}
83+
alt={product.name}
84+
class="size-[38px] rounded-md bg-white object-contain p-1"
85+
onerror={handleProductLogoError}
86+
/>
87+
<span
88+
class="hidden size-[38px] items-center justify-center rounded-md font-mono text-xs font-bold text-white"
89+
style="background-color: {product.color}"
90+
aria-hidden="true"
91+
>
92+
{product.initials}
93+
</span>
94+
{:else}
95+
<span
96+
class="flex size-[38px] items-center justify-center rounded-md font-mono text-xs font-bold text-white"
97+
style="background-color: {product.color}"
98+
aria-hidden="true"
99+
>
100+
{product.initials}
101+
</span>
102+
{/if}
103+
</a>
102104
<div class="min-w-0 flex-1">
103105
<div class="flex min-w-0 items-baseline gap-1.5">
104-
<span class="text-base-content truncate text-[13.5px] leading-tight font-bold">
106+
<a
107+
href={bookmark.url}
108+
target="_blank"
109+
rel="noopener noreferrer"
110+
class="text-base-content truncate text-[13.5px] leading-tight font-bold"
111+
>
105112
{bookmark.name}
106-
</span>
107-
{#if bookmark.environment}
108-
<span class="text-base-content/70 shrink-0 text-[13px]"
109-
>{bookmark.environment}</span
110-
>
111-
{/if}
113+
{#if bookmark.environment}
114+
<span
115+
class="text-base-content/70 shrink-0 text-[13px] leading-loose font-normal"
116+
>{bookmark.environment}</span
117+
>
118+
{/if}
119+
</a>
112120
</div>
113121
<div class="mt-1 flex flex-wrap items-center gap-1.5">
114122
<span class="bg-base-300 text-base-content/60 rounded-full px-2 py-0.5 text-[11px]">

0 commit comments

Comments
 (0)