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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
1.7 KiB
Vue
Raw Normal View History

2019-12-26 22:10:19 +05:30
<script>
2023-03-04 22:38:38 +05:30
import { GlIcon, GlLink, GlLoadingIcon } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
2020-03-13 15:44:24 +05:30
import { handleLocationHash } from '~/lib/utils/common_utils';
2023-03-04 22:38:38 +05:30
import { renderGFM } from '~/behaviors/markdown/render_gfm';
2020-10-24 23:57:45 +05:30
import readmeQuery from '../../queries/readme.query.graphql';
2019-12-26 22:10:19 +05:30
export default {
apollo: {
readme: {
2020-10-24 23:57:45 +05:30
query: readmeQuery,
2019-12-26 22:10:19 +05:30
variables() {
return {
2020-10-24 23:57:45 +05:30
url: this.blob.webPath,
2019-12-26 22:10:19 +05:30
};
},
loadingKey: 'loading',
},
},
components: {
2021-01-03 14:25:43 +05:30
GlIcon,
2019-12-26 22:10:19 +05:30
GlLink,
GlLoadingIcon,
},
2021-11-18 22:05:49 +05:30
directives: {
SafeHtml,
},
2019-12-26 22:10:19 +05:30
props: {
blob: {
type: Object,
required: true,
},
},
data() {
return {
readme: null,
loading: 0,
};
},
2020-03-13 15:44:24 +05:30
watch: {
readme(newVal) {
if (newVal) {
this.$nextTick(() => {
handleLocationHash();
2023-03-04 22:38:38 +05:30
renderGFM(this.$refs.readme);
2020-03-13 15:44:24 +05:30
});
}
},
},
2022-03-02 08:16:31 +05:30
safeHtmlConfig: {
ADD_TAGS: ['copy-code'],
},
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">
2021-02-22 17:27:13 +05:30
<gl-icon name="doc-text" />
2020-10-24 23:57:45 +05:30
<gl-link :href="blob.webPath">
2020-01-01 13:55:28 +05:30
<strong>{{ blob.name }}</strong>
</gl-link>
</div>
2019-12-26 22:10:19 +05:30
</div>
2021-01-29 00:20:46 +05:30
<div class="blob-viewer" data-qa-selector="blob_viewer_content" itemprop="about">
2022-07-23 23:45:48 +05:30
<gl-loading-icon v-if="loading > 0" size="lg" color="dark" class="my-4 mx-auto" />
2022-03-02 08:16:31 +05:30
<div
v-else-if="readme"
ref="readme"
v-safe-html:[$options.safeHtmlConfig]="readme.html"
></div>
2019-12-26 22:10:19 +05:30
</div>
</article>
</template>