debian-mirror-gitlab/app/assets/javascripts/snippets/components/show.vue

62 lines
1.8 KiB
Vue
Raw Normal View History

2020-01-01 13:55:28 +05:30
<script>
2020-10-24 23:57:45 +05:30
import { GlLoadingIcon } from '@gitlab/ui';
2020-07-28 23:09:34 +05:30
import BlobEmbeddable from '~/blob/components/blob_embeddable.vue';
2020-01-01 13:55:28 +05:30
import SnippetHeader from './snippet_header.vue';
2020-03-13 15:44:24 +05:30
import SnippetTitle from './snippet_title.vue';
import SnippetBlob from './snippet_blob_view.vue';
2020-10-24 23:57:45 +05:30
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';
2020-07-28 23:09:34 +05:30
import { SNIPPET_VISIBILITY_PUBLIC } from '~/snippets/constants';
2020-04-22 19:07:51 +05:30
2020-10-24 23:57:45 +05:30
import { SNIPPET_MARK_VIEW_APP_START } from '~/performance_constants';
2020-01-01 13:55:28 +05:30
export default {
components: {
2020-07-28 23:09:34 +05:30
BlobEmbeddable,
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() {
performance.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-01-01 13:55:28 +05:30
class="loading-animation prepend-top-20 append-bottom-20"
/>
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">
<blob-embeddable v-if="embeddable" class="gl-flex-fill-1" :url="snippet.webUrl" />
<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>