Commit 1d30feef authored by Filipa Lacerda's avatar Filipa Lacerda

Changes after review

parent e89b6eea
/* eslint-disable no-new */ /* eslint-disable no-new, import/first */
/** /**
* Renders a deploy board. * Renders a deploy board.
* *
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
* for more information * for more information
*/ */
const Vue = require('vue'); import instanceComponent from './deploy_board_instance_component.js.es6';
const instanceComponent = require('./deploy_board_instance_component'); import statusCodes from '~/lib/utils/http_status';
require('~/lib/utils/common_utils'); import Flash from '~/flash';
const Flash = require('~/flash'); import '~/lib/utils/common_utils.js.es6';
module.exports = Vue.component('deploy_boards_components', { module.exports = {
components: { components: {
instanceComponent, instanceComponent,
...@@ -63,13 +63,12 @@ module.exports = Vue.component('deploy_boards_components', { ...@@ -63,13 +63,12 @@ module.exports = Vue.component('deploy_boards_components', {
this.isLoading = true; this.isLoading = true;
const maxNumberOfRequests = 3; const maxNumberOfRequests = 3;
const noContentStatus = 204;
// If the response is 204, we make 3 more requests. // If the response is 204, we make 3 more requests.
gl.utils.backOff((next, stop) => { gl.utils.backOff((next, stop) => {
this.service.getDeployBoard(this.environmentID) this.service.getDeployBoard(this.environmentID)
.then((resp) => { .then((resp) => {
if (resp.status === noContentStatus) { if (resp.status === statusCodes.NO_CONTENT) {
this.backOffRequestCounter = this.backOffRequestCounter += 1; this.backOffRequestCounter = this.backOffRequestCounter += 1;
if (this.backOffRequestCounter < maxNumberOfRequests) { if (this.backOffRequestCounter < maxNumberOfRequests) {
...@@ -84,7 +83,7 @@ module.exports = Vue.component('deploy_boards_components', { ...@@ -84,7 +83,7 @@ module.exports = Vue.component('deploy_boards_components', {
.catch(stop); .catch(stop);
}) })
.then((resp) => { .then((resp) => {
if (resp.status === noContentStatus) { if (resp.status === statusCodes.NO_CONTENT) {
this.hasError = true; this.hasError = true;
return resp; return resp;
} }
...@@ -126,7 +125,7 @@ module.exports = Vue.component('deploy_boards_components', { ...@@ -126,7 +125,7 @@ module.exports = Vue.component('deploy_boards_components', {
<div class="js-deploy-board deploy-board"> <div class="js-deploy-board deploy-board">
<div v-if="isLoading"> <div v-if="isLoading">
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin" aria-hidden="true"></i>
</div> </div>
<div v-if="canRenderDeployBoard"> <div v-if="canRenderDeployBoard">
...@@ -175,4 +174,4 @@ module.exports = Vue.component('deploy_boards_components', { ...@@ -175,4 +174,4 @@ module.exports = Vue.component('deploy_boards_components', {
</div> </div>
</div> </div>
`, `,
}); };
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
const Vue = require('vue'); const Vue = require('vue');
module.exports = Vue.component('deploy_board_instance_component', { module.exports = {
props: { props: {
...@@ -48,4 +48,4 @@ module.exports = Vue.component('deploy_board_instance_component', { ...@@ -48,4 +48,4 @@ module.exports = Vue.component('deploy_board_instance_component', {
data-placement="top"> data-placement="top">
</div> </div>
`, `,
}); };
...@@ -89,7 +89,7 @@ module.exports = Vue.component('environment-component', { ...@@ -89,7 +89,7 @@ module.exports = Vue.component('environment-component', {
this.isLoading = true; this.isLoading = true;
return this.service.all() return this.service.get()
.then(resp => ({ .then(resp => ({
headers: resp.headers, headers: resp.headers,
body: resp.json(), body: resp.json(),
......
...@@ -93,7 +93,7 @@ module.exports = Vue.component('environment-folder-view', { ...@@ -93,7 +93,7 @@ module.exports = Vue.component('environment-folder-view', {
this.isLoading = true; this.isLoading = true;
return this.service.all() return this.service.get()
.then(resp => ({ .then(resp => ({
headers: resp.headers, headers: resp.headers,
body: resp.json(), body: resp.json(),
......
...@@ -7,7 +7,7 @@ class EnvironmentsService { ...@@ -7,7 +7,7 @@ class EnvironmentsService {
this.deployBoard = Vue.resource('environments/{id}/status.json'); this.deployBoard = Vue.resource('environments/{id}/status.json');
} }
all() { get() {
return this.environments.get(); return this.environments.get();
} }
......
/**
* exports HTTP status codes
*/
const statusCodes = {
NO_CONTENT: 204,
OK: 200,
};
export default statusCodes;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment