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

146 lines
3.7 KiB
Vue
Raw Normal View History

2019-09-04 21:01:54 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlDeprecatedSkeletonLoading as GlSkeletonLoading, GlButton } from '@gitlab/ui';
2019-09-04 21:01:54 +05:30
import { sprintf, __ } from '../../../locale';
import getRefMixin from '../../mixins/get_ref';
2020-10-24 23:57:45 +05:30
import projectPathQuery from '../../queries/project_path.query.graphql';
2019-09-04 21:01:54 +05:30
import TableHeader from './header.vue';
import ParentRow from './parent_row.vue';
2021-03-11 19:13:27 +05:30
import TableRow from './row.vue';
2019-09-04 21:01:54 +05:30
export default {
components: {
2019-12-26 22:10:19 +05:30
GlSkeletonLoading,
2019-09-04 21:01:54 +05:30
TableHeader,
TableRow,
ParentRow,
2020-11-24 15:15:51 +05:30
GlButton,
2019-09-04 21:01:54 +05:30
},
mixins: [getRefMixin],
apollo: {
projectPath: {
2020-10-24 23:57:45 +05:30
query: projectPathQuery,
2019-09-04 21:01:54 +05:30
},
},
props: {
path: {
type: String,
required: true,
},
2019-12-26 22:10:19 +05:30
entries: {
type: Object,
required: false,
default: () => ({}),
},
isLoading: {
type: Boolean,
required: true,
},
2020-03-13 15:44:24 +05:30
loadingPath: {
type: String,
required: false,
default: '',
},
2020-11-24 15:15:51 +05:30
hasMore: {
type: Boolean,
required: true,
},
2019-09-04 21:01:54 +05:30
},
data() {
return {
projectPath: '',
};
},
computed: {
2021-09-04 01:27:46 +05:30
totalEntries() {
return Object.values(this.entries).flat().length;
},
2019-09-04 21:01:54 +05:30
tableCaption() {
2019-12-26 22:10:19 +05:30
if (this.isLoading) {
return sprintf(
__(
'Loading files, directories, and submodules in the path %{path} for commit reference %{ref}',
),
{ path: this.path, ref: this.ref },
);
}
2019-09-04 21:01:54 +05:30
return sprintf(
__('Files, directories, and submodules in the path %{path} for commit reference %{ref}'),
{ path: this.path, ref: this.ref },
);
},
showParentRow() {
2021-09-30 23:02:18 +05:30
return ['', '/'].indexOf(this.path) === -1;
2019-09-04 21:01:54 +05:30
},
},
2020-11-24 15:15:51 +05:30
methods: {
showMore() {
this.$emit('showMore');
},
},
2019-09-04 21:01:54 +05:30
};
</script>
<template>
<div class="tree-content-holder">
<div class="table-holder bordered-box">
2020-03-13 15:44:24 +05:30
<table
:aria-label="tableCaption"
class="table tree-table"
aria-live="polite"
data-qa-selector="file_tree_table"
>
2019-09-04 21:01:54 +05:30
<table-header v-once />
<tbody>
2020-03-13 15:44:24 +05:30
<parent-row
2020-07-28 23:09:34 +05:30
v-if="showParentRow"
2020-05-05 14:28:15 +05:30
:commit-ref="escapedRef"
2020-03-13 15:44:24 +05:30
:path="path"
:loading-path="loadingPath"
/>
2019-09-04 21:01:54 +05:30
<template v-for="val in entries">
<table-row
v-for="entry in val"
:id="entry.id"
:key="`${entry.flatPath}-${entry.id}`"
2019-12-26 22:10:19 +05:30
:sha="entry.sha"
2019-09-30 21:07:59 +05:30
:project-path="projectPath"
2019-09-04 21:01:54 +05:30
:current-path="path"
2019-09-30 21:07:59 +05:30
:name="entry.name"
2019-09-04 21:01:54 +05:30
:path="entry.flatPath"
:type="entry.type"
2020-10-24 23:57:45 +05:30
:url="entry.webUrl || entry.webPath"
2020-07-28 23:09:34 +05:30
:mode="entry.mode"
2019-09-30 21:07:59 +05:30
:submodule-tree-url="entry.treeUrl"
2019-09-04 21:01:54 +05:30
:lfs-oid="entry.lfsOid"
2020-03-13 15:44:24 +05:30
:loading-path="loadingPath"
2021-09-04 01:27:46 +05:30
:total-entries="totalEntries"
2019-09-04 21:01:54 +05:30
/>
</template>
2019-12-26 22:10:19 +05:30
<template v-if="isLoading">
<tr v-for="i in 5" :key="i" aria-hidden="true">
<td><gl-skeleton-loading :lines="1" class="h-auto" /></td>
<td><gl-skeleton-loading :lines="1" class="h-auto" /></td>
<td><gl-skeleton-loading :lines="1" class="ml-auto h-auto w-50" /></td>
</tr>
</template>
2020-11-24 15:15:51 +05:30
<template v-if="hasMore">
<tr>
<td align="center" colspan="3" class="gl-p-0!">
<gl-button
variant="link"
class="gl-display-flex gl-w-full gl-py-4!"
:loading="isLoading"
@click="showMore"
>
{{ s__('ProjectFileTree|Show more') }}
</gl-button>
</td>
</tr>
</template>
2019-09-04 21:01:54 +05:30
</tbody>
</table>
</div>
</div>
</template>