Commit f947d245 authored by Phil Hughes's avatar Phil Hughes

Merge branch '324330-display-correct-action-buttons' into 'master'

Display correct action buttons when viewing non-text files

See merge request gitlab-org/gitlab!69286
parents 535c8ba6 359718e3
......@@ -118,7 +118,7 @@ export default {
return this.$apollo.queries.project.loading || this.isLoadingLegacyViewer;
},
isBinaryFileType() {
return this.isBinary || this.viewer.fileType === 'download';
return this.isBinary || this.blobInfo.simpleViewer?.fileType !== 'text';
},
blobInfo() {
const nodes = this.project?.repository?.blobs?.nodes || [];
......@@ -180,7 +180,7 @@ export default {
<div v-if="blobInfo && !isLoading" class="file-holder">
<blob-header
:blob="blobInfo"
:hide-viewer-switcher="!hasRichViewer || isBinary"
:hide-viewer-switcher="!hasRichViewer || isBinaryFileType"
:is-binary="isBinaryFileType"
:active-viewer-type="viewer.type"
:has-render-error="hasRenderError"
......@@ -188,7 +188,7 @@ export default {
>
<template #actions>
<blob-edit
:show-edit-button="!isBinary"
:show-edit-button="!isBinaryFileType"
:edit-path="blobInfo.editBlobPath"
:web-ide-path="blobInfo.ideEditPath"
/>
......
......@@ -375,6 +375,30 @@ describe('Blob content viewer component', () => {
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', () => {
......
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