Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5b7e7b29
Commit
5b7e7b29
authored
Feb 18, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makes request to correct endpoint and handles the response
parent
56b50e44
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
41 deletions
+107
-41
app/assets/javascripts/environments/components/deploy_board_component.js.es6
...pts/environments/components/deploy_board_component.js.es6
+31
-6
app/assets/javascripts/environments/components/environment.js.es6
...ts/javascripts/environments/components/environment.js.es6
+6
-3
app/assets/javascripts/environments/components/environments_table.js.es6
...scripts/environments/components/environments_table.js.es6
+23
-4
app/assets/javascripts/environments/services/environments_service.js.es6
...scripts/environments/services/environments_service.js.es6
+6
-0
app/assets/javascripts/environments/stores/environments_store.js.es6
...javascripts/environments/stores/environments_store.js.es6
+41
-28
No files found.
app/assets/javascripts/environments/components/deploy_board_component.js.es6
View file @
5b7e7b29
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
* [Mockup](https://gitlab.com/gitlab-org/gitlab-ce/uploads/2f655655c0eadf655d0ae7467b53002a/environments__deploy-graphic.png)
* [Mockup](https://gitlab.com/gitlab-org/gitlab-ce/uploads/2f655655c0eadf655d0ae7467b53002a/environments__deploy-graphic.png)
*
*
* The data of each deploy board needs to be fetched when we render the component.
* The data of each deploy board needs to be fetched when we render the component.
* Endpoint is /group/project/environments/{id}/status.json
*
*
* The endpoint response can sometimes be 204, in those cases we need to retry the request.
* The endpoint response can sometimes be 204, in those cases we need to retry the request.
* This should be done using backoff pooling and we should make no more than 3 request
* This should be done using backoff pooling and we should make no more than 3 request
...
@@ -28,8 +27,23 @@ module.exports = Vue.component('deploy_boards_components', {
...
@@ -28,8 +27,23 @@ module.exports = Vue.component('deploy_boards_components', {
},
},
props: {
props: {
endpoint: {
store: {
type: String,
type: Object,
required: true,
},
service: {
type: Object,
required: true,
},
data: {
type: Object,
required: true,
},
environmentID: {
type: Number,
required: true,
required: true,
},
},
},
},
...
@@ -42,9 +56,20 @@ module.exports = Vue.component('deploy_boards_components', {
...
@@ -42,9 +56,20 @@ module.exports = Vue.component('deploy_boards_components', {
};
};
},
},
created() {
beforeMount() {
// Fetch data
this.isLoading = true;
console.log('HERE!');
this.service.getDeployBoard(this.environmentID)
.then(resp => resp.json())
.then((response) => {
this.store.storeDeployBoard(this.environmentID, response);
})
.then(() => {
this.isLoading = false;
})
.catch(() => {
this.isLoading = false;
});
},
},
template: `
template: `
...
...
app/assets/javascripts/environments/components/environment.js.es6
View file @
5b7e7b29
...
@@ -23,6 +23,7 @@ module.exports = Vue.component('environment-component', {
...
@@ -23,6 +23,7 @@ module.exports = Vue.component('environment-component', {
return {
return {
store,
store,
service: {},
state: store.state,
state: store.state,
visibility: 'available',
visibility: 'available',
isLoading: false,
isLoading: false,
...
@@ -74,11 +75,11 @@ module.exports = Vue.component('environment-component', {
...
@@ -74,11 +75,11 @@ module.exports = Vue.component('environment-component', {
const endpoint = `${this.endpoint}?scope=${scope}&page=${pageNumber}`;
const endpoint = `${this.endpoint}?scope=${scope}&page=${pageNumber}`;
const
service = new EnvironmentsService(endpoint);
this.
service = new EnvironmentsService(endpoint);
this.isLoading = true;
this.isLoading = true;
return service.all()
return
this.
service.all()
.then(resp => ({
.then(resp => ({
headers: resp.headers,
headers: resp.headers,
body: resp.json(),
body: resp.json(),
...
@@ -187,7 +188,9 @@ module.exports = Vue.component('environment-component', {
...
@@ -187,7 +188,9 @@ module.exports = Vue.component('environment-component', {
:play-icon-svg="playIconSvg"
:play-icon-svg="playIconSvg"
:terminal-icon-svg="terminalIconSvg"
:terminal-icon-svg="terminalIconSvg"
:commit-icon-svg="commitIconSvg"
:commit-icon-svg="commitIconSvg"
:toggleDeployBoard="toggleDeployBoard">
:toggleDeployBoard="toggleDeployBoard"
:store="store"
:service="service">
</environment-table>
</environment-table>
<table-pagination
<table-pagination
...
...
app/assets/javascripts/environments/components/environments_table.js.es6
View file @
5b7e7b29
...
@@ -11,8 +11,8 @@ const DeployBoard = require('./deploy_board_component');
...
@@ -11,8 +11,8 @@ const DeployBoard = require('./deploy_board_component');
module.exports = Vue.component('environment-table-component', {
module.exports = Vue.component('environment-table-component', {
components: {
components: {
'environment-item':
EnvironmentItem,
EnvironmentItem,
'deploy-board':
DeployBoard,
DeployBoard,
},
},
props: {
props: {
...
@@ -51,7 +51,17 @@ module.exports = Vue.component('environment-table-component', {
...
@@ -51,7 +51,17 @@ module.exports = Vue.component('environment-table-component', {
toggleDeployBoard: {
toggleDeployBoard: {
type: Function,
type: Function,
required: false,
required: true,
},
store: {
type: Object,
required: true,
},
service: {
type: Object,
required: true,
},
},
},
},
...
@@ -70,6 +80,7 @@ module.exports = Vue.component('environment-table-component', {
...
@@ -70,6 +80,7 @@ module.exports = Vue.component('environment-table-component', {
<tbody>
<tbody>
<template v-for="model in environments"
<template v-for="model in environments"
v-bind:model="model">
v-bind:model="model">
<tr is="environment-item"
<tr is="environment-item"
:model="model"
:model="model"
:can-create-deployment="canCreateDeployment"
:can-create-deployment="canCreateDeployment"
...
@@ -80,10 +91,18 @@ module.exports = Vue.component('environment-table-component', {
...
@@ -80,10 +91,18 @@ module.exports = Vue.component('environment-table-component', {
:toggleDeployBoard="toggleDeployBoard.bind(model)"></tr>
:toggleDeployBoard="toggleDeployBoard.bind(model)"></tr>
<tr v-if="model.isDeployBoardVisible">
<tr v-if="model.isDeployBoardVisible">
<td colspan="6" class="deploy-board-container">
<td colspan="6" class="deploy-board-container">
<deploy-board></deploy-board>
<deploy-board
:store="store"
:service="service"
:environmentID="model.id"
:data="model.deployBoardData">
</deploy-board>
</td>
</td>
</tr>
</tr>
</template>
</template>
</tbody>
</tbody>
</table>
</table>
...
...
app/assets/javascripts/environments/services/environments_service.js.es6
View file @
5b7e7b29
...
@@ -3,11 +3,17 @@ const Vue = require('vue');
...
@@ -3,11 +3,17 @@ const Vue = require('vue');
class EnvironmentsService {
class EnvironmentsService {
constructor(endpoint) {
constructor(endpoint) {
this.environments = Vue.resource(endpoint);
this.environments = Vue.resource(endpoint);
this.deployBoard = Vue.resource('environments/{id}/status.json');
}
}
all() {
all() {
return this.environments.get();
return this.environments.get();
}
}
getDeployBoard(environmentID) {
return this.deployBoard.get({ id: environmentID });
}
}
}
module.exports = EnvironmentsService;
module.exports = EnvironmentsService;
app/assets/javascripts/environments/stores/environments_store.js.es6
View file @
5b7e7b29
...
@@ -31,9 +31,12 @@ class EnvironmentsStore {
...
@@ -31,9 +31,12 @@ class EnvironmentsStore {
* In those cases we add `isFolder` key in order to render it properly.
* In those cases we add `isFolder` key in order to render it properly.
*
*
* Top level environments - when the size is 1 - with `rollout_status`
* Top level environments - when the size is 1 - with `rollout_status`
* can render a deploy board. We add `isDeployBoardVisible` key to those envrionments.
* can render a deploy board. We add `isDeployBoardVisible` and `deployBoardData`
* This key let's us know if we should or not render the deploy board. It will
* keys to those envrionments.
* be toggled when the user clicks to seee the deploy board.
* The first key will let's us know if we should or not render the deploy board.
* It will be toggled when the user clicks to seee the deploy board.
*
* The second key will allow us to update the environment with the received deploy board data.
*
*
* @param {Array} environments
* @param {Array} environments
* @returns {Array}
* @returns {Array}
...
@@ -44,10 +47,16 @@ class EnvironmentsStore {
...
@@ -44,10 +47,16 @@ class EnvironmentsStore {
if (env.size > 1) {
if (env.size > 1) {
filtered = Object.assign({}, env, { isFolder: true, folderName: env.name });
filtered = Object.assign({}, env, { isFolder: true, folderName: env.name });
} else {
}
// FIX ME
// no folders items with `x` key can have a deploy board
// FIX ME
filtered = Object.assign({}, env, { isDeployBoardVisible: false });
// no folders items with `x` key can have a deploy board
if (env.size === 1) {
filtered = Object.assign({}, env, {
isDeployBoardVisible: false,
deployBoardData: {},
deployBoardEndpoint: `environments/${env.id}/status.json`,
});
}
}
if (env.latest) {
if (env.latest) {
...
@@ -65,27 +74,6 @@ class EnvironmentsStore {
...
@@ -65,27 +74,6 @@ class EnvironmentsStore {
return filteredEnvironments;
return filteredEnvironments;
}
}
/**
* Toggles deploy board visibility for the provided environment.
*
* @param {Object} environment
* @return {Array}
*/
toggleDeployBoard(environment) {
const environments = Object.assign([], this.state.environments);
this.state.environments = environments.map((env) => {
let updated = Object.assign({}, env);
if (env.id === environment.id) {
updated = Object.assign({}, updated, { isDeployBoardVisible: !env.isDeployBoardVisible });
}
return updated;
});
return this.state.environments;
}
/**
/**
* Stores the pagination information needed to render the pagination for the
* Stores the pagination information needed to render the pagination for the
* table.
* table.
...
@@ -129,6 +117,31 @@ class EnvironmentsStore {
...
@@ -129,6 +117,31 @@ class EnvironmentsStore {
this.state.stoppedCounter = count;
this.state.stoppedCounter = count;
return count;
return count;
}
}
/**
* Toggles deploy board visibility for the provided environment.
*
* @param {Object} environment
* @return {Array}
*/
toggleDeployBoard(environment) {
const environments = Object.assign([], this.state.environments);
this.state.environments = environments.map((env) => {
let updated = Object.assign({}, env);
if (env.id === environment.id) {
updated = Object.assign({}, updated, { isDeployBoardVisible: !env.isDeployBoardVisible });
}
return updated;
});
return this.state.environments;
}
storeDeployBoard(environmentID, deployBoard) {
console.log(environmentID, deployBoard);
}
}
}
module.exports = EnvironmentsStore;
module.exports = EnvironmentsStore;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment