Skip to content

Commit 2d6173e

Browse files
committed
fix: connect media preview on public retrieval page
Wire the existing media-preview actions and modal, with a regression test for the missing connections. Verified image, audio and video previews against a local backend. Refs vastsa/FileCodeBox#472
1 parent 4c40406 commit 2d6173e

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎src/views/RetrievewFileView.vue‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
:record="selectedRecord"
5454
@close="closeDetails"
5555
@preview-content="showContentPreview"
56+
@preview-file="showFilePreview"
5657
/>
5758

5859
<ContentPreviewModal
@@ -61,6 +62,12 @@
6162
@close="closeContentPreview"
6263
@copy-content="copyContent"
6364
/>
65+
66+
<MediaPreviewModal
67+
:visible="showMediaPreview"
68+
:record="previewMediaRecord"
69+
@close="closeFilePreview"
70+
/>
6471
</div>
6572
</template>
6673

@@ -75,6 +82,7 @@ import SideDrawer from '@/components/common/SideDrawer.vue'
7582
import FileDetailModal from '@/components/common/FileDetailModal.vue'
7683
import FileRecordList from '@/components/common/FileRecordList.vue'
7784
import ContentPreviewModal from '@/components/common/ContentPreviewModal.vue'
85+
import MediaPreviewModal from '@/components/common/MediaPreviewModal.vue'
7886
import { useRetrieveFlow } from '@/composables'
7987
import { useInjectedDarkMode } from '@/composables'
8088
@@ -88,16 +96,20 @@ const {
8896
error,
8997
records,
9098
selectedRecord,
99+
previewMediaRecord,
91100
showDrawer,
92101
showPreview,
102+
showMediaPreview,
93103
renderedContent,
94104
closeContentPreview,
105+
closeFilePreview,
95106
closeDetails,
96107
copyContent,
97108
deleteRecord,
98109
downloadRecord,
99110
handleSubmit,
100111
showContentPreview,
112+
showFilePreview,
101113
toggleDrawer,
102114
viewDetails
103115
} = useRetrieveFlow()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import assert from 'node:assert/strict'
2+
import { readFileSync } from 'node:fs'
3+
import { test } from 'node:test'
4+
import { URL } from 'node:url'
5+
import { compileScript, parse } from 'vue/compiler-sfc'
6+
7+
test('issue #472: retrieval view connects media preview events, state and close action', () => {
8+
const source = readFileSync(
9+
new URL('../src/views/RetrievewFileView.vue', import.meta.url),
10+
'utf8'
11+
)
12+
const { descriptor, errors } = parse(source)
13+
assert.deepEqual(errors, [])
14+
const { bindings } = compileScript(descriptor, { id: 'retrieve-view' })
15+
for (const name of [
16+
'MediaPreviewModal',
17+
'previewMediaRecord',
18+
'showMediaPreview',
19+
'showFilePreview',
20+
'closeFilePreview'
21+
]) {
22+
assert.ok(bindings[name], `${name} must be available to the template`)
23+
}
24+
const template = descriptor.template.content
25+
assert.match(template, /<FileDetailModal\b[^>]*@preview-file="showFilePreview"/)
26+
const modal = template.match(/<MediaPreviewModal\b[^>]*\/>/)?.[0]
27+
assert.ok(modal, 'the public retrieval page must render the media preview modal')
28+
assert.match(modal, /:visible="showMediaPreview"/)
29+
assert.match(modal, /:record="previewMediaRecord"/)
30+
assert.match(modal, /@close="closeFilePreview"/)
31+
})

0 commit comments

Comments
 (0)