summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repository/components/table
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-07 18:06:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-07 18:06:21 +0000
commitd8ccc7a00b7a1ea954263170a2044257424a2cfe (patch)
tree0a29cb558aae61795da47c82ce7e87983c5dc4af /app/assets/javascripts/repository/components/table
parent90a06a20be61bb6d48d77746091492831153e075 (diff)
downloadgitlab-ce-d8ccc7a00b7a1ea954263170a2044257424a2cfe.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/repository/components/table')
-rw-r--r--app/assets/javascripts/repository/components/table/index.vue84
1 files changed, 12 insertions, 72 deletions
diff --git a/app/assets/javascripts/repository/components/table/index.vue b/app/assets/javascripts/repository/components/table/index.vue
index 98923c79c7a..ac20549acb8 100644
--- a/app/assets/javascripts/repository/components/table/index.vue
+++ b/app/assets/javascripts/repository/components/table/index.vue
@@ -1,16 +1,12 @@
<script>
import { GlSkeletonLoading } from '@gitlab/ui';
-import createFlash from '~/flash';
import { sprintf, __ } from '../../../locale';
import getRefMixin from '../../mixins/get_ref';
-import getFiles from '../../queries/getFiles.query.graphql';
import getProjectPath from '../../queries/getProjectPath.query.graphql';
import TableHeader from './header.vue';
import TableRow from './row.vue';
import ParentRow from './parent_row.vue';
-const PAGE_SIZE = 100;
-
export default {
components: {
GlSkeletonLoading,
@@ -29,22 +25,24 @@ export default {
type: String,
required: true,
},
+ entries: {
+ type: Object,
+ required: false,
+ default: () => ({}),
+ },
+ isLoading: {
+ type: Boolean,
+ required: true,
+ },
},
data() {
return {
projectPath: '',
- nextPageCursor: '',
- entries: {
- trees: [],
- submodules: [],
- blobs: [],
- },
- isLoadingFiles: false,
};
},
computed: {
tableCaption() {
- if (this.isLoadingFiles) {
+ if (this.isLoading) {
return sprintf(
__(
'Loading files, directories, and submodules in the path %{path} for commit reference %{ref}',
@@ -59,65 +57,7 @@ export default {
);
},
showParentRow() {
- return !this.isLoadingFiles && ['', '/'].indexOf(this.path) === -1;
- },
- },
- watch: {
- $route: function routeChange() {
- this.entries.trees = [];
- this.entries.submodules = [];
- this.entries.blobs = [];
- this.nextPageCursor = '';
- this.fetchFiles();
- },
- },
- mounted() {
- // We need to wait for `ref` and `projectPath` to be set
- this.$nextTick(() => this.fetchFiles());
- },
- methods: {
- fetchFiles() {
- this.isLoadingFiles = true;
-
- return this.$apollo
- .query({
- query: getFiles,
- variables: {
- projectPath: this.projectPath,
- ref: this.ref,
- path: this.path || '/',
- nextPageCursor: this.nextPageCursor,
- pageSize: PAGE_SIZE,
- },
- })
- .then(({ data }) => {
- if (!data) return;
-
- const pageInfo = this.hasNextPage(data.project.repository.tree);
-
- this.isLoadingFiles = false;
- this.entries = Object.keys(this.entries).reduce(
- (acc, key) => ({
- ...acc,
- [key]: this.normalizeData(key, data.project.repository.tree[key].edges),
- }),
- {},
- );
-
- if (pageInfo && pageInfo.hasNextPage) {
- this.nextPageCursor = pageInfo.endCursor;
- this.fetchFiles();
- }
- })
- .catch(() => createFlash(__('An error occurred while fetching folder content.')));
- },
- normalizeData(key, data) {
- return this.entries[key].concat(data.map(({ node }) => node));
- },
- hasNextPage(data) {
- return []
- .concat(data.trees.pageInfo, data.submodules.pageInfo, data.blobs.pageInfo)
- .find(({ hasNextPage }) => hasNextPage);
+ return !this.isLoading && ['', '/'].indexOf(this.path) === -1;
},
},
};
@@ -145,7 +85,7 @@ export default {
:lfs-oid="entry.lfsOid"
/>
</template>
- <template v-if="isLoadingFiles">
+ <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>