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

37 lines
870 B
JavaScript
Raw Normal View History

2021-01-29 00:20:46 +05:30
import filesQuery from 'shared_queries/repository/files.query.graphql';
2020-03-13 15:44:24 +05:30
import getRefMixin from './get_ref';
2020-10-24 23:57:45 +05:30
import projectPathQuery from '../queries/project_path.query.graphql';
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({
2020-10-24 23:57:45 +05:30
query: filesQuery,
2020-03-13 15:44:24 +05:30
variables: {
projectPath: this.projectPath,
ref: this.ref,
path: this.loadingPath,
nextPageCursor: '',
pageSize: 100,
},
})
.then(() => next());
},
},
};