2020-01-01 13:55:28 +05:30
|
|
|
<script>
|
2020-10-24 23:57:45 +05:30
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import eventHub from '~/blob/components/eventhub';
|
2021-01-03 14:25:43 +05:30
|
|
|
import {
|
|
|
|
SNIPPET_MARK_VIEW_APP_START,
|
|
|
|
SNIPPET_MEASURE_BLOBS_CONTENT,
|
2021-01-29 00:20:46 +05:30
|
|
|
} from '~/performance/constants';
|
|
|
|
import { performanceMarkAndMeasure } from '~/performance/utils';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { SNIPPET_VISIBILITY_PUBLIC } from '~/snippets/constants';
|
|
|
|
import CloneDropdownButton from '~/vue_shared/components/clone_dropdown.vue';
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
import { getSnippetMixin } from '../mixins/snippets';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { markBlobPerformance } from '../utils/blob';
|
2021-03-11 19:13:27 +05:30
|
|
|
import EmbedDropdown from './embed_dropdown.vue';
|
|
|
|
import SnippetBlob from './snippet_blob_view.vue';
|
|
|
|
import SnippetHeader from './snippet_header.vue';
|
|
|
|
import SnippetTitle from './snippet_title.vue';
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
eventHub.$on(SNIPPET_MEASURE_BLOBS_CONTENT, markBlobPerformance);
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
2020-11-24 15:15:51 +05:30
|
|
|
EmbedDropdown,
|
2020-01-01 13:55:28 +05:30
|
|
|
SnippetHeader,
|
2020-03-13 15:44:24 +05:30
|
|
|
SnippetTitle,
|
2020-01-01 13:55:28 +05:30
|
|
|
GlLoadingIcon,
|
2020-03-13 15:44:24 +05:30
|
|
|
SnippetBlob,
|
2020-10-24 23:57:45 +05:30
|
|
|
CloneDropdownButton,
|
2020-01-01 13:55:28 +05:30
|
|
|
},
|
2020-04-22 19:07:51 +05:30
|
|
|
mixins: [getSnippetMixin],
|
2020-07-28 23:09:34 +05:30
|
|
|
computed: {
|
|
|
|
embeddable() {
|
|
|
|
return this.snippet.visibilityLevel === SNIPPET_VISIBILITY_PUBLIC;
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
canBeCloned() {
|
|
|
|
return Boolean(this.snippet.sshUrlToRepo || this.snippet.httpUrlToRepo);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
beforeCreate() {
|
2021-01-03 14:25:43 +05:30
|
|
|
performanceMarkAndMeasure({ mark: SNIPPET_MARK_VIEW_APP_START });
|
2020-07-28 23:09:34 +05:30
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div class="js-snippet-view">
|
|
|
|
<gl-loading-icon
|
|
|
|
v-if="isLoading"
|
|
|
|
:label="__('Loading snippet')"
|
2020-04-22 19:07:51 +05:30
|
|
|
size="lg"
|
2020-11-24 15:15:51 +05:30
|
|
|
class="loading-animation prepend-top-20 gl-mb-6"
|
2020-01-01 13:55:28 +05:30
|
|
|
/>
|
2020-03-13 15:44:24 +05:30
|
|
|
<template v-else>
|
|
|
|
<snippet-header :snippet="snippet" />
|
|
|
|
<snippet-title :snippet="snippet" />
|
2020-10-24 23:57:45 +05:30
|
|
|
<div class="gl-display-flex gl-justify-content-end gl-mb-5">
|
2020-11-24 15:15:51 +05:30
|
|
|
<embed-dropdown
|
|
|
|
v-if="embeddable"
|
|
|
|
:url="snippet.webUrl"
|
|
|
|
data-qa-selector="snippet_embed_dropdown"
|
|
|
|
/>
|
2020-10-24 23:57:45 +05:30
|
|
|
<clone-dropdown-button
|
|
|
|
v-if="canBeCloned"
|
|
|
|
class="gl-ml-3"
|
|
|
|
:ssh-link="snippet.sshUrlToRepo"
|
|
|
|
:http-link="snippet.httpUrlToRepo"
|
|
|
|
data-qa-selector="clone_button"
|
|
|
|
/>
|
2020-07-28 23:09:34 +05:30
|
|
|
</div>
|
2020-10-24 23:57:45 +05:30
|
|
|
<snippet-blob v-for="blob in blobs" :key="blob.path" :snippet="snippet" :blob="blob" />
|
2020-03-13 15:44:24 +05:30
|
|
|
</template>
|
2020-01-01 13:55:28 +05:30
|
|
|
</div>
|
|
|
|
</template>
|