2019-09-04 21:01:54 +05:30
|
|
|
<script>
|
2019-09-30 21:07:59 +05:30
|
|
|
import { GlBadge, GlLink, GlSkeletonLoading } from '@gitlab/ui';
|
2019-09-04 21:01:54 +05:30
|
|
|
import { visitUrl } from '~/lib/utils/url_utility';
|
2019-09-30 21:07:59 +05:30
|
|
|
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
2019-09-04 21:01:54 +05:30
|
|
|
import { getIconName } from '../../utils/icon';
|
|
|
|
import getRefMixin from '../../mixins/get_ref';
|
2019-09-30 21:07:59 +05:30
|
|
|
import getCommit from '../../queries/getCommit.query.graphql';
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlBadge,
|
2019-09-30 21:07:59 +05:30
|
|
|
GlLink,
|
|
|
|
GlSkeletonLoading,
|
|
|
|
TimeagoTooltip,
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
commit: {
|
|
|
|
query: getCommit,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
fileName: this.name,
|
|
|
|
type: this.type,
|
|
|
|
path: this.currentPath,
|
|
|
|
projectPath: this.projectPath,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
2019-09-04 21:01:54 +05:30
|
|
|
},
|
|
|
|
mixins: [getRefMixin],
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
projectPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-09-04 21:01:54 +05:30
|
|
|
currentPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2019-09-04 21:01:54 +05:30
|
|
|
path: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
url: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
lfsOid: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
submoduleTreeUrl: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
commit: null,
|
|
|
|
};
|
2019-09-04 21:01:54 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
routerLinkTo() {
|
|
|
|
return this.isFolder ? { path: `/tree/${this.ref}/${this.path}` } : null;
|
|
|
|
},
|
|
|
|
iconName() {
|
|
|
|
return `fa-${getIconName(this.type, this.path)}`;
|
|
|
|
},
|
|
|
|
isFolder() {
|
|
|
|
return this.type === 'tree';
|
|
|
|
},
|
|
|
|
isSubmodule() {
|
|
|
|
return this.type === 'commit';
|
|
|
|
},
|
|
|
|
linkComponent() {
|
|
|
|
return this.isFolder ? 'router-link' : 'a';
|
|
|
|
},
|
|
|
|
fullPath() {
|
|
|
|
return this.path.replace(new RegExp(`^${this.currentPath}/`), '');
|
|
|
|
},
|
|
|
|
shortSha() {
|
|
|
|
return this.id.slice(0, 8);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
openRow() {
|
|
|
|
if (this.isFolder) {
|
|
|
|
this.$router.push(this.routerLinkTo);
|
|
|
|
} else {
|
|
|
|
visitUrl(this.url);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-09-30 21:07:59 +05:30
|
|
|
<tr :class="`file_${id}`" class="tree-item" @click="openRow">
|
2019-09-04 21:01:54 +05:30
|
|
|
<td class="tree-item-file-name">
|
|
|
|
<i :aria-label="type" role="img" :class="iconName" class="fa fa-fw"></i>
|
|
|
|
<component :is="linkComponent" :to="routerLinkTo" :href="url" class="str-truncated">
|
|
|
|
{{ fullPath }}
|
|
|
|
</component>
|
2019-09-30 21:07:59 +05:30
|
|
|
<gl-badge v-if="lfsOid" variant="default" class="label-lfs ml-1">LFS</gl-badge>
|
2019-09-04 21:01:54 +05:30
|
|
|
<template v-if="isSubmodule">
|
2019-09-30 21:07:59 +05:30
|
|
|
@ <gl-link :href="submoduleTreeUrl" class="commit-sha">{{ shortSha }}</gl-link>
|
2019-09-04 21:01:54 +05:30
|
|
|
</template>
|
|
|
|
</td>
|
2019-09-30 21:07:59 +05:30
|
|
|
<td class="d-none d-sm-table-cell tree-commit">
|
|
|
|
<gl-link v-if="commit" :href="commit.commitPath" class="str-truncated-100 tree-commit-link">
|
|
|
|
{{ commit.message }}
|
|
|
|
</gl-link>
|
|
|
|
<gl-skeleton-loading v-else :lines="1" class="h-auto" />
|
|
|
|
</td>
|
|
|
|
<td class="tree-time-ago text-right">
|
|
|
|
<timeago-tooltip v-if="commit" :time="commit.committedDate" tooltip-placement="bottom" />
|
|
|
|
<gl-skeleton-loading v-else :lines="1" class="ml-auto h-auto w-50" />
|
|
|
|
</td>
|
2019-09-04 21:01:54 +05:30
|
|
|
</tr>
|
|
|
|
</template>
|