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
0
Merge Requests
0
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
Boxiang Sun
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
*
*
* Used in a hierarchical structure to show folders with children
* in a table.
* 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)
* 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)
* for more information.
*/
const Store = gl.environmentsList.EnvironmentsStore;
window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {};
gl.environmentsList.EnvironmentItem = Vue.component('environment-item', {
template: '#environment-item-template',
props: {
...
...
@@ -31,11 +31,11 @@
},
computed: {
/**
* If an item has a `children` entry it means it is a folder.
* Folder items have different behaviours - it is possible to toggle
* them and show their children.
* them and show their children.
*
* @returns {Boolean}
*/
...
...
app/assets/javascripts/environments/environments_bundle.js.es6
View file @
dcafd476
...
...
@@ -6,30 +6,29 @@
//= require ../boards/vue_resource_interceptor
$(() => {
const environmentsListApp = document.getElementById('environments-list-view');
const Store = gl.environmentsList.EnvironmentsStore;
window.gl = window.gl || {};
if (gl.EnvironmentsListApp) {
gl.EnvironmentsListApp.$destroy(true);
}
const filterState = (state) => (environment) => environment.state === state && environment;
// recursiveMap :: (Function, Array) -> Array
// recursiveMap :: (Function, Array) -> Array
const recursiveMap = (fn, arr) => {
return arr.map((item) => {
if (!item.children) { return fn(item); }
const filteredChildren = recursiveMap(fn, item.children).filter(Boolean);
if (filteredChildren.length) {
item.children = filteredChildren;
return item;
}
}).filter(Boolean);
};
...
...
@@ -47,18 +46,18 @@ $(() => {
loading: true,
visibility: 'available'
},
computed: {
filteredEnvironments () {
return recursiveMap(filterState(this.visibility), this.state.environments);
}
},
init: Store.create.bind(Store),
created() {
gl.environmentsService = new EnvironmentsService(this.endpoint);
const scope = this.$options.getQueryParameter('scope');
if (scope) {
this.visibility = scope;
...
...
@@ -67,7 +66,7 @@ $(() => {
/**
* Fetches all the environmnets and stores them.
* Toggles loading property.
* Toggles loading property.
*/
ready() {
gl.environmentsService.all().then((resp) => {
...
...
@@ -75,11 +74,11 @@ $(() => {
this.loading = false;
});
},
/**
* Transforms the url parameter into an object and
* returns the one requested.
*
*
* @param {String} param
* @returns {String} The value of the requested parameter.
*/
...
...
app/assets/javascripts/environments/services/environments_service.js.es6
View file @
dcafd476
class EnvironmentsService {
constructor (root) {
Vue.http.options.root = root;
this.environments = Vue.resource(root);
Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-Token'] = $.rails.csrfToken();
next();
});
}
all () {
return this.environments.get();
}
...
...
app/assets/javascripts/environments/stores/environmnets_store.js.es6
View file @
dcafd476
...
...
@@ -12,15 +12,15 @@
},
/**
* In order to display a tree view we need to modify the received
* data in to a tree structure based on `environment_type`
* In order to display a tree view we need to modify the received
* data in to a tree structure based on `environment_type`
* sorted alphabetically.
* 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
* not accept non-prop attributes.
*
*
*
*
* @example
* it will transform this:
* [
...
...
@@ -30,7 +30,7 @@
* ]
* into this:
* [
* { name: "review", children:
* { name: "review", children:
* [
* { name: "environment", environment_type: "review", vue-isChildren: true},
* { name: "environment_2", environment_type: "review", vue-isChildren: true}
...
...
@@ -38,8 +38,8 @@
* },
* {name: "environment_1", environment_type: null}
* ]
*
*
*
*
* @param {Array} environments List of environments.
* @returns {Array} Tree structured array with the received environments.
*/
...
...
@@ -56,13 +56,13 @@
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)}));
}
//transforms created date for deployment in a human readable format
if (environment.last_deployment.created_at) {
// TODO - how to do this without jquery
}
}
if (environment.environment_type !== null) {
const occurs = acc.find((element, index, array) => {
return element.children && element.name === environment.environment_type;
...
...
@@ -89,15 +89,15 @@
}, []).sort(this.sortByName);
this.state.environments = 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.
*
* @param {Array} environments
* @param {Array} environments
* @param {String} state
* @returns {Number}
*/
...
...
spec/javascripts/environments/environments_store_spec.js.es6
View file @
dcafd476
...
...
@@ -4,14 +4,14 @@
//= require environments/services/environments_service
//= require environments/stores/environments_store
//= require ./mock_data
//
//
(() => {
beforeEach(() => {
gl.environmentsService = new EnvironmentsService('test/environments');
gl.environmentsList.EnvironmentsStore.create();
});
describe('Store', () => {
it('starts with a blank state', () => {
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