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' ;
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 ,
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 ( ) {
return this . snippet . visibilityLevel === SNIPPET _VISIBILITY _PUBLIC ;
} ,
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 >