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

37 lines
852 B
JavaScript
Raw Normal View History

2020-03-13 15:44:24 +05:30
import getFiles from '../queries/getFiles.query.graphql';
import getRefMixin from './get_ref';
import getProjectPath from '../queries/getProjectPath.query.graphql';
export default {
mixins: [getRefMixin],
apollo: {
projectPath: {
query: getProjectPath,
},
},
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({
query: getFiles,
variables: {
projectPath: this.projectPath,
ref: this.ref,
path: this.loadingPath,
nextPageCursor: '',
pageSize: 100,
},
})
.then(() => next());
},
},
};