1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<script>
import { GlLoadingIcon } from '@gitlab/ui';
import { uniqueId } from 'lodash';
import BlobContent from '~/blob/components/blob_content.vue';
import BlobHeader from '~/blob/components/blob_header.vue';
import createFlash from '~/flash';
import { __ } from '~/locale';
import blobInfoQuery from '../queries/blob_info.query.graphql';
import projectPathQuery from '../queries/project_path.query.graphql';
export default {
components: {
BlobHeader,
BlobContent,
GlLoadingIcon,
},
apollo: {
projectPath: {
query: projectPathQuery,
},
blobInfo: {
query: blobInfoQuery,
variables() {
return {
projectPath: this.projectPath,
filePath: this.path,
};
},
error() {
createFlash({ message: __('An error occurred while loading the file. Please try again.') });
},
},
},
provide() {
return {
blobHash: uniqueId(),
};
},
props: {
path: {
type: String,
required: true,
},
},
data() {
return {
projectPath: '',
blobInfo: {
name: '',
size: '',
rawBlob: '',
type: '',
fileType: '',
tooLarge: false,
path: '',
editBlobPath: '',
ideEditPath: '',
storedExternally: false,
rawPath: '',
externalStorageUrl: '',
replacePath: '',
deletePath: '',
canLock: false,
isLocked: false,
lockLink: '',
canModifyBlob: true,
forkPath: '',
simpleViewer: '',
richViewer: '',
},
};
},
computed: {
isLoading() {
return this.$apollo.queries.blobInfo.loading;
},
viewer() {
const { fileType, tooLarge, type } = this.blobInfo;
return { fileType, tooLarge, type };
},
},
};
</script>
<template>
<div>
<gl-loading-icon v-if="isLoading" />
<div v-if="blobInfo && !isLoading">
<blob-header :blob="blobInfo" />
<blob-content
:blob="blobInfo"
:content="blobInfo.rawBlob"
:is-raw-content="true"
:active-viewer="viewer"
:loading="false"
/>
</div>
</div>
</template>
|