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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
895 B
JavaScript
Raw Normal View History

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-12-11 22:18:48 +05:30
query: paginatedTreeQuery,
2020-03-13 15:44:24 +05:30
variables: {
projectPath: this.projectPath,
ref: this.ref,
path: this.loadingPath,
nextPageCursor: '',
pageSize: 100,
},
})
.then(() => next());
},
},
};