debian-mirror-gitlab/app/assets/javascripts/repository/components/table/row.vue

189 lines
4.3 KiB
Vue
Raw Normal View History

2019-09-04 21:01:54 +05:30
<script>
2020-03-13 15:44:24 +05:30
import { escapeRegExp } from 'lodash';
2020-04-22 19:07:51 +05:30
import {
GlBadge,
GlLink,
GlSkeletonLoading,
GlTooltipDirective,
GlLoadingIcon,
GlIcon,
} from '@gitlab/ui';
import { escapeFileUrl } from '~/lib/utils/url_utility';
2019-09-30 21:07:59 +05:30
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
2020-04-22 19:07:51 +05:30
import FileIcon from '~/vue_shared/components/file_icon.vue';
2019-09-04 21:01:54 +05:30
import getRefMixin from '../../mixins/get_ref';
2020-10-24 23:57:45 +05:30
import commitQuery from '../../queries/commit.query.graphql';
2019-09-04 21:01:54 +05:30
export default {
components: {
GlBadge,
2019-09-30 21:07:59 +05:30
GlLink,
GlSkeletonLoading,
2020-03-13 15:44:24 +05:30
GlLoadingIcon,
2020-04-22 19:07:51 +05:30
GlIcon,
2019-09-30 21:07:59 +05:30
TimeagoTooltip,
2020-04-22 19:07:51 +05:30
FileIcon,
2019-12-26 22:10:19 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
2019-09-30 21:07:59 +05:30
},
apollo: {
commit: {
2020-10-24 23:57:45 +05:30
query: commitQuery,
2019-09-30 21:07:59 +05:30
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-12-26 22:10:19 +05:30
sha: {
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,
},
2020-07-28 23:09:34 +05:30
mode: {
type: String,
required: false,
default: '',
},
2019-09-04 21:01:54 +05:30
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,
},
2020-03-13 15:44:24 +05:30
loadingPath: {
type: String,
required: false,
default: '',
},
2019-09-30 21:07:59 +05:30
},
data() {
return {
commit: null,
};
2019-09-04 21:01:54 +05:30
},
computed: {
routerLinkTo() {
2020-03-13 15:44:24 +05:30
return this.isFolder
2020-05-05 14:28:15 +05:30
? { path: `/-/tree/${this.escapedRef}/${escapeFileUrl(this.path)}` }
2020-03-13 15:44:24 +05:30
: null;
2019-09-04 21:01:54 +05:30
},
isFolder() {
return this.type === 'tree';
},
isSubmodule() {
return this.type === 'commit';
},
linkComponent() {
return this.isFolder ? 'router-link' : 'a';
},
fullPath() {
2020-03-13 15:44:24 +05:30
return this.path.replace(new RegExp(`^${escapeRegExp(this.currentPath)}/`), '');
2019-09-04 21:01:54 +05:30
},
shortSha() {
2019-12-26 22:10:19 +05:30
return this.sha.slice(0, 8);
},
hasLockLabel() {
return this.commit && this.commit.lockLabel;
2019-09-04 21:01:54 +05:30
},
},
};
</script>
<template>
2020-04-22 19:07:51 +05:30
<tr class="tree-item">
<td class="tree-item-file-name cursor-default position-relative">
2020-03-13 15:44:24 +05:30
<component
:is="linkComponent"
ref="link"
:to="routerLinkTo"
:href="url"
2020-04-22 19:07:51 +05:30
:class="{
'is-submodule': isSubmodule,
}"
class="tree-item-link str-truncated"
2020-03-13 15:44:24 +05:30
data-qa-selector="file_name_link"
>
2020-04-22 19:07:51 +05:30
<file-icon
:file-name="fullPath"
2020-07-28 23:09:34 +05:30
:file-mode="mode"
2020-04-22 19:07:51 +05:30
:folder="isFolder"
:submodule="isSubmodule"
:loading="path === loadingPath"
css-classes="position-relative file-icon"
class="mr-1 position-relative text-secondary"
/><span class="position-relative">{{ fullPath }}</span>
2019-09-04 21:01:54 +05:30
</component>
2020-06-23 00:09:42 +05:30
<!-- eslint-disable @gitlab/vue-require-i18n-strings -->
<gl-badge v-if="lfsOid" variant="muted" size="sm" class="ml-1" data-qa-selector="label-lfs"
>LFS</gl-badge
>
<!-- eslint-enable @gitlab/vue-require-i18n-strings -->
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>
2020-04-22 19:07:51 +05:30
<gl-icon
2019-12-26 22:10:19 +05:30
v-if="hasLockLabel"
v-gl-tooltip
:title="commit.lockLabel"
name="lock"
:size="12"
2020-04-22 19:07:51 +05:30
class="ml-1"
2019-12-26 22:10:19 +05:30
/>
2019-09-04 21:01:54 +05:30
</td>
2020-04-22 19:07:51 +05:30
<td class="d-none d-sm-table-cell tree-commit cursor-default">
2019-12-26 22:10:19 +05:30
<gl-link
v-if="commit"
:href="commit.commitPath"
:title="commit.message"
class="str-truncated-100 tree-commit-link"
2020-05-24 23:13:21 +05:30
v-html="commit.titleHtml"
/>
2019-09-30 21:07:59 +05:30
<gl-skeleton-loading v-else :lines="1" class="h-auto" />
</td>
2020-04-22 19:07:51 +05:30
<td class="tree-time-ago text-right cursor-default">
2019-12-26 22:10:19 +05:30
<timeago-tooltip v-if="commit" :time="commit.committedDate" />
2019-09-30 21:07:59 +05:30
<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>