Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6077dea7
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6077dea7
编写于
2月 09, 2017
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove store from global namespace, use CSJ instead
上级
acb68ae6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
76 deletion
+65
-76
app/assets/javascripts/environments/components/environment.js.es6
...ts/javascripts/environments/components/environment.js.es6
+4
-8
app/assets/javascripts/environments/environments_bundle.js.es6
...ssets/javascripts/environments/environments_bundle.js.es6
+0
-7
app/assets/javascripts/environments/stores/environments_store.js.es6
...javascripts/environments/stores/environments_store.js.es6
+60
-60
app/assets/javascripts/vue_shared/vue_resource_interceptor.js.es6
...ts/javascripts/vue_shared/vue_resource_interceptor.js.es6
+1
-1
未找到文件。
app/assets/javascripts/environments/components/environment.js.es6
浏览文件 @
6077dea7
...
...
@@ -7,18 +7,12 @@ window.Vue = require('vue');
window.Vue.use(require('vue-resource'));
require('../services/environments_service');
require('./environment_item');
const Store = require('../stores/environments_store');
(() => {
window.gl = window.gl || {};
gl.environmentsList.EnvironmentsComponent = Vue.component('environment-component', {
props: {
store: {
type: Object,
required: true,
default: () => ({}),
},
},
components: {
'environment-item': gl.environmentsList.EnvironmentItem,
...
...
@@ -26,9 +20,11 @@ require('./environment_item');
data() {
const environmentsData = document.querySelector('#environments-list-view').dataset;
const store = new Store();
return {
state: this.store.state,
store,
state: store.state,
visibility: 'available',
isLoading: false,
cssContainerClass: environmentsData.cssClass,
...
...
app/assets/javascripts/environments/environments_bundle.js.es6
浏览文件 @
6077dea7
window.Vue = require('vue');
require('./stores/environments_store');
require('./components/environment');
require('../vue_shared/vue_resource_interceptor');
...
...
@@ -9,14 +8,8 @@ $(() => {
if (gl.EnvironmentsListApp) {
gl.EnvironmentsListApp.$destroy(true);
}
const Store = gl.environmentsList.EnvironmentsStore;
gl.EnvironmentsListApp = new gl.environmentsList.EnvironmentsComponent({
el: document.querySelector('#environments-list-view'),
propsData: {
store: Store.create(),
},
});
});
app/assets/javascripts/environments/stores/environments_store.js.es6
浏览文件 @
6077dea7
/* eslint-disable no-param-reassign */
(() => {
window.gl = window.gl || {};
window.gl.environmentsList = window.gl.environmentsList || {};
/**
* Environments Store.
*
* Stores received environments, count of stopped environments and count of
* available environments.
*/
class EnvironmentsStore {
constructor() {
this.state = {};
this.state.environments = [];
this.state.stoppedCounter = 0;
this.state.availableCounter = 0;
this.state.filteredEnvironments = [];
gl.environmentsList.EnvironmentsStore = {
state: {},
return this;
}
create() {
this.state.environments = [];
this.state.stoppedCounter = 0;
this.state.availableCounter = 0;
this.state.filteredEnvironments = [];
/**
*
* Stores the received environments.
*
* Each environment has the following schema
* { name: String, size: Number, latest: Object }
*
* If the `size` is bigger than 1, it means it should be rendered as a folder.
* In those cases we add `isFolder` key in order to render it properly.
*
* @param {Array} environments
* @returns {Array}
*/
storeEnvironments(environments = []) {
const filteredEnvironments = environments.map((env) => {
if (env.size > 1) {
return Object.assign({}, env, { isFolder: true });
}
return
this
;
}
,
return
env
;
}
);
/**
*
* Stores the received environments.
*
* Each environment has the following schema
* { name: String, size: Number, latest: Object }
*
* If the `size` is bigger than 1, it means it should be rendered as a folder.
* In those cases we add `isFolder` key in order to render it properly.
*
* @param {Array} environments
* @returns {Array}
*/
storeEnvironments(environments = []) {
const filteredEnvironments = environments.map((env) => {
if (env.size > 1) {
return Object.assign({}, env, { isFolder: true });
}
this.state.environments = filteredEnvironments;
return env
;
});
return filteredEnvironments
;
}
this.state.environments = filteredEnvironments;
/**
* Stores the number of available environments.
*
* @param {Number} count = 0
* @return {Number}
*/
storeAvailableCount(count = 0) {
this.state.availableCounter = count;
return count;
}
return filteredEnvironments;
},
/**
* Stores the number of closed environments.
*
* @param {Number} count = 0
* @return {Number}
*/
storeStoppedCount(count = 0) {
this.state.stoppedCounter = count;
return count;
}
}
/**
* Stores the number of available environments.
*
* @param {Number} count = 0
* @return {Number}
*/
storeAvailableCount(count = 0) {
this.state.availableCounter = count;
return count;
},
/**
* Stores the number of closed environments.
*
* @param {Number} count = 0
* @return {Number}
*/
storeStoppedCount(count = 0) {
this.state.stoppedCounter = count;
return count;
},
};
})();
module.exports = EnvironmentsStore;
app/assets/javascripts/vue_shared/vue_resource_interceptor.js.es6
浏览文件 @
6077dea7
...
...
@@ -6,7 +6,7 @@ Vue.http.interceptors.push((request, next) => {
Vue.activeResources = Vue.activeResources ? Vue.activeResources + 1 : 1;
next((response) => {
if (typeof response.data === 'string'
&& response.status !== 500
) {
if (typeof response.data === 'string') {
response.data = JSON.parse(response.data);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录