diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 09:09:34 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-14 09:09:34 +0000 |
commit | 97f0ae7454597105a27df65ffb772949d9d4f3cb (patch) | |
tree | 0bf4888e0e9082c8f168a211390a73a6ae810cef /app/assets/javascripts/snippets | |
parent | 5ebc4d92cd5fbb46c627eb04d500384893dbe2b4 (diff) | |
download | gitlab-ce-97f0ae7454597105a27df65ffb772949d9d4f3cb.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/snippets')
3 files changed, 23 insertions, 56 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 diff --git a/app/assets/javascripts/snippets/fragments/snippetBase.fragment.graphql b/app/assets/javascripts/snippets/fragments/snippetBase.fragment.graphql index 22aab7c7795..d793d0b6bb4 100644 --- a/app/assets/javascripts/snippets/fragments/snippetBase.fragment.graphql +++ b/app/assets/javascripts/snippets/fragments/snippetBase.fragment.graphql @@ -1,3 +1,5 @@ +#import '~/graphql_shared/fragments/blobviewer.fragment.graphql' + fragment SnippetBase on Snippet { id title @@ -9,6 +11,19 @@ fragment SnippetBase on Snippet { webUrl httpUrlToRepo sshUrlToRepo + blob { + binary + name + path + rawPath + size + simpleViewer { + ...BlobViewer + } + richViewer { + ...BlobViewer + } + } userPermissions { adminSnippet updateSnippet diff --git a/app/assets/javascripts/snippets/queries/snippet.blob.query.graphql b/app/assets/javascripts/snippets/queries/snippet.blob.query.graphql deleted file mode 100644 index 785c88c185a..00000000000 --- a/app/assets/javascripts/snippets/queries/snippet.blob.query.graphql +++ /dev/null @@ -1,24 +0,0 @@ -#import '~/graphql_shared/fragments/blobviewer.fragment.graphql' - -query SnippetBlobFull($ids: [ID!]) { - snippets(ids: $ids) { - edges { - node { - id - blob { - binary - name - path - rawPath - size - simpleViewer { - ...BlobViewer - } - richViewer { - ...BlobViewer - } - } - } - } - } -} |