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

90 lines
2.7 KiB
Vue
Raw Normal View History

2020-01-01 13:55:28 +05:30
<script>
2022-02-27 12:50:16 +05:30
import { GlAlert, 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';
2022-10-11 01:57:18 +05:30
import { VISIBILITY_LEVEL_PUBLIC_STRING } from '~/visibility_level/constants';
2021-03-11 19:13:27 +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';
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,
2022-02-27 12:50:16 +05:30
GlAlert,
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() {
2022-10-11 01:57:18 +05:30
return this.snippet.visibilityLevel === VISIBILITY_LEVEL_PUBLIC_STRING;
2020-07-28 23:09:34 +05:30
},
2020-10-24 23:57:45 +05:30
canBeCloned() {
return Boolean(this.snippet.sshUrlToRepo || this.snippet.httpUrlToRepo);
},
2022-02-27 12:50:16 +05:30
hasUnretrievableBlobs() {
return this.snippet.hasUnretrievableBlobs;
},
2020-10-24 23:57:45 +05:30
},
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>
2022-02-27 12:50:16 +05:30
<gl-alert v-if="hasUnretrievableBlobs" variant="danger" class="gl-mb-3" :dismissible="false">
{{
__(
'WARNING: This snippet contains hidden files which might be used to mask malicious behavior. Exercise caution if cloning and executing code from this snippet.',
)
}}
</gl-alert>
2021-10-29 20:43:33 +05:30
<snippet-blob
v-for="blob in blobs"
:key="blob.path"
:snippet="snippet"
:blob="blob"
class="project-highlight-puc"
/>
2020-03-13 15:44:24 +05:30
</template>
2020-01-01 13:55:28 +05:30
</div>
</template>