Commit fd11fe1c authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '218510-hide-copy-btn-for-rendering-error' into 'master'

Hid copy contents button on render error

Closes #218510

See merge request gitlab-org/gitlab!32632
parents acca4e78 bec2e793
...@@ -30,6 +30,11 @@ export default { ...@@ -30,6 +30,11 @@ export default {
required: false, required: false,
default: SIMPLE_BLOB_VIEWER, default: SIMPLE_BLOB_VIEWER,
}, },
hasRenderError: {
type: Boolean,
required: false,
default: false,
},
}, },
data() { data() {
return { return {
...@@ -75,6 +80,7 @@ export default { ...@@ -75,6 +80,7 @@ export default {
v-if="showDefaultActions" v-if="showDefaultActions"
:raw-path="blob.rawPath" :raw-path="blob.rawPath"
:active-viewer="viewer" :active-viewer="viewer"
:has-render-error="hasRenderError"
@copy="proxyCopyRequest" @copy="proxyCopyRequest"
/> />
</div> </div>
......
...@@ -27,6 +27,11 @@ export default { ...@@ -27,6 +27,11 @@ export default {
default: SIMPLE_BLOB_VIEWER, default: SIMPLE_BLOB_VIEWER,
required: false, required: false,
}, },
hasRenderError: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
downloadUrl() { downloadUrl() {
...@@ -44,11 +49,13 @@ export default { ...@@ -44,11 +49,13 @@ export default {
<template> <template>
<gl-button-group> <gl-button-group>
<gl-deprecated-button <gl-deprecated-button
v-if="!hasRenderError"
v-gl-tooltip.hover v-gl-tooltip.hover
:aria-label="$options.BTN_COPY_CONTENTS_TITLE" :aria-label="$options.BTN_COPY_CONTENTS_TITLE"
:title="$options.BTN_COPY_CONTENTS_TITLE" :title="$options.BTN_COPY_CONTENTS_TITLE"
:disabled="copyDisabled" :disabled="copyDisabled"
data-clipboard-target="#blob-code-content" data-clipboard-target="#blob-code-content"
data-testid="copyContentsButton"
> >
<gl-icon name="copy-to-clipboard" :size="14" /> <gl-icon name="copy-to-clipboard" :size="14" />
</gl-deprecated-button> </gl-deprecated-button>
......
...@@ -74,6 +74,9 @@ export default { ...@@ -74,6 +74,9 @@ export default {
canBeCloned() { canBeCloned() {
return this.snippet.sshUrlToRepo || this.snippet.httpUrlToRepo; return this.snippet.sshUrlToRepo || this.snippet.httpUrlToRepo;
}, },
hasRenderError() {
return Boolean(this.viewer.renderError);
},
}, },
methods: { methods: {
switchViewer(newViewer) { switchViewer(newViewer) {
...@@ -92,7 +95,12 @@ export default { ...@@ -92,7 +95,12 @@ export default {
<div> <div>
<blob-embeddable v-if="embeddable" class="mb-3" :url="snippet.webUrl" /> <blob-embeddable v-if="embeddable" class="mb-3" :url="snippet.webUrl" />
<article class="file-holder snippet-file-content"> <article class="file-holder snippet-file-content">
<blob-header :blob="blob" :active-viewer-type="viewer.type" @viewer-changed="switchViewer"> <blob-header
:blob="blob"
:active-viewer-type="viewer.type"
:has-render-error="hasRenderError"
@viewer-changed="switchViewer"
>
<template #actions> <template #actions>
<clone-dropdown-button <clone-dropdown-button
v-if="canBeCloned" v-if="canBeCloned"
......
---
title: Hid copy contents button when blob has rendering error
merge_request: 32632
author:
type: fixed
...@@ -66,5 +66,13 @@ describe('Blob Header Default Actions', () => { ...@@ -66,5 +66,13 @@ describe('Blob Header Default Actions', () => {
expect(buttons.at(0).attributes('disabled')).toBeTruthy(); expect(buttons.at(0).attributes('disabled')).toBeTruthy();
}); });
it('does not render the copy button if a rendering error is set', () => {
createComponent({
hasRenderError: true,
});
expect(wrapper.find('[data-testid="copyContentsButton"]').exists()).toBe(false);
});
}); });
}); });
...@@ -87,6 +87,17 @@ describe('Blob Header Default Actions', () => { ...@@ -87,6 +87,17 @@ describe('Blob Header Default Actions', () => {
expect(wrapper.text()).toContain(slotContent); expect(wrapper.text()).toContain(slotContent);
}); });
}); });
it('passes information about render error down to default actions', () => {
createComponent(
{},
{},
{
hasRenderError: true,
},
);
expect(wrapper.find(DefaultActions).props('hasRenderError')).toBe(true);
});
}); });
describe('functionality', () => { describe('functionality', () => {
......
...@@ -3,7 +3,11 @@ import SnippetBlobView from '~/snippets/components/snippet_blob_view.vue'; ...@@ -3,7 +3,11 @@ import SnippetBlobView from '~/snippets/components/snippet_blob_view.vue';
import BlobHeader from '~/blob/components/blob_header.vue'; import BlobHeader from '~/blob/components/blob_header.vue';
import BlobEmbeddable from '~/blob/components/blob_embeddable.vue'; import BlobEmbeddable from '~/blob/components/blob_embeddable.vue';
import BlobContent from '~/blob/components/blob_content.vue'; import BlobContent from '~/blob/components/blob_content.vue';
import { BLOB_RENDER_EVENT_LOAD, BLOB_RENDER_EVENT_SHOW_SOURCE } from '~/blob/components/constants'; import {
BLOB_RENDER_EVENT_LOAD,
BLOB_RENDER_EVENT_SHOW_SOURCE,
BLOB_RENDER_ERRORS,
} from '~/blob/components/constants';
import { RichViewer, SimpleViewer } from '~/vue_shared/components/blob_viewers'; import { RichViewer, SimpleViewer } from '~/vue_shared/components/blob_viewers';
import { import {
SNIPPET_VISIBILITY_PRIVATE, SNIPPET_VISIBILITY_PRIVATE,
...@@ -109,6 +113,20 @@ describe('Blob Embeddable', () => { ...@@ -109,6 +113,20 @@ describe('Blob Embeddable', () => {
}); });
}); });
it('passes information about render error down to blob header', () => {
createComponent({
blob: {
...BlobMock,
simpleViewer: {
...SimpleViewerMock,
renderError: BLOB_RENDER_ERRORS.REASONS.COLLAPSED.id,
},
},
});
expect(wrapper.find(BlobHeader).props('hasRenderError')).toBe(true);
});
describe('URLS with hash', () => { describe('URLS with hash', () => {
beforeEach(() => { beforeEach(() => {
window.location.hash = '#LC2'; window.location.hash = '#LC2';
......
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