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

117 lines
2.9 KiB
Vue
Raw Normal View History

2019-09-04 21:01:54 +05:30
<script>
2019-12-26 22:10:19 +05:30
import { GlSkeletonLoading } from '@gitlab/ui';
2019-09-04 21:01:54 +05:30
import { sprintf, __ } from '../../../locale';
import getRefMixin from '../../mixins/get_ref';
2019-09-30 21:07:59 +05:30
import getProjectPath from '../../queries/getProjectPath.query.graphql';
2019-09-04 21:01:54 +05:30
import TableHeader from './header.vue';
import TableRow from './row.vue';
import ParentRow from './parent_row.vue';
export default {
components: {
2019-12-26 22:10:19 +05:30
GlSkeletonLoading,
2019-09-04 21:01:54 +05:30
TableHeader,
TableRow,
ParentRow,
},
mixins: [getRefMixin],
apollo: {
projectPath: {
query: getProjectPath,
},
},
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-09 13:42:32 +05:30
loadingPath: {
type: String,
required: false,
default: '',
},
2019-09-04 21:01:54 +05:30
},
data() {
return {
projectPath: '',
};
},
computed: {
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() {
2019-12-26 22:10:19 +05:30
return !this.isLoading && ['', '/'].indexOf(this.path) === -1;
2019-09-04 21:01:54 +05:30
},
},
};
</script>
<template>
<div class="tree-content-holder">
<div class="table-holder bordered-box">
2020-03-09 13:42:32 +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-09 13:42:32 +05:30
<parent-row
v-show="showParentRow"
:commit-ref="ref"
: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"
:url="entry.webUrl"
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-09 13:42:32 +05:30
:loading-path="loadingPath"
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>
2019-09-04 21:01:54 +05:30
</tbody>
</table>
</div>
</div>
</template>