Commit 359718e3 authored by jerasmus's avatar jerasmus

Display correct header buttons when viewing binary

Displays correct header buttons when viewing binary
parent 96f06f05
...@@ -118,7 +118,7 @@ export default { ...@@ -118,7 +118,7 @@ export default {
return this.$apollo.queries.project.loading || this.isLoadingLegacyViewer; return this.$apollo.queries.project.loading || this.isLoadingLegacyViewer;
}, },
isBinaryFileType() { isBinaryFileType() {
return this.isBinary || this.viewer.fileType === 'download'; return this.isBinary || this.blobInfo.simpleViewer?.fileType !== 'text';
}, },
blobInfo() { blobInfo() {
const nodes = this.project?.repository?.blobs?.nodes || []; const nodes = this.project?.repository?.blobs?.nodes || [];
...@@ -180,7 +180,7 @@ export default { ...@@ -180,7 +180,7 @@ export default {
<div v-if="blobInfo && !isLoading" class="file-holder"> <div v-if="blobInfo && !isLoading" class="file-holder">
<blob-header <blob-header
:blob="blobInfo" :blob="blobInfo"
:hide-viewer-switcher="!hasRichViewer || isBinary" :hide-viewer-switcher="!hasRichViewer || isBinaryFileType"
:is-binary="isBinaryFileType" :is-binary="isBinaryFileType"
:active-viewer-type="viewer.type" :active-viewer-type="viewer.type"
:has-render-error="hasRenderError" :has-render-error="hasRenderError"
...@@ -188,7 +188,7 @@ export default { ...@@ -188,7 +188,7 @@ export default {
> >
<template #actions> <template #actions>
<blob-edit <blob-edit
:show-edit-button="!isBinary" :show-edit-button="!isBinaryFileType"
:edit-path="blobInfo.editBlobPath" :edit-path="blobInfo.editBlobPath"
:web-ide-path="blobInfo.ideEditPath" :web-ide-path="blobInfo.ideEditPath"
/> />
......
...@@ -375,6 +375,30 @@ describe('Blob content viewer component', () => { ...@@ -375,6 +375,30 @@ describe('Blob content viewer component', () => {
expect(findBlobHeader().props('isBinary')).toBe(true); expect(findBlobHeader().props('isBinary')).toBe(true);
}, },
); );
it('passes the correct header props when viewing a non-text file', async () => {
fullFactory({
mockData: {
blobInfo: {
...simpleMockData,
simpleViewer: {
...simpleMockData.simpleViewer,
fileType: 'image',
},
},
},
stubs: {
BlobContent: true,
BlobReplace: true,
},
});
await nextTick();
expect(findBlobHeader().props('hideViewerSwitcher')).toBe(true);
expect(findBlobHeader().props('isBinary')).toBe(true);
expect(findBlobEdit().props('showEditButton')).toBe(false);
});
}); });
describe('BlobButtonGroup', () => { describe('BlobButtonGroup', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment