debian-mirror-gitlab/app/assets/javascripts/repository/components/preview/index.vue

65 lines
1.4 KiB
Vue
Raw Normal View History

2019-12-26 22:10:19 +05:30
<script>
2020-03-09 13:42:32 +05:30
import $ from 'jquery';
import '~/behaviors/markdown/render_gfm';
2019-12-26 22:10:19 +05:30
import { GlLink, GlLoadingIcon } from '@gitlab/ui';
2020-03-09 13:42:32 +05:30
import { handleLocationHash } from '~/lib/utils/common_utils';
2019-12-26 22:10:19 +05:30
import getReadmeQuery from '../../queries/getReadme.query.graphql';
export default {
apollo: {
readme: {
query: getReadmeQuery,
variables() {
return {
url: this.blob.webUrl,
};
},
loadingKey: 'loading',
},
},
components: {
GlLink,
GlLoadingIcon,
},
props: {
blob: {
type: Object,
required: true,
},
},
data() {
return {
readme: null,
loading: 0,
};
},
2020-03-09 13:42:32 +05:30
watch: {
readme(newVal) {
if (newVal) {
this.$nextTick(() => {
handleLocationHash();
$(this.$refs.readme).renderGFM();
});
}
},
},
2019-12-26 22:10:19 +05:30
};
</script>
<template>
<article class="file-holder limited-width-container readme-holder">
2020-01-01 13:55:28 +05:30
<div class="js-file-title file-title-flex-parent">
<div class="file-header-content">
<i aria-hidden="true" class="fa fa-file-text-o fa-fw"></i>
<gl-link :href="blob.webUrl">
<strong>{{ blob.name }}</strong>
</gl-link>
</div>
2019-12-26 22:10:19 +05:30
</div>
<div class="blob-viewer">
2020-03-09 13:42:32 +05:30
<gl-loading-icon v-if="loading > 0" size="md" color="dark" class="my-4 mx-auto" />
<div v-else-if="readme" ref="readme" v-html="readme.html"></div>
2019-12-26 22:10:19 +05:30
</div>
</article>
</template>