diff --git a/src/components/compute/TesDataRefDialog.test.ts b/src/components/compute/TesDataRefDialog.test.ts new file mode 100644 index 000000000..f96f0f21e --- /dev/null +++ b/src/components/compute/TesDataRefDialog.test.ts @@ -0,0 +1,57 @@ +import { defineComponent, h, ref } from 'vue' +import * as VueRuntime from 'vue' +import { describe, expect, it } from 'vitest' +import * as Tes from '@/lib/tes' +import { button, click, compileClientComponent, content, element, flush, mountApp, moduleDefault } from '@/test/clientRender' + +const Passthrough = defineComponent({ inheritAttrs: false, setup: (_, { attrs, slots }) => () => h('div', attrs, slots.default?.()) }) +const Empty = defineComponent(() => () => null) + +const component = compileClientComponent(new URL('./TesDataRefDialog.vue', import.meta.url), { + vue: VueRuntime, + 'vue-router': { RouterLink: Passthrough }, + '@lucide/vue': new Proxy({}, { get: () => Empty }), + '@/components/ui/Dialog.vue': moduleDefault(Passthrough), + '@/components/ui/DialogClose.vue': moduleDefault(Passthrough), + '@/components/ui/DialogContent.vue': moduleDefault(Passthrough), + '@/components/ui/DialogDescription.vue': moduleDefault(Passthrough), + '@/components/ui/DialogFooter.vue': moduleDefault(Passthrough), + '@/components/ui/DialogHeader.vue': moduleDefault(Passthrough), + '@/components/ui/DialogTitle.vue': moduleDefault(Passthrough), + '@/components/ui/Notice.vue': moduleDefault(Passthrough), + '@/components/ui/Switch.vue': moduleDefault(Empty), + '@/components/ui/Button.vue': moduleDefault(defineComponent({ inheritAttrs: false, setup: (_, { attrs, slots }) => () => h('button', attrs, slots.default?.()) })), + '@/components/ui/Input.vue': moduleDefault(Empty), + '@/components/ui/OptionToggle.vue': moduleDefault(defineComponent({ inheritAttrs: false, setup: (_, { attrs }) => () => h('div', { ...attrs, role: 'radiogroup' }) })), + '@/components/data/ObjectBrowserPanel.vue': moduleDefault(defineComponent({ + props: { bucket: String, groupId: String }, + setup: (props) => () => h('section', `browser ${props.bucket ?? 'any'} ${props.groupId ?? ''}`), + })), + '@/components/data/CreateCredentialDialog.vue': moduleDefault(Empty), + '@/components/data/add/DatabasesTab.vue': moduleDefault(defineComponent({ + emits: ['choose'], + setup: (_, { emit }) => () => h('div', [ + h('button', { onClick: () => emit('choose', 'far-db', 'n2', 'g2') }, 'Far database'), + h('button', { onClick: () => emit('choose', 'spire', 'n1', 'g3') }, 'Local database'), + ]), + })), + '@/composables/useS3': { useS3: () => ({ endpoint: ref('https://s3.test'), hasActiveKey: ref(true), ensureSession: async () => {} }) }, + '@/composables/useAruna': { useAruna: () => ({ currentUser: ref(null), myGroups: ref([]) }) }, + '@/composables/useGroupSelection': { activeGroupId: ref('') }, + '@/composables/useRealmNodes': { useRealmNodes: () => ({ isLocalNode: (id: string) => id === 'n1' }) }, + '@/lib/utils': { errorMessage: (cause: unknown) => String(cause) }, + '@/lib/tes': Tes, +}) + +describe('TES input picker databases', () => { + it('browses a database this node holds in its own group, and refuses one of another node', async () => { + const { root } = await mountApp(component, { props: { open: true, mode: 'input' } }) + ;(element(root, (node) => node.props.role === 'radiogroup').props['onUpdate:modelValue'] as (value: string) => void)('databases') + await flush() + + await click(button(root, 'Far database')) + expect(content(root)).toContain('This database is on another node.') + await click(button(root, 'Local database')) + expect(content(root)).toContain('browser spire g3') + }) +}) diff --git a/src/components/compute/TesDataRefDialog.vue b/src/components/compute/TesDataRefDialog.vue index d61ba9c97..d92ddc18c 100644 --- a/src/components/compute/TesDataRefDialog.vue +++ b/src/components/compute/TesDataRefDialog.vue @@ -12,11 +12,14 @@ import DialogHeader from '@/components/ui/DialogHeader.vue' import DialogTitle from '@/components/ui/DialogTitle.vue' import Button from '@/components/ui/Button.vue' import Input from '@/components/ui/Input.vue' +import OptionToggle from '@/components/ui/OptionToggle.vue' import ObjectBrowserPanel from '@/components/data/ObjectBrowserPanel.vue' import CreateCredentialDialog from '@/components/data/CreateCredentialDialog.vue' +import DatabasesTab from '@/components/data/add/DatabasesTab.vue' import { useS3, type FolderEntry, type ObjectEntry } from '@/composables/useS3' import { useAruna } from '@/composables/useAruna' import { activeGroupId } from '@/composables/useGroupSelection' +import { useRealmNodes } from '@/composables/useRealmNodes' import { errorMessage } from '@/lib/utils' import { normalizeContainerDir, @@ -46,8 +49,35 @@ const emit = defineEmits<{ const s3 = useS3() const { currentUser, myGroups } = useAruna() +const { isLocalNode } = useRealmNodes() const credentialDialogOpen = ref(false) +// Inputs come from a bucket of this node or from a database this node holds, in its own group. +const SOURCES = [ + { value: 'buckets', label: 'Buckets' }, + { value: 'databases', label: 'Databases' }, +] +const source = ref<'buckets' | 'databases'>('buckets') +const database = ref<{ bucket: string; groupId: string } | null>(null) +const databaseProblem = ref(null) + +function chooseDatabase(bucket: string, nodeId: string, groupId: string) { + if (!isLocalNode(nodeId)) { + databaseProblem.value = 'This database is on another node. Task inputs come from this node.' + return + } + databaseProblem.value = null + pendingSelection.value = null + database.value = { bucket, groupId } +} + +function showSource(next: 'buckets' | 'databases') { + source.value = next + database.value = null + databaseProblem.value = null + pendingSelection.value = null +} + // Folder handling: the TES facade stages FILE inputs only, so a folder pick is // expanded here (for validation and the file cap) but emitted as ONE folder // entry carrying its file list; consumers expand it again at task assembly. @@ -151,6 +181,7 @@ watch( folderError.value = null mountDir.value = props.mountDefault pendingSelection.value = null + showSource('buckets') // The browser needs a session; without one the picker only offers credentials. if (!currentUser.value) return const gid = activeGroupId.value || myGroups.value[0]?.id @@ -200,7 +231,26 @@ watch( Selected files are staged below this container directory; folders keep their name as a subdirectory.

- + + + +

Will be staged as

    diff --git a/src/components/dashboard/SearchOverlay.test.ts b/src/components/dashboard/SearchOverlay.test.ts index f7c728788..70f67da29 100644 --- a/src/components/dashboard/SearchOverlay.test.ts +++ b/src/components/dashboard/SearchOverlay.test.ts @@ -6,6 +6,7 @@ import * as VueRuntime from 'vue' import { createRenderer, defineComponent, h, nextTick, ref, type App, type Component, type Ref } from 'vue' import { beforeEach, describe, expect, it, vi } from 'vitest' import { isLeafFile } from '@/lib/dataEntities' +import * as Databases from '@/lib/databases' const ButtonStub = defineComponent({ inheritAttrs: false, @@ -30,6 +31,10 @@ const icons = new Proxy({}, { get: () => IconStub }) const moduleDefault = (component: Component) => ({ __esModule: true, default: component }) const narrow = ref(true) +let databaseRows: Databases.DatabaseRow[] = [] +const databaseHits = (query: string) => Databases.searchRows(databaseRows, query) +const databaseState = ref('ready') +const databaseReload = vi.fn() const authToken = ref('token-a') const objectSearchMode = ref('distributed_best_effort') const mediaQuery = vi.fn(() => narrow) @@ -109,9 +114,24 @@ const compiled = compileClientComponent(new URL('./SearchOverlay.vue', import.me useRealmNodes: () => ({ displayName: (nodeId: string) => nodeId === 'node-b' ? 'Storage node B' : nodeId, isLocalNode: (nodeId: string) => nodeId === 'node-a', + localNodeId: ref('node-a'), }), }, '@/lib/dataEntities': { isLeafFile }, + '@/lib/databases': Databases, + '@/composables/useMockDatabases': { useMockDatabases: () => ({ search: () => [] }) }, + '@/composables/useDatabases': { + useDatabases: () => ({ + search: (query: string) => databaseHits(query), + ensure: () => undefined, + reload: databaseReload, + state: databaseState, + complete: ref(true), + locate: async (row: Databases.DatabaseRow) => Databases.placeOf(row, null, 'node-a'), + }), + }, + '@/lib/distributedMock': { mockEnabled: () => false }, + '@/lib/distributedMockData': { searchFiles: () => [] }, '@/lib/utils': { relativeTime: (value: string) => `relative ${value}`, truncateMiddle: (value: string) => value, @@ -631,6 +651,22 @@ describe('narrow TopBar search panel', () => { mounted.app.unmount() }) + it('lists the databases a person may use under their own tag', async () => { + databaseRows = [{ + entryId: 'e1', datasetId: 'd1', bucket: 'spire-db', ownerGroup: 'group-a', title: 'SPIRE microbiome', documentPath: null, state: 'active', public: false, + target: { kind: 'ordinary', node_id: 'node-b', bucket: 'spire-db' }, + }] + const mounted = await mount() + await click(element(mounted.root, (node) => node.props['aria-label'] === 'Open global search')) + await inputValue(element(mounted.root, (node) => node.tag === 'input'), 'microbiome') + + const option = allNodes(mounted.root).find((node) => node.props.id === 'qs-db:e1') + expect(option && content(option)).toContain('Database') + expect(option && content(option)).toContain('SPIRE microbiome') + databaseRows = [] + mounted.app.unmount() + }) + it('summarizes the answer and drops empty kinds', async () => { // No subject_types: an older node's hits keep the dataset label. search.documents.value = [ @@ -802,4 +838,17 @@ describe('narrow TopBar search panel', () => { expect(mounted.errors).toEqual([]) mounted.app.unmount() }) + + it('reports partial coverage when the databases could not be read, and reads them again on retry', async () => { + databaseState.value = 'failed' + const mounted = await mount() + await click(element(mounted.root, (node) => node.props['aria-label'] === 'Open global search')) + await inputValue(element(mounted.root, (node) => node.tag === 'input'), 'sample') + + expect(allNodes(mounted.root).some((node) => node.props['aria-label'] === 'Search coverage: partial')).toBe(true) + await click(element(mounted.root, (node) => node.tag === 'button' && content(node).trim() === 'Retry')) + expect(databaseReload).toHaveBeenCalled() + databaseState.value = 'ready' + mounted.app.unmount() + }) }) diff --git a/src/components/dashboard/SearchOverlay.vue b/src/components/dashboard/SearchOverlay.vue index ec526e564..1496000c3 100644 --- a/src/components/dashboard/SearchOverlay.vue +++ b/src/components/dashboard/SearchOverlay.vue @@ -16,17 +16,22 @@ import Spinner from '@/components/ui/Spinner.vue' import CoverageIcon from '@/components/search/CoverageIcon.vue' import { useAruna } from '@/composables/useAruna' import { useRealm } from '@/composables/useRealm' +import { useDatabases } from '@/composables/useDatabases' +import { useMockDatabases } from '@/composables/useMockDatabases' import { useRealmNodes } from '@/composables/useRealmNodes' import { useSearchSettings } from '@/composables/useSearchSettings' import { OBJECT_SEARCH_MODE_LABELS, useUnifiedSearch } from '@/composables/useUnifiedSearch' import { isLeafFile } from '@/lib/dataEntities' -import { truncateMiddle } from '@/lib/utils' +import { NOT_HELD_HERE, type DatabaseRow } from '@/lib/databases' +import { mockEnabled } from '@/lib/distributedMock' +import { searchFiles } from '@/lib/distributedMockData' +import { errorMessage, truncateMiddle } from '@/lib/utils' import { Search, Settings2, X } from '@lucide/vue' import { useMediaQuery } from '@vueuse/core' import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue' import { useRouter } from 'vue-router' -type QuickSection = 'datasets' | 'files' | 'buckets' | 'objects' | 'groups' | 'people' +type QuickSection = 'datasets' | 'files' | 'buckets' | 'objects' | 'databases' | 'groups' | 'people' interface QuickItem { key: string @@ -36,6 +41,8 @@ interface QuickItem { routeName: string routeParams: Record routeQuery?: Record + /** A database opens where it is held, which is resolved on open. */ + database?: DatabaseRow } // Declaration order is the order the summary line lists the kinds in. @@ -44,6 +51,7 @@ const QUICK_KIND_LABELS: Record = { files: 'File', buckets: 'Bucket', objects: 'Object', + databases: 'Database', groups: 'Group', people: 'User', } @@ -66,6 +74,8 @@ const { authToken } = useAruna() const { displayName: nodeDisplayName, isLocalNode } = useRealmNodes() const router = useRouter() const { objectSearchMode } = useSearchSettings() +const { search: searchDatabases } = useMockDatabases() +const databases = useDatabases() const objectModeOptions = Object.entries(OBJECT_SEARCH_MODE_LABELS).map(([value, label]) => ({ value, label })) // Quick search is server-backed only: the catalog is paged, so a client-side @@ -123,6 +133,35 @@ const items = computed(() => [ ...(objectParentPrefix(hit.key) ? { prefix: objectParentPrefix(hit.key) as string } : {}), }, })), + // The databases the user may use, by the dataset's title and the bucket name. + ...databases.search(q.value).map((row): QuickItem => ({ + key: `db:${row.entryId}`, + section: 'databases', + title: row.title || row.bucket, + subtitle: `Bucket: ${row.bucket}`, + routeName: 'bucket', + routeParams: { bucketId: row.bucket }, + routeQuery: { group: row.ownerGroup }, + database: row, + })), + // Databases and files of the example buckets (node mock). + ...(mockEnabled() ? searchDatabases(q.value) : []).map((entry): QuickItem => ({ + key: `db:${entry.id}`, + section: 'databases', + title: entry.dataset.name, + subtitle: `${entry.dataset.description} ${entry.dataset.source}`, + routeName: 'bucket', + routeParams: { bucketId: entry.bucket }, + })), + ...(mockEnabled() ? searchFiles(q.value) : []).map((file): QuickItem => ({ + key: `m:${file.key}`, + section: 'files', + title: file.title, + subtitle: file.subtitle, + routeName: 'bucket', + routeParams: { bucketId: file.bucket }, + routeQuery: { object: file.title }, + })), ...quickGroups.value.map((group): QuickItem => ({ key: `g:${group.group_id}`, section: 'groups', @@ -143,9 +182,20 @@ const items = computed(() => [ // rather than read as the answer to what was just typed. const quickStale = computed(() => quickPending.value && items.value.length > 0) // One icon carries the whole answer; the numbers live on the search page. +// The databases are matched from the list read for the session, so it counts towards coverage. +const databasesSearched = computed(() => Boolean(authToken.value) && q.value.trim().length >= 2) +const databasesCovered = computed( + () => !databasesSearched.value || (databases.state.value === 'ready' && databases.complete.value), +) +const coverageComplete = computed(() => quickComplete.value && databasesCovered.value) const quickCoverageShown = computed(() => - quickSearched.value || quickObjectSearched.value || Boolean(quickError.value), + quickSearched.value || quickObjectSearched.value || Boolean(quickError.value) || !databasesCovered.value, ) + +function retryAll() { + if (!databasesCovered.value) void databases.reload() + if (!quickComplete.value) retrySearch() +} const quickObjectErrorDetail = computed(() => { if (!quickObjectError.value) return '' const strict = objectSearchMode.value === 'distributed_strict' @@ -167,7 +217,13 @@ const quickSummary = computed(() => { const activeKey = computed(() => items.value[activeIndex.value]?.key ?? null) watch(items, () => (activeIndex.value = -1)) -watch(q, () => (activeIndex.value = -1)) +watch(q, (value) => { + activeIndex.value = -1 + databaseProblem.value = null + opening++ + // The list of databases is read once, when the first search needs it. + if (value.trim().length >= 2) databases.ensure() +}) watch(isNarrowSearch, (narrow) => { if (!narrow && panelOpen.value) requestPanelClose(false) }) @@ -230,7 +286,27 @@ function navigateAfterPanel(callback: () => void) { else callback() } -function openItem(item: QuickItem) { +// Why a chosen database cannot open from here; a later choice drops an earlier answer. +const databaseProblem = ref(null) +let opening = 0 + +async function openItem(chosen: QuickItem) { + const run = ++opening + let item = chosen + databaseProblem.value = null + if (chosen.database) { + try { + const place = await databases.locate(chosen.database) + if (run !== opening) return + if (!place) return void (databaseProblem.value = NOT_HELD_HERE) + const routeQuery: Record = { group: chosen.database.ownerGroup } + if (!isLocalNode(place.nodeId)) routeQuery.node = place.nodeId + item = { ...chosen, routeParams: { bucketId: place.bucket }, routeQuery } + } catch (cause) { + if (run === opening) databaseProblem.value = errorMessage(cause) + return + } + } showResults.value = false q.value = '' navigateAfterPanel(() => void router.push({ @@ -258,7 +334,7 @@ function onInputKeydown(event: KeyboardEvent) { activeIndex.value = list.length ? (activeIndex.value - 1 + list.length) % list.length : -1 } else if (event.key === 'Enter') { const item = list[activeIndex.value] - if (item) openItem(item) + if (item) void openItem(item) else if (q.value.trim()) openSearchPage() } else if (event.key === 'Escape') { showResults.value = false @@ -501,20 +577,23 @@ onBeforeUnmount(() => { role="status" class="ml-auto flex shrink-0 items-center gap-1" > - +
+

+ {{ databaseProblem }} +

mockEnabled() && Boolean(mockBucket(props.bucket))) const tab = ref(props.tab === 'connector' && !shown('connectors') ? 'local' : props.tab ?? 'local') +// A chosen database is the source of the Other buckets tab. +function chooseDatabase(name: string, nodeId: string, groupId: string) { + otherBuckets.pickSearchHit({ bucket: name, node_id: nodeId, arn: '', group_id: groupId, created_at: '' } satisfies BucketSearchHit) + tab.value = 'other' +} + function addConnectorRows(rows: ConnectorStagingRow[]) { basket.addStaging('connector', rows) } @@ -91,6 +105,8 @@ function onImportsCreated() { Local files From connector Other buckets + Databases + Whole collection @@ -113,7 +129,16 @@ function onImportsCreated() { @created="onImportsCreated" /> + + + + + + + + + diff --git a/src/components/data/manager/DatabaseRows.test.ts b/src/components/data/manager/DatabaseRows.test.ts new file mode 100644 index 000000000..48e598154 --- /dev/null +++ b/src/components/data/manager/DatabaseRows.test.ts @@ -0,0 +1,99 @@ +import { defineComponent, h, ref } from 'vue' +import * as VueRuntime from 'vue' +import { describe, expect, it, vi } from 'vitest' +import * as Databases from '@/lib/databases' +import { compileClientComponent, content, element, click, mountApp, moduleDefault } from '@/test/clientRender' + +const state = ref('ready') +const rows = ref([]) +const complete = ref(true) +const held = ref<{ id: string; bucket: string; prefix: string; held_here: boolean } | null>(null) + +const RowStub = defineComponent({ + props: { bucket: String, subtitle: String }, + emits: ['open'], + setup: (props, { emit }) => () => h('button', { 'data-bucket': props.bucket, onClick: () => emit('open') }, `${props.bucket} ${props.subtitle ?? ''}`), +}) + +const component = compileClientComponent(new URL('./DatabaseRows.vue', import.meta.url), { + vue: VueRuntime, + '@/components/data/BucketRow.vue': moduleDefault(RowStub), + '@/components/ui/Spinner.vue': moduleDefault(defineComponent(() => () => h('i'))), + '@/composables/useDatabases': { + useDatabases: () => ({ + rows, state, error: ref('node busy'), complete, ensure: vi.fn(), + locate: async (item: Databases.DatabaseRow) => Databases.placeOf(item, held.value, 'n1'), + }), + }, + '@/composables/useRealmNodes': { + useRealmNodes: () => ({ localNodeId: ref('n1'), isLocalNode: (id: string) => id === 'n1' }), + }, + '@/lib/databases': Databases, + '@/lib/utils': { errorMessage: (cause: unknown) => String(cause) }, +}) + +function row(bucket: string, extra: Partial = {}): Databases.DatabaseRow { + return { + entryId: `e-${bucket}`, datasetId: `d-${bucket}`, bucket, ownerGroup: 'g1', title: `${bucket} title`, documentPath: null, state: 'active', public: false, + target: { kind: 'ordinary', node_id: 'n1', bucket }, + ...extra, + } +} + +async function render(filter = '') { + return mountApp(component, { props: { filter, active: '' } }) +} + +describe('database rows', () => { + it('lists each database with the dataset title and opens it on its own node', async () => { + state.value = 'ready' + rows.value = [row('lab'), row('far', { target: { kind: 'ordinary', node_id: 'n2', bucket: 'far' } })] + const opened: unknown[][] = [] + const { root } = await mountApp(component, { props: { filter: '', active: '', onOpen: (...args: unknown[]) => opened.push(args) } }) + + expect(content(root)).toContain('lab lab title') + await click(element(root, (node) => node.props['data-bucket'] === 'far')) + await click(element(root, (node) => node.props['data-bucket'] === 'lab')) + + expect(opened).toEqual([['far', 'n2', 'g1'], ['lab', null, 'g1']]) + }) + + it('says why an entry is not plain and filters by the typed text', async () => { + state.value = 'ready' + rows.value = [row('lab', { state: 'description_unavailable' }), row('spire')] + const { root } = await render('spi') + + expect(content(root)).toContain('spire spire title') + expect(content(root)).not.toContain('lab') + expect(content((await render('lab')).root)).toContain('Description temporarily unavailable') + }) + + it('keeps a failed read apart from an empty list and notes a partial one', async () => { + rows.value = [] + state.value = 'failed' + expect(content((await render()).root)).toContain('node busy') + + state.value = 'ready' + expect(content((await render()).root)).toContain('No database is listed for you yet') + complete.value = false + expect(content((await render()).root)).toContain('The list is partial') + complete.value = true + }) + + it('opens a set here only when this node holds it, and says so otherwise', async () => { + state.value = 'ready' + rows.value = [row('spire', { target: { kind: 'distributed', set_id: 's1' } })] + const opened: unknown[][] = [] + const { root } = await mountApp(component, { props: { filter: '', active: '', onOpen: (...args: unknown[]) => opened.push(args) } }) + + held.value = { id: 'r', bucket: 'spire', prefix: '', held_here: false } + await click(element(root, (node) => node.props['data-bucket'] === 'spire')) + expect(opened).toEqual([]) + expect(content(root)).toContain('This node holds no copy of this database.') + + held.value = { ...held.value, held_here: true } + await click(element(root, (node) => node.props['data-bucket'] === 'spire')) + expect(opened).toEqual([['spire', null, 'g1']]) + held.value = null + }) +}) diff --git a/src/components/data/manager/DatabaseRows.vue b/src/components/data/manager/DatabaseRows.vue new file mode 100644 index 000000000..24de12f58 --- /dev/null +++ b/src/components/data/manager/DatabaseRows.vue @@ -0,0 +1,68 @@ + + + diff --git a/src/components/data/manager/DistributionBanner.vue b/src/components/data/manager/DistributionBanner.vue new file mode 100644 index 000000000..5dcdae483 --- /dev/null +++ b/src/components/data/manager/DistributionBanner.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/components/data/manager/MockBucketRows.vue b/src/components/data/manager/MockBucketRows.vue new file mode 100644 index 000000000..46a0373a7 --- /dev/null +++ b/src/components/data/manager/MockBucketRows.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/components/data/manager/MockSidebar.vue b/src/components/data/manager/MockSidebar.vue new file mode 100644 index 000000000..c32d63205 --- /dev/null +++ b/src/components/data/manager/MockSidebar.vue @@ -0,0 +1,39 @@ + + + diff --git a/src/components/data/manager/ObjectBrowser.test.ts b/src/components/data/manager/ObjectBrowser.test.ts index 2f7087773..fd189b49d 100644 --- a/src/components/data/manager/ObjectBrowser.test.ts +++ b/src/components/data/manager/ObjectBrowser.test.ts @@ -691,8 +691,9 @@ describe('object browser public access', () => { it('opens the same details view for a folder', async () => { openDetails.mockClear() const root = await render({ folders: ref([listedFolder]) }) - const row = element(root, (node) => node.tag === 'tr' && content(node).includes(`${listedFolder.name}/`)) + const row = element(root, (node) => node.tag === 'tr' && content(node).includes(listedFolder.name)) + expect(content(element(row, (node) => node.tag === 'td' && content(node).trim() === listedFolder.name))).toBe(` ${listedFolder.name} `) expect(menuLabels(row)).toEqual(['Open', 'Details', 'Move to', 'Copy to', 'Change access', 'Delete folder', 'Delete permanently…']) await click(menuItem(root, 'Details', `${listedFolder.name}/`)) @@ -709,7 +710,7 @@ describe('object browser public access', () => { }) const fileRow = element(root, (node) => node.tag === 'tr' && content(node).includes(listedObject.name)) - const folderRow = element(root, (node) => node.tag === 'tr' && content(node).includes(`${listedFolder.name}/`)) + const folderRow = element(root, (node) => node.tag === 'tr' && content(node).includes(listedFolder.name)) expect(content(fileRow)).toContain('public') expect(content(folderRow)).not.toContain('public') }) diff --git a/src/components/data/manager/ObjectBrowser.vue b/src/components/data/manager/ObjectBrowser.vue index 2d71cae5e..4b25c6fd2 100644 --- a/src/components/data/manager/ObjectBrowser.vue +++ b/src/components/data/manager/ObjectBrowser.vue @@ -19,6 +19,8 @@ import KeyedReadNotice from '@/components/storage/KeyedReadNotice.vue' import { useAruna } from '@/composables/useAruna' import { usePortalFeatures } from '@/composables/usePortalFeatures' import { isDesktop } from '@/lib/desktop' +import { mockEnabled } from '@/lib/distributedMock' +import { exampleMark } from '@/lib/distributedMockData' import type { BindSource } from '@/lib/bindSource' import { folderName } from '@/lib/deviceApi' import { useBrokenFiles } from '@/composables/useBrokenFiles' @@ -70,7 +72,6 @@ const emit = defineEmits<{ (e: 'add-data'): void (e: 'new-folder'): void (e: 'new-notebook'): void - (e: 'sync-to-node'): void (e: 'sync-to-computer', source: BindSource): void (e: 'public-access', targets: PublicTarget[]): void (e: 'new-bucket'): void @@ -538,13 +539,8 @@ async function onDrop(event: DragEvent) {

-
@@ -605,7 +601,7 @@ async function onDrop(event: DragEvent) { - {{ folder.name }}/ + {{ folder.name }} @@ -680,6 +676,9 @@ async function onDrop(event: DragEvent) { class="h-3 w-3 shrink-0 text-primary/40" aria-label="Covered by a sync relationship" /> + + {{ exampleMark(bucket, object.key) }} + diff --git a/src/components/distributed/AccessTab.vue b/src/components/distributed/AccessTab.vue new file mode 100644 index 000000000..5f0e33930 --- /dev/null +++ b/src/components/distributed/AccessTab.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/components/distributed/AdmissionRetry.vue b/src/components/distributed/AdmissionRetry.vue new file mode 100644 index 000000000..5ea2f108c --- /dev/null +++ b/src/components/distributed/AdmissionRetry.vue @@ -0,0 +1,55 @@ + + + diff --git a/src/components/distributed/BucketActions.vue b/src/components/distributed/BucketActions.vue new file mode 100644 index 000000000..a7d77c6b8 --- /dev/null +++ b/src/components/distributed/BucketActions.vue @@ -0,0 +1,52 @@ + + + diff --git a/src/components/distributed/CreateResults.test.ts b/src/components/distributed/CreateResults.test.ts new file mode 100644 index 000000000..66ca215c3 --- /dev/null +++ b/src/components/distributed/CreateResults.test.ts @@ -0,0 +1,36 @@ +import { defineComponent, h } from 'vue' +import * as VueRuntime from 'vue' +import { describe, expect, it } from 'vitest' +import type { AdmissionResponse } from '@/lib/api' +import { compileClientComponent, content, mountApp, moduleDefault } from '@/test/clientRender' + +const Slotted = (tag: string) => + defineComponent({ inheritAttrs: false, setup: (_, { attrs, slots }) => () => h(tag, attrs, [attrs.title ? `${attrs.title} ` : '', slots.default?.()]) }) + +const component = compileClientComponent(new URL('./CreateResults.vue', import.meta.url), { + vue: VueRuntime, + '@lucide/vue': { RefreshCw: defineComponent(() => () => h('i')) }, + '@/components/ui/Badge.vue': moduleDefault(Slotted('span')), + '@/components/ui/Button.vue': moduleDefault(Slotted('button')), + '@/components/ui/NodeLabel.vue': moduleDefault(defineComponent({ props: { nodeId: String }, setup: (props) => () => h('b', props.nodeId) })), + '@/components/ui/Notice.vue': moduleDefault(Slotted('aside')), +}) + +const member = (id: string, admitted: boolean) => ({ member_id: id, node_id: id, admitted, error: admitted ? null : 'busy' }) + +async function text(outcome: AdmissionResponse) { + return content((await mountApp(component, { props: { name: 'lab', outcome, busy: false, failure: null } })).root) +} + +describe('create results', () => { + it('claims every member admitted only when each one is, and offers the retry otherwise', async () => { + const all = await text({ set_id: 's', active: true, members: [member('n1', true), member('n2', true)] }) + expect(all).toContain('Every member is admitted') + expect(all).not.toContain('Retry admission') + + const some = await text({ set_id: 's', active: true, members: [member('n1', true), member('n2', false)] }) + expect(some).not.toContain('Every member is admitted') + expect(some).toContain('Some members are not admitted') + expect(some).toContain('Retry admission') + }) +}) diff --git a/src/components/distributed/CreateResults.vue b/src/components/distributed/CreateResults.vue new file mode 100644 index 000000000..d8b48f6da --- /dev/null +++ b/src/components/distributed/CreateResults.vue @@ -0,0 +1,66 @@ + + + diff --git a/src/components/distributed/CreateSettings.vue b/src/components/distributed/CreateSettings.vue new file mode 100644 index 000000000..b54ff2259 --- /dev/null +++ b/src/components/distributed/CreateSettings.vue @@ -0,0 +1,116 @@ + + +