diff options
Diffstat (limited to 'app/assets/javascripts/snippets/components/snippet_blob_view.vue')
-rw-r--r-- | app/assets/javascripts/snippets/components/snippet_blob_view.vue | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/app/assets/javascripts/snippets/components/snippet_blob_view.vue b/app/assets/javascripts/snippets/components/snippet_blob_view.vue index 3e3dcab70c0..02a0fc7686d 100644 --- a/app/assets/javascripts/snippets/components/snippet_blob_view.vue +++ b/app/assets/javascripts/snippets/components/snippet_blob_view.vue @@ -3,10 +3,8 @@ import BlobEmbeddable from '~/blob/components/blob_embeddable.vue'; import { SNIPPET_VISIBILITY_PUBLIC } from '../constants'; import BlobHeader from '~/blob/components/blob_header.vue'; import BlobContent from '~/blob/components/blob_content.vue'; -import { GlLoadingIcon } from '@gitlab/ui'; import CloneDropdownButton from '~/vue_shared/components/clone_dropdown.vue'; -import GetSnippetBlobQuery from '../queries/snippet.blob.query.graphql'; import GetBlobContent from '../queries/snippet.blob.content.query.graphql'; import { SIMPLE_BLOB_VIEWER, RICH_BLOB_VIEWER } from '~/blob/components/constants'; @@ -16,25 +14,9 @@ export default { BlobEmbeddable, BlobHeader, BlobContent, - GlLoadingIcon, CloneDropdownButton, }, apollo: { - blob: { - query: GetSnippetBlobQuery, - variables() { - return { - ids: this.snippet.id, - }; - }, - update: data => data.snippets.edges[0].node.blob, - result(res) { - const viewer = res.data.snippets.edges[0].node.blob.richViewer - ? RICH_BLOB_VIEWER - : SIMPLE_BLOB_VIEWER; - this.switchViewer(viewer, true); - }, - }, blobContent: { query: GetBlobContent, variables() { @@ -55,18 +37,18 @@ export default { }, data() { return { - blob: {}, + blob: this.snippet.blob, blobContent: '', - activeViewerType: window.location.hash ? SIMPLE_BLOB_VIEWER : '', + activeViewerType: + this.snippet.blob?.richViewer && !window.location.hash + ? RICH_BLOB_VIEWER + : SIMPLE_BLOB_VIEWER, }; }, computed: { embeddable() { return this.snippet.visibilityLevel === SNIPPET_VISIBILITY_PUBLIC; }, - isBlobLoading() { - return this.$apollo.queries.blob.loading; - }, isContentLoading() { return this.$apollo.queries.blobContent.loading; }, @@ -79,8 +61,8 @@ export default { }, }, methods: { - switchViewer(newViewer, respectHash = false) { - this.activeViewerType = respectHash && window.location.hash ? SIMPLE_BLOB_VIEWER : newViewer; + switchViewer(newViewer) { + this.activeViewerType = newViewer; }, }, }; @@ -88,13 +70,7 @@ export default { <template> <div> <blob-embeddable v-if="embeddable" class="mb-3" :url="snippet.webUrl" /> - <gl-loading-icon - v-if="isBlobLoading" - :label="__('Loading blob')" - size="lg" - class="prepend-top-20 append-bottom-20" - /> - <article v-else 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"> <template #actions> <clone-dropdown-button |