diff --git a/AGENTS.md b/AGENTS.md index 0b6ef049..f48869cb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,7 +35,7 @@ Single SvelteKit application (not a monorepo). ├── src/ │ ├── lib/ │ │ ├── server/ # Server-only code: auth, db, logging, metrics, feature flags, trino/, storage/ -│ │ ├── components/ # Svelte components (shared ones at top level, per-module subfolders) +│ │ ├── components/ # Svelte components: ui/ (generic), app-wide at top level and layout/, per-module subfolders │ │ ├── client/ # Client-only utilities │ │ ├── stores/ # Svelte stores (*.svelte.ts) │ │ ├── storage/ # Client-side storage module logic @@ -140,6 +140,16 @@ Environment variables are parsed with zod at startup using the helpers in `src/l Document new variables in `README.md` and `.env.example`; don't read `env` ad hoc. +### Component Layers + +`src/lib/components/` is split by what a component depends on. Each layer may only use the layers above it: + +1. **`ui/`** — generic building blocks (`Modal`, `TooltipTrigger`, `TabBar`, ...). Data comes in through props, results go out through callbacks or `bind:`. They may import Svelte, icons, Paraglide messages, `$lib/types` and other `ui/` components, nothing else (enforced by ESLint). +2. **Top level and `layout/`** — app-wide components that know the app (stores, routes, session), e.g. `ErrorPanel`, `ToastHost`, the header and sidebar. +3. **`/`** — feature components. Pieces shared only within one module go into `/shared/`; move them to `ui/` once a second module needs them and they have no module dependencies. + +Before writing a new component, check DaisyUI and the existing `ui/` components. + ### Code Style & Best Practices - Run `npm run format`. @@ -213,7 +223,7 @@ pre-commit run --all-files # All of the above plus markdownlint, yamllint, she Most conventions in this file are checked automatically; fix violations instead of disabling rules. -- **ESLint** (`eslint.config.js`): no server imports from client code (`src/lib/client`, `stores`, `storage`, `editor`, `types`) and vice versa, file naming (PascalCase components, stores as `*.svelte.ts`), file size limits (`max-lines`), no `` outside `Modal.svelte`, a subset of hard-coded colour classes (`bg-white`, `text-gray-*`, ...), no `console` in server code. +- **ESLint** (`eslint.config.js`): no server imports from client code (`src/lib/client`, `stores`, `storage`, `editor`, `types`) and vice versa, file naming (PascalCase components, stores as `*.svelte.ts`), file size limits (`max-lines`), no `` outside `ui/Modal.svelte`, `ui/` components importing app code, a subset of hard-coded colour classes (`bg-white`, `text-gray-*`, ...), no `console` in server code. - **Architecture tests** (`npm run test:arch`, `src/architecture-tests/`): no circular dependencies in `src/lib` and `src/routes`, i18n key parity and no unused message keys, no static English `aria-label`, no native date inputs, `` with `alt`, no clickable `
`/``, no low-opacity `text-base-content` for text (use `text-muted`). `npm run test:arch:report` additionally writes dependency/metrics reports to `reports/`. When you add a new architectural rule, prefer an ESLint rule; otherwise add a `.spec.ts` in `src/architecture-tests/` following the existing patterns. diff --git a/e2e/storage/context-menu.spec.ts b/e2e/storage/context-menu.spec.ts index 9c92f3d9..2985aef8 100644 --- a/e2e/storage/context-menu.spec.ts +++ b/e2e/storage/context-menu.spec.ts @@ -68,6 +68,68 @@ test.describe('Storage S3 — Context Menu', () => { } }); + test('a right-click elsewhere replaces the open context menu', async ({ page }, testInfo) => { + const credentials = requireGarageCredentials(); + const client = createS3Client(credentials); + const prefix = uniquePrefix(testInfo, 'ctx-replace'); + const cleanupKeys = [`${prefix}first.txt`, `${prefix}second.txt`]; + + try { + for (const key of cleanupKeys) await putTextObject(client, credentials.bucket, key, 'x'); + + await connectAndOpenPrefix(page, credentials, prefix); + + const menu = page.getByRole('menu'); + await rowByName(page, 'first.txt').click({ button: 'right' }); + await expect(menu).toBeVisible(); + + // Another row of the same list moves the menu and keeps that row selected. + await rowByName(page, 'second.txt').click({ button: 'right', position: { x: 10, y: 10 } }); + await expect(menu).toHaveCount(1); + await expect(menu.getByRole('menuitem', { name: 'Preview' })).toBeVisible(); + await expect(page.getByText('1 selected')).toBeVisible(); + + // Another component's target opens its own menu instead. + const sidebar = page.getByRole('navigation', { name: 'Buckets' }); + await sidebar.getByText(credentials.bucket).click({ button: 'right' }); + await expect(menu).toHaveCount(1); + await expect(menu.getByRole('menuitem', { name: 'Details' })).toBeVisible(); + } finally { + await deleteKnownKeys(client, credentials.bucket, cleanupKeys); + } + }); + + test('unpins a pinned location from its sidebar menu', async ({ page }, testInfo) => { + const credentials = requireGarageCredentials(); + const client = createS3Client(credentials); + const prefix = uniquePrefix(testInfo, 'ctx-unpin'); + const cleanupKeys = [`${prefix}file.txt`]; + + try { + await putTextObject(client, credentials.bucket, cleanupKeys[0], 'x'); + await connectAndOpenPrefix(page, credentials, prefix); + + const breadcrumb = page.getByRole('navigation', { name: 'Breadcrumb' }); + await breadcrumb.getByText(credentials.bucket).hover(); + await page + .getByRole('button', { name: 'Pin this location' }) + .filter({ visible: true }) + .first() + .click(); + const sidebar = page.getByRole('navigation', { name: 'Buckets' }); + await expect(sidebar.getByText('Pinned Access')).toBeVisible(); + + await sidebar.getByRole('button', { name: 'More options' }).click({ force: true }); + const menu = page.getByRole('menu', { name: 'Actions' }); + await menu.getByRole('menuitem', { name: 'Unpin' }).click(); + + await expect(menu).toHaveCount(0); + await expect(sidebar.getByText('Pinned Access')).toHaveCount(0); + } finally { + await deleteKnownKeys(client, credentials.bucket, cleanupKeys); + } + }); + test('deletes a single file via context menu', async ({ page }, testInfo) => { const credentials = requireGarageCredentials(); const client = createS3Client(credentials); diff --git a/e2e/storage/details.spec.ts b/e2e/storage/details.spec.ts index fcec5179..27d94d76 100644 --- a/e2e/storage/details.spec.ts +++ b/e2e/storage/details.spec.ts @@ -97,6 +97,52 @@ test.describe('Storage S3 — Details Modal', () => { } }); + test('treemap context menu works on top of the details modal', async ({ + page, + context, + browserName + }, testInfo) => { + const credentials = requireGarageCredentials(); + const client = createS3Client(credentials); + const prefix = uniquePrefix(testInfo, 'details-treemap'); + const cleanupKeys = [`${prefix}subdir/big.txt`]; + + try { + await putTextObject(client, credentials.bucket, cleanupKeys[0], 'x'.repeat(2048)); + // Firefox cannot grant clipboard permissions; the copy itself still runs there. + if (browserName === 'chromium') { + await context.grantPermissions(['clipboard-read', 'clipboard-write']); + } + + await connectAndOpenPrefix(page, credentials, prefix); + await rowByName(page, 'subdir').click({ button: 'right' }); + await page.getByRole('menuitem', { name: 'Details' }).click(); + + const modal = modalBox(page); + await modal.getByRole('button', { name: 'Calculate directory size' }).click(); + await modal.getByRole('tab', { name: 'Size composition' }).click(); + const leaf = modal.getByRole('treeitem', { name: /big\.txt/ }); + + // Escape closes only the menu, not the modal underneath. + const menu = page.getByRole('menu'); + await leaf.click({ button: 'right' }); + await expect(menu).toBeVisible(); + await page.keyboard.press('Escape'); + await expect(menu).toHaveCount(0); + await expect(modal).toBeVisible(); + + await leaf.click({ button: 'right' }); + await menu.getByRole('menuitem', { name: 'Copy file name' }).click(); + await expect(menu).toHaveCount(0); + await expect(modal).toBeVisible(); + if (browserName === 'chromium') { + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe('big.txt'); + } + } finally { + await deleteKnownKeys(client, credentials.bucket, cleanupKeys); + } + }); + test('explains a failed size calculation', async ({ page }, testInfo) => { const credentials = requireGarageCredentials(); const client = createS3Client(credentials); diff --git a/eslint.config.js b/eslint.config.js index 880f4a38..e2adae38 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -138,9 +138,38 @@ export default defineConfig( } }, { - files: ['src/lib/components/Modal.svelte'], + files: ['src/lib/components/ui/Modal.svelte'], rules: { 'svelte/no-restricted-html-elements': 'off' } }, + { + // Generic building blocks: everything comes in through props, so they must not depend on app + // state, routing or feature modules (see "Component Layers" in AGENTS.md). + files: ['src/lib/components/ui/**/*.{svelte,ts}'], + // Specs may load the global stylesheet to test against the real styles. + ignores: ['src/lib/components/ui/**/*.spec.ts'], + rules: { + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['$lib/*', '!$lib/paraglide', '!$lib/types', '!$lib/components'], + message: 'ui/ components may only import Paraglide messages, shared types and ui/.' + }, + { + group: ['$lib/components/*', '!$lib/components/ui'], + message: 'ui/ components must not import app or feature components.' + }, + { + group: ['$app/*'], + message: 'ui/ components must not depend on SvelteKit app state.' + }, + { group: ['../*'], message: 'ui/ components must not import from outside ui/.' } + ] + } + ] + } + }, { files: [ 'src/lib/client/**/*.ts', diff --git a/src/architecture-tests/ui-pattern-enforcement.spec.ts b/src/architecture-tests/ui-pattern-enforcement.spec.ts index c2581519..8471b301 100644 --- a/src/architecture-tests/ui-pattern-enforcement.spec.ts +++ b/src/architecture-tests/ui-pattern-enforcement.spec.ts @@ -44,7 +44,6 @@ describe('UI Pattern Enforcement', () => { const KNOWN_VIOLATION_PATHS = [ 'src/lib/components/catalog/CatalogTree.svelte', 'src/lib/components/storage/explorer/OperationsButton.svelte', - 'src/lib/components/storage/shared/FloatingMenu.svelte', 'src/lib/components/trino/StatementResult.svelte' ]; diff --git a/src/lib/components/dashboard/AddBookmarkModal.svelte b/src/lib/components/dashboard/AddBookmarkModal.svelte index b302a5b9..cbb9dbf6 100644 --- a/src/lib/components/dashboard/AddBookmarkModal.svelte +++ b/src/lib/components/dashboard/AddBookmarkModal.svelte @@ -1,6 +1,6 @@ - - - -{#if isOpen} - - - -{/if} diff --git a/src/lib/components/storage/explorer/FileExplorer.svelte b/src/lib/components/storage/explorer/FileExplorer.svelte index fdd17a84..2b5e8742 100644 --- a/src/lib/components/storage/explorer/FileExplorer.svelte +++ b/src/lib/components/storage/explorer/FileExplorer.svelte @@ -7,7 +7,6 @@ import { getTabsState } from '$lib/storage/context.js'; import { collectDroppedFiles } from '$lib/storage/file-collection.js'; import { storageTransferEnabled } from '$lib/client/feature-flags.js'; - import type { ContextMenuAction } from '$lib/storage/types.js'; import type { ActionName } from '$lib/storage/types.js'; import IconVisibility from 'virtual:icons/material-symbols/visibility'; import IconDownload from 'virtual:icons/material-symbols/download'; @@ -27,7 +26,7 @@ import StorageBreadcrumb from './StorageBreadcrumb.svelte'; import TabBar from './TabBar.svelte'; import ObjectTable from './ObjectTable.svelte'; - import ContextMenu from './ContextMenu.svelte'; + import ContextMenu, { type ContextMenuAction } from '$lib/components/ui/ContextMenu.svelte'; import Pagination from '$lib/components/Pagination.svelte'; const storage = getStorageState(); diff --git a/src/lib/components/storage/explorer/StorageBreadcrumb.svelte b/src/lib/components/storage/explorer/StorageBreadcrumb.svelte index dc42ba69..efe18c20 100644 --- a/src/lib/components/storage/explorer/StorageBreadcrumb.svelte +++ b/src/lib/components/storage/explorer/StorageBreadcrumb.svelte @@ -22,9 +22,8 @@ import { storageTransferEnabled } from '$lib/client/feature-flags.js'; import { parseStorageDrop, canStorageDrop } from '$lib/storage/drag-handlers.js'; import OperationsButton from './OperationsButton.svelte'; - import ContextMenu from './ContextMenu.svelte'; - import TooltipTrigger from '$lib/components/TooltipTrigger.svelte'; - import type { ContextMenuAction } from '$lib/storage/types.js'; + import ContextMenu, { type ContextMenuAction } from '$lib/components/ui/ContextMenu.svelte'; + import TooltipTrigger from '$lib/components/ui/TooltipTrigger.svelte'; const storage = getStorageState(); const uid = $props.id(); diff --git a/src/lib/components/storage/explorer/TabBar.svelte b/src/lib/components/storage/explorer/TabBar.svelte index 262352e3..8f5f6a10 100644 --- a/src/lib/components/storage/explorer/TabBar.svelte +++ b/src/lib/components/storage/explorer/TabBar.svelte @@ -5,12 +5,11 @@ import IconDriveFileRenameOutline from 'virtual:icons/material-symbols/drive-file-rename-outline'; import * as m from '$lib/paraglide/messages.js'; import type { TabsState } from '$lib/storage/tabs.svelte.js'; - import type { ContextMenuAction } from '$lib/storage/types.js'; import { getStorageState } from '$lib/storage/context.js'; import { storageTransferEnabled } from '$lib/client/feature-flags.js'; import { parseStorageDrop } from '$lib/storage/drag-handlers.js'; - import ContextMenu from './ContextMenu.svelte'; - import GenericTabBar, { type ExternalTabDrag } from '$lib/components/TabBar.svelte'; + import ContextMenu, { type ContextMenuAction } from '$lib/components/ui/ContextMenu.svelte'; + import GenericTabBar, { type ExternalTabDrag } from '$lib/components/ui/TabBar.svelte'; interface Props { tabsState: TabsState; diff --git a/src/lib/components/storage/explorer/__tests__/ContextMenu.svelte.spec.ts b/src/lib/components/storage/explorer/__tests__/ContextMenu.svelte.spec.ts deleted file mode 100644 index 994ca594..00000000 --- a/src/lib/components/storage/explorer/__tests__/ContextMenu.svelte.spec.ts +++ /dev/null @@ -1,239 +0,0 @@ -import { page } from 'vitest/browser'; -import { describe, expect, it, vi } from 'vitest'; -import { render } from 'vitest-browser-svelte'; -import { faker } from '@faker-js/faker'; -import { SvelteSet } from 'svelte/reactivity'; -import ContextMenuWrapper from './ContextMenuWrapper.svelte'; -import type { StorageObject } from '$lib/storage/types.js'; -import { StorageState } from '$lib/storage/state.svelte.js'; - -function makeFile(key: string): StorageObject { - return { - key, - size: faker.number.int({ min: 100, max: 10_000_000 }), - lastModified: faker.date.recent(), - isDirectory: false, - contentType: 'application/octet-stream' - }; -} - -function makeFolder(key: string): StorageObject { - return { - key, - size: 0, - lastModified: faker.date.recent(), - isDirectory: true, - contentType: undefined - }; -} - -function createState( - objects: StorageObject[] = [], - opts: { contextMenu?: { x: number; y: number; key: string }; selectedKeys?: string[] } = {} -): StorageState { - const state = new StorageState({ connected: true, buckets: ['test-bucket'] }); - state.bucket = 'test-bucket'; - state.prefix = ''; - state.objects = { - objects, - hasNextPage: false, - currentPage: 1, - pageSize: 25 - }; - if (opts.contextMenu) state.contextMenu = opts.contextMenu; - if (opts.selectedKeys) state.selectedKeys = new SvelteSet(opts.selectedKeys); - return state; -} - -describe('ContextMenu', () => { - it('should render menu with role="menu"', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - render(ContextMenuWrapper, { state }); - - await expect.element(page.getByRole('menu')).toBeInTheDocument(); - }); - - it('should show action buttons', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - render(ContextMenuWrapper, { state }); - - await expect.element(page.getByRole('menuitem', { name: 'Preview' })).toBeInTheDocument(); - await expect.element(page.getByRole('menuitem', { name: 'Download' })).toBeInTheDocument(); - await expect.element(page.getByRole('menuitem', { name: 'Delete' })).toBeInTheDocument(); - }); - - it('should disable preview when context is a folder', async () => { - const folder = makeFolder('docs/'); - const state = createState([folder], { - contextMenu: { x: 100, y: 100, key: 'docs/' }, - selectedKeys: ['docs/'] - }); - render(ContextMenuWrapper, { state }); - - const previewBtn = page.getByRole('menuitem', { name: 'Preview' }); - await expect.element(previewBtn).toHaveAttribute('disabled'); - }); - - it('should enable download when context is a folder', async () => { - const folder = makeFolder('docs/'); - const state = createState([folder], { - contextMenu: { x: 100, y: 100, key: 'docs/' }, - selectedKeys: ['docs/'] - }); - render(ContextMenuWrapper, { state }); - - const downloadBtn = page.getByRole('menuitem', { name: 'Download' }); - await expect.element(downloadBtn).not.toHaveAttribute('disabled'); - }); - - it('should enable download when context is a file', async () => { - const file = makeFile('report.pdf'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'report.pdf' }, - selectedKeys: ['report.pdf'] - }); - render(ContextMenuWrapper, { state }); - - const downloadBtn = page.getByRole('menuitem', { name: 'Download' }); - await expect.element(downloadBtn).not.toHaveAttribute('disabled'); - }); - - it('should close menu when close button is clicked', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - const spy = vi.spyOn(state, 'closeContextMenu'); - render(ContextMenuWrapper, { state, title: 'Menu' }); - - await page.getByRole('menuitem', { name: 'Close' }).click(); - expect(spy).toHaveBeenCalled(); - }); - - it('should close menu on Escape key', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - const spy = vi.spyOn(state, 'closeContextMenu'); - render(ContextMenuWrapper, { state }); - - document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); - expect(spy).toHaveBeenCalled(); - }); - - it('should execute action when action button is clicked', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - const spy = vi.spyOn(state, 'executeAction'); - render(ContextMenuWrapper, { state }); - - await page.getByRole('menuitem', { name: 'Delete' }).click(); - expect(spy).toHaveBeenCalledWith('delete'); - }); - - it('should position menu at context menu coordinates', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 200, y: 150, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - render(ContextMenuWrapper, { state }); - - const menu = page.getByRole('menu'); - await expect.element(menu).toBeInTheDocument(); - }); - - it('should adjust position when menu overflows viewport bottom', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: window.innerHeight - 10, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - render(ContextMenuWrapper, { state }); - - const menu = page.getByRole('menu'); - await expect.element(menu).toBeInTheDocument(); - const el = menu.element() as HTMLElement; - const top = parseInt(el.style.top); - expect(top).toBeLessThan(window.innerHeight - 10); - }); - - it('should not close menu when clicking inside it', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - const spy = vi.spyOn(state, 'closeContextMenu'); - render(ContextMenuWrapper, { state }); - - const menu = page.getByRole('menu'); - await menu.click(); - expect(spy).not.toHaveBeenCalled(); - }); - - it('should execute action when clicking an enabled action button (preview)', async () => { - const file = makeFile('photo.png'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'photo.png' }, - selectedKeys: ['photo.png'] - }); - const spy = vi.spyOn(state, 'executeAction'); - render(ContextMenuWrapper, { state }); - - await page.getByRole('menuitem', { name: 'Preview' }).click(); - expect(spy).toHaveBeenCalledWith('preview'); - }); - - it('should execute download action', async () => { - const file = makeFile('data.csv'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'data.csv' }, - selectedKeys: ['data.csv'] - }); - const spy = vi.spyOn(state, 'executeAction'); - render(ContextMenuWrapper, { state }); - - await page.getByRole('menuitem', { name: 'Download' }).click(); - expect(spy).toHaveBeenCalledWith('download'); - }); - - it('should not close menu on non-Escape key', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: ['test.txt'] - }); - const spy = vi.spyOn(state, 'closeContextMenu'); - render(ContextMenuWrapper, { state }); - - document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })); - expect(spy).not.toHaveBeenCalled(); - }); - - it('should disable delete when no items are selected', async () => { - const file = makeFile('test.txt'); - const state = createState([file], { - contextMenu: { x: 100, y: 100, key: 'test.txt' }, - selectedKeys: [] - }); - render(ContextMenuWrapper, { state }); - - const deleteBtn = page.getByRole('menuitem', { name: 'Delete' }); - await expect.element(deleteBtn).toHaveAttribute('disabled'); - }); -}); diff --git a/src/lib/components/storage/explorer/__tests__/ContextMenuWrapper.svelte b/src/lib/components/storage/explorer/__tests__/ContextMenuWrapper.svelte deleted file mode 100644 index db8496e3..00000000 --- a/src/lib/components/storage/explorer/__tests__/ContextMenuWrapper.svelte +++ /dev/null @@ -1,51 +0,0 @@ - - - state.closeContextMenu()} - onaction={(key) => state.executeAction(key as 'preview' | 'download' | 'delete')} - {actions} - {title} -/> diff --git a/src/lib/components/storage/explorer/__tests__/FileExplorer.svelte.spec.ts b/src/lib/components/storage/explorer/__tests__/FileExplorer.svelte.spec.ts index e5fea596..57bcfc1a 100644 --- a/src/lib/components/storage/explorer/__tests__/FileExplorer.svelte.spec.ts +++ b/src/lib/components/storage/explorer/__tests__/FileExplorer.svelte.spec.ts @@ -154,8 +154,8 @@ describe('FileExplorer', () => { const state = createState([makeFile('test.txt')]); render(FileExplorerWrapper, { state }); - // Context menu title "Actions" should not be present - expect(page.getByText('Actions').elements().length).toBe(0); + await expect.element(page.getByText('Page 1')).toBeInTheDocument(); + expect(document.querySelector('[popover]:popover-open')).toBeNull(); }); it('should render pagination', async () => { diff --git a/src/lib/components/storage/explorer/__tests__/StorageBreadcrumb.svelte.spec.ts b/src/lib/components/storage/explorer/__tests__/StorageBreadcrumb.svelte.spec.ts index 50111caa..3d5213a8 100644 --- a/src/lib/components/storage/explorer/__tests__/StorageBreadcrumb.svelte.spec.ts +++ b/src/lib/components/storage/explorer/__tests__/StorageBreadcrumb.svelte.spec.ts @@ -384,29 +384,6 @@ describe('StorageBreadcrumb', () => { expect(spy).toHaveBeenCalledWith('test-bucket', ''); }); - it('should close context menu when clicking outside', async () => { - const state = createState({ bucket: 'test-bucket' }); - render(StorageBreadcrumbWrapper, { state }); - - const nav = page.getByRole('navigation', { name: 'breadcrumb' }); - const bucketEl = nav.getByText('test-bucket'); - await bucketEl.click({ button: 'right' }); - - // Context menu should be open - it's the fixed-position menu - const ctxMenuItems = page.getByRole('menuitem'); - await expect.element(ctxMenuItems.first()).toBeInTheDocument(); - - // The backdrop is a fixed inset-0 div that's a sibling before the context menu - // Dispatch mousedown on it to trigger closeBreadcrumbCtx - const menuEl = (await ctxMenuItems.first().element()) as HTMLElement; - const menuUl = menuEl.closest('ul[role="menu"]')!; - const backdrop = menuUl.previousElementSibling as HTMLElement; - backdrop.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })); - - // Context menu should be closed. - await expect.element(page.getByRole('menuitem').first()).not.toBeInTheDocument(); - }); - it('should open context menu on right-click of bucket with prefix', async () => { const state = createState({ bucket: 'data', prefix: 'reports/' }); render(StorageBreadcrumbWrapper, { state }); diff --git a/src/lib/components/storage/landing/BucketGrid.svelte b/src/lib/components/storage/landing/BucketGrid.svelte index 5feabd73..df2d6f95 100644 --- a/src/lib/components/storage/landing/BucketGrid.svelte +++ b/src/lib/components/storage/landing/BucketGrid.svelte @@ -1,11 +1,11 @@ - - - + onaction={() => ctxMenu && openDetails(ctxMenu.bucket)} + actions={[{ key: 'details', icon: IconInfo, label: m.storage_action_details() }]} +/> {#if loading || !storage.connectionHostname}
- import Modal from '$lib/components/Modal.svelte'; + import Modal from '$lib/components/ui/Modal.svelte'; import IconDeleteForever from 'virtual:icons/material-symbols/delete-forever'; import IconWarningRounded from 'virtual:icons/material-symbols/warning-rounded'; import * as m from '$lib/paraglide/messages.js'; diff --git a/src/lib/components/storage/modals/DeleteConnectionModal.svelte b/src/lib/components/storage/modals/DeleteConnectionModal.svelte index f47766e3..919734c0 100644 --- a/src/lib/components/storage/modals/DeleteConnectionModal.svelte +++ b/src/lib/components/storage/modals/DeleteConnectionModal.svelte @@ -1,8 +1,8 @@ - -{#if open} - - -{/if} diff --git a/src/lib/components/storage/sidebar/BucketList.svelte b/src/lib/components/storage/sidebar/BucketList.svelte index f6c56dcc..9bd90d9e 100644 --- a/src/lib/components/storage/sidebar/BucketList.svelte +++ b/src/lib/components/storage/sidebar/BucketList.svelte @@ -1,7 +1,6 @@ - - - -{#if unpinCtx} -
    node.focus()} - class=" - menu menu-sm border-base-300 bg-base-100 fixed z-150 w-48 rounded-lg - border p-1 shadow-lg - " - role="menu" - tabindex="-1" - style="left: {adjustedPos.left}px; top: {adjustedPos.top}px;" - > - -
  • - -
  • -
-{/if} +