Changes after review

This commit is contained in:
Filipa Lacerda 2017-03-30 11:08:27 +01:00 committed by Kamil Trzcinski
parent 7c1bb6c349
commit 386f958620
No known key found for this signature in database
GPG Key ID: 4505F5C7E12C6A5A
2 changed files with 11 additions and 9 deletions

View File

@ -44,7 +44,7 @@ export default Vue.component('pipelines-table', {
state: store.state,
isLoading: false,
hasError: false,
setIsMakingRequest: false,
isMakingRequest: false,
};
},

View File

@ -123,18 +123,23 @@ export default {
tagsPath: this.tagsPath,
};
},
pageParameter() {
return gl.utils.getParameterByName('page') || this.pagenum;
},
scopeParameter() {
return gl.utils.getParameterByName('scope') || this.apiScope;
},
},
created() {
const pageNumber = gl.utils.getParameterByName('page') || this.pagenum;
const scope = gl.utils.getParameterByName('scope') || this.apiScope;
this.service = new PipelinesService(this.endpoint);
const poll = new Poll({
resource: this.service,
method: 'getPipelines',
data: { page: pageNumber, scope },
data: { page: this.pageParameter, scope: this.scopeParameter },
successCallback: this.successCallback,
errorCallback: this.errorCallback,
notificationCallback: this.setIsMakingRequest,
@ -183,13 +188,10 @@ export default {
},
fetchPipelines() {
const pageNumber = gl.utils.getParameterByName('page') || this.pagenum;
const scope = gl.utils.getParameterByName('scope') || this.apiScope;
if (!this.isMakingRequest) {
this.isLoading = true;
this.service.getPipelines({ scope, page: pageNumber })
this.service.getPipelines({ scope: this.scopeParameter, page: this.pageParameter })
.then(response => this.successCallback(response))
.catch(() => this.errorCallback());
}