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
dcafd476
Commit
dcafd476
authored
Oct 26, 2016
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes trailing whitespace
parent
3c383f9f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
45 deletions
+44
-45
app/assets/javascripts/environments/components/environment_item.js.es6
...vascripts/environments/components/environment_item.js.es6
+10
-10
app/assets/javascripts/environments/environments_bundle.js.es6
...ssets/javascripts/environments/environments_bundle.js.es6
+15
-16
app/assets/javascripts/environments/services/environments_service.js.es6
...scripts/environments/services/environments_service.js.es6
+4
-4
app/assets/javascripts/environments/stores/environmnets_store.js.es6
...javascripts/environments/stores/environmnets_store.js.es6
+13
-13
spec/javascripts/environments/environments_store_spec.js.es6
spec/javascripts/environments/environments_store_spec.js.es6
+2
-2
No files found.
app/assets/javascripts/environments/components/environment_item.js.es6
View file @
dcafd476
(() => {
(() => {
/**
/**
* Envrionment Item Component
* Envrionment Item Component
*
*
* Used in a hierarchical structure to show folders with children
* Used in a hierarchical structure to show folders with children
* in a table.
* in a table.
* Recursive component based on [Tree View](https://vuejs.org/examples/tree-view.html)
* Recursive component based on [Tree View](https://vuejs.org/examples/tree-view.html)
*
*
* See this [issue](https://gitlab.com/gitlab-org/gitlab-ce/issues/22539)
* See this [issue](https://gitlab.com/gitlab-org/gitlab-ce/issues/22539)
* for more information.
* for more information.
*/
*/
const Store = gl.environmentsList.EnvironmentsStore;
const Store = gl.environmentsList.EnvironmentsStore;
window.gl = window.gl || {};
window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {};
window.gl.environmentsList = window.gl.environmentsList || {};
gl.environmentsList.EnvironmentItem = Vue.component('environment-item', {
gl.environmentsList.EnvironmentItem = Vue.component('environment-item', {
template: '#environment-item-template',
template: '#environment-item-template',
props: {
props: {
...
@@ -31,11 +31,11 @@
...
@@ -31,11 +31,11 @@
},
},
computed: {
computed: {
/**
/**
* If an item has a `children` entry it means it is a folder.
* If an item has a `children` entry it means it is a folder.
* Folder items have different behaviours - it is possible to toggle
* Folder items have different behaviours - it is possible to toggle
* them and show their children.
* them and show their children.
*
*
* @returns {Boolean}
* @returns {Boolean}
*/
*/
...
...
app/assets/javascripts/environments/environments_bundle.js.es6
View file @
dcafd476
...
@@ -6,30 +6,29 @@
...
@@ -6,30 +6,29 @@
//= require ../boards/vue_resource_interceptor
//= require ../boards/vue_resource_interceptor
$(() => {
$(() => {
const environmentsListApp = document.getElementById('environments-list-view');
const environmentsListApp = document.getElementById('environments-list-view');
const Store = gl.environmentsList.EnvironmentsStore;
const Store = gl.environmentsList.EnvironmentsStore;
window.gl = window.gl || {};
window.gl = window.gl || {};
if (gl.EnvironmentsListApp) {
if (gl.EnvironmentsListApp) {
gl.EnvironmentsListApp.$destroy(true);
gl.EnvironmentsListApp.$destroy(true);
}
}
const filterState = (state) => (environment) => environment.state === state && environment;
const filterState = (state) => (environment) => environment.state === state && environment;
// recursiveMap :: (Function, Array) -> Array
// recursiveMap :: (Function, Array) -> Array
const recursiveMap = (fn, arr) => {
const recursiveMap = (fn, arr) => {
return arr.map((item) => {
return arr.map((item) => {
if (!item.children) { return fn(item); }
if (!item.children) { return fn(item); }
const filteredChildren = recursiveMap(fn, item.children).filter(Boolean);
const filteredChildren = recursiveMap(fn, item.children).filter(Boolean);
if (filteredChildren.length) {
if (filteredChildren.length) {
item.children = filteredChildren;
item.children = filteredChildren;
return item;
return item;
}
}
}).filter(Boolean);
}).filter(Boolean);
};
};
...
@@ -47,18 +46,18 @@ $(() => {
...
@@ -47,18 +46,18 @@ $(() => {
loading: true,
loading: true,
visibility: 'available'
visibility: 'available'
},
},
computed: {
computed: {
filteredEnvironments () {
filteredEnvironments () {
return recursiveMap(filterState(this.visibility), this.state.environments);
return recursiveMap(filterState(this.visibility), this.state.environments);
}
}
},
},
init: Store.create.bind(Store),
init: Store.create.bind(Store),
created() {
created() {
gl.environmentsService = new EnvironmentsService(this.endpoint);
gl.environmentsService = new EnvironmentsService(this.endpoint);
const scope = this.$options.getQueryParameter('scope');
const scope = this.$options.getQueryParameter('scope');
if (scope) {
if (scope) {
this.visibility = scope;
this.visibility = scope;
...
@@ -67,7 +66,7 @@ $(() => {
...
@@ -67,7 +66,7 @@ $(() => {
/**
/**
* Fetches all the environmnets and stores them.
* Fetches all the environmnets and stores them.
* Toggles loading property.
* Toggles loading property.
*/
*/
ready() {
ready() {
gl.environmentsService.all().then((resp) => {
gl.environmentsService.all().then((resp) => {
...
@@ -75,11 +74,11 @@ $(() => {
...
@@ -75,11 +74,11 @@ $(() => {
this.loading = false;
this.loading = false;
});
});
},
},
/**
/**
* Transforms the url parameter into an object and
* Transforms the url parameter into an object and
* returns the one requested.
* returns the one requested.
*
*
* @param {String} param
* @param {String} param
* @returns {String} The value of the requested parameter.
* @returns {String} The value of the requested parameter.
*/
*/
...
...
app/assets/javascripts/environments/services/environments_service.js.es6
View file @
dcafd476
class EnvironmentsService {
class EnvironmentsService {
constructor (root) {
constructor (root) {
Vue.http.options.root = root;
Vue.http.options.root = root;
this.environments = Vue.resource(root);
this.environments = Vue.resource(root);
Vue.http.interceptors.push((request, next) => {
Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
next();
next();
});
});
}
}
all () {
all () {
return this.environments.get();
return this.environments.get();
}
}
...
...
app/assets/javascripts/environments/stores/environmnets_store.js.es6
View file @
dcafd476
...
@@ -12,15 +12,15 @@
...
@@ -12,15 +12,15 @@
},
},
/**
/**
* In order to display a tree view we need to modify the received
* In order to display a tree view we need to modify the received
* data in to a tree structure based on `environment_type`
* data in to a tree structure based on `environment_type`
* sorted alphabetically.
* sorted alphabetically.
* In each children a `vue-` property will be added. This property will be
* In each children a `vue-` property will be added. This property will be
* used to know if an item is a children mostly for css purposes. This is
* used to know if an item is a children mostly for css purposes. This is
* needed because the children row is a fragment instance and therfore does
* needed because the children row is a fragment instance and therfore does
* not accept non-prop attributes.
* not accept non-prop attributes.
*
*
*
*
* @example
* @example
* it will transform this:
* it will transform this:
* [
* [
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
* ]
* ]
* into this:
* into this:
* [
* [
* { name: "review", children:
* { name: "review", children:
* [
* [
* { name: "environment", environment_type: "review", vue-isChildren: true},
* { name: "environment", environment_type: "review", vue-isChildren: true},
* { name: "environment_2", environment_type: "review", vue-isChildren: true}
* { name: "environment_2", environment_type: "review", vue-isChildren: true}
...
@@ -38,8 +38,8 @@
...
@@ -38,8 +38,8 @@
* },
* },
* {name: "environment_1", environment_type: null}
* {name: "environment_1", environment_type: null}
* ]
* ]
*
*
*
*
* @param {Array} environments List of environments.
* @param {Array} environments List of environments.
* @returns {Array} Tree structured array with the received environments.
* @returns {Array} Tree structured array with the received environments.
*/
*/
...
@@ -56,13 +56,13 @@
...
@@ -56,13 +56,13 @@
if (environment.last_deployment.manual_actions) {
if (environment.last_deployment.manual_actions) {
environment.last_deployment.manual_actions = environment.last_deployment.manual_actions.map((action) => Object.assign({}, action, {name: gl.text.humanize(action.name)}));
environment.last_deployment.manual_actions = environment.last_deployment.manual_actions.map((action) => Object.assign({}, action, {name: gl.text.humanize(action.name)}));
}
}
//transforms created date for deployment in a human readable format
//transforms created date for deployment in a human readable format
if (environment.last_deployment.created_at) {
if (environment.last_deployment.created_at) {
// TODO - how to do this without jquery
// TODO - how to do this without jquery
}
}
}
}
if (environment.environment_type !== null) {
if (environment.environment_type !== null) {
const occurs = acc.find((element, index, array) => {
const occurs = acc.find((element, index, array) => {
return element.children && element.name === environment.environment_type;
return element.children && element.name === environment.environment_type;
...
@@ -89,15 +89,15 @@
...
@@ -89,15 +89,15 @@
}, []).sort(this.sortByName);
}, []).sort(this.sortByName);
this.state.environments = environmentsTree;
this.state.environments = environmentsTree;
return environmentsTree;
return environmentsTree;
},
},
/**
/**
* Given an array of environments, returns the number of environments
* Given an array of environments, returns the number of environments
* that have the given state.
* that have the given state.
*
*
* @param {Array} environments
* @param {Array} environments
* @param {String} state
* @param {String} state
* @returns {Number}
* @returns {Number}
*/
*/
...
...
spec/javascripts/environments/environments_store_spec.js.es6
View file @
dcafd476
...
@@ -4,14 +4,14 @@
...
@@ -4,14 +4,14 @@
//= require environments/services/environments_service
//= require environments/services/environments_service
//= require environments/stores/environments_store
//= require environments/stores/environments_store
//= require ./mock_data
//= require ./mock_data
//
//
(() => {
(() => {
beforeEach(() => {
beforeEach(() => {
gl.environmentsService = new EnvironmentsService('test/environments');
gl.environmentsService = new EnvironmentsService('test/environments');
gl.environmentsList.EnvironmentsStore.create();
gl.environmentsList.EnvironmentsStore.create();
});
});
describe('Store', () => {
describe('Store', () => {
it('starts with a blank state', () => {
it('starts with a blank state', () => {
expect(gl.environmentsList.EnvironmentsStore.state.environments.length).toBe(0);
expect(gl.environmentsList.EnvironmentsStore.state.environments.length).toBe(0);
...
...
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