debian-mirror-gitlab/app/assets/javascripts/repository/mixins/preload.js

38 lines
1,021 B
JavaScript
Raw Normal View History

2021-01-29 00:20:46 +05:30
import filesQuery from 'shared_queries/repository/files.query.graphql';
2021-11-11 11:23:49 +05:30
import paginatedTreeQuery from 'shared_queries/repository/paginated_tree.query.graphql';
2020-10-24 23:57:45 +05:30
import projectPathQuery from '../queries/project_path.query.graphql';
2021-03-11 19:13:27 +05:30
import getRefMixin from './get_ref';
2020-03-13 15:44:24 +05:30
export default {
mixins: [getRefMixin],
apollo: {
projectPath: {
2020-10-24 23:57:45 +05:30
query: projectPathQuery,
2020-03-13 15:44:24 +05:30
},
},
data() {
return { projectPath: '', loadingPath: null };
},
beforeRouteUpdate(to, from, next) {
this.preload(to.params.path, next);
},
methods: {
preload(path = '/', next) {
this.loadingPath = path.replace(/^\//, '');
return this.$apollo
.query({
2021-11-11 11:23:49 +05:30
query: gon.features.paginatedTreeGraphqlQuery ? paginatedTreeQuery : filesQuery,
2020-03-13 15:44:24 +05:30
variables: {
projectPath: this.projectPath,
ref: this.ref,
path: this.loadingPath,
nextPageCursor: '',
pageSize: 100,
},
})
.then(() => next());
},
},
};