Skip to content

Commit

Permalink
[format]: update lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pizn committed Feb 1, 2016
1 parent 0b143e5 commit 4eb83d3
Show file tree
Hide file tree
Showing 26 changed files with 515 additions and 434 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"vars-on-top": 0,

// Disable comma-dangle unless need to support it
"comma-dangle": 0
"comma-dangle": 0,
"consistent-return": 1
},
"plugins": [
"react"
Expand Down
33 changes: 16 additions & 17 deletions src/actions/LeafActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function loginDone() {
auth.loginDone();
return {
type: types.AUTH_LOGIN_DONE,
}
};
}

export function logout() {
Expand All @@ -31,82 +31,81 @@ export function updateUserInfo(data) {
return {
type: types.UPDATE_USER_INFO,
data,
}
} else {
return {
types: [types.LOAD_USER_INFO, types.LOAD_USER_INFO_SUCCESS, types.LOAD_USER_INFO_FAIL],
promise: user.getInfo(),
}
};
}
return {
types: [types.LOAD_USER_INFO, types.LOAD_USER_INFO_SUCCESS, types.LOAD_USER_INFO_FAIL],
promise: user.getInfo(),
};
}

export function loadRepoInfo(data) {
return {
types: [types.LOAD_REPO_INFO, types.LOAD_REPO_INFO_SUCCESS, types.LOAD_REPO_INFO_FAIL],
promise: user.checkRepo(data.username),
}
};
}

export function updateRepoInfo(data) {
return {
type: types.UPLOAD_REPO_INFO,
data,
}
};
}

export function loadRepoTree(data) {
return {
types: [types.LOAD_REPO_TREE, types.LOAD_REPO_TREE_SUCCESS, types.LOAD_REPO_TREE_FAIL],
promise: repo.getTree(data.username, data.reponame),
}
};
}

export function readRepoTree(data) {
return {
types: [types.READ_REPO_TREE, types.READ_REPO_TREE_SUCCESS, types.READ_REPO_TREE_FAIL],
promise: repo.readTree(data.username, data.reponame, data.path),
}
};
}

export function readRepoBlob(data) {
return {
types: [types.READ_REPO_BLOB, types.READ_REPO_BLOB_SUCCESS, types.READ_REPO_BLOB_FAIL],
promise: repo.readBlob(data.username, data.reponame, data.path),
}
};
}

export function readRepoBlobCommit(data) {
return {
types: [types.READ_REPO_BLOB_COMMIT, types.READ_REPO_BLOB_COMMIT_SUCCESS, types.READ_REPO_BLOB_COMMIT_FAIL],
promise: repo.readBlobCommit(data.username, data.reponame, data.sha),
}
};
}

export function addRepoBlob(data) {
return {
types: [types.ADD_REPO_BLOB, types.ADD_REPO_BLOB_SUCCESS, types.ADD_REPO_BLOB_FAIL],
promise: repo.addBlob(data),
}
};
}

export function updateRepoBlob(data) {
return {
types: [types.UPDATE_REPO_BLOB, types.UPDATE_REPO_BLOB_SUCCESS, types.UPDATE_REPO_BLOB_FAIL],
promise: repo.writeBlob(data),
data,
}
};
}

export function removeRepoBlob(data) {
return {
types: [types.REMOVE_REPO_BLOB, types.REMOVE_REPO_BLOB_SUCCESS, types.REMOVE_REPO_BLOB_FAIL],
promise: repo.removeBlob(data),
data,
}
};
}

export function clearRepoBlob() {
return {
type: types.CLEAR_REPO_BLOB,
}
};
}
161 changes: 84 additions & 77 deletions src/components/Desktop/AddFile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component, PropTypes } from 'react';
import { Form, Item as FormItem } from 'antd/lib/form';

import Modal from 'antd/lib/modal';
import Row from 'antd/lib/row';
import Col from 'antd/lib/col';
import Input from 'antd/lib/input';
import Button from 'antd/lib/button';
Expand All @@ -11,101 +10,109 @@ import createForm from 'rc-form/lib/createForm';


class CreateFileForm extends Component {

static propTypes = {
modalVisible: PropTypes.bool,
modalHandleOk: PropTypes.func,
modalHandleCancel: PropTypes.func,
form: PropTypes.object,
}

modalHandleOk(e) {
e.preventDefault();
const { form, modalHandleOk } = this.props;
const { validateFields } = form;
validateFields((error, values) => {
if (!error) {
modalHandleOk(values);
} else {
console.log('error', error, values);
}
});
}

render() {
const { modalVisible, modalHandleOk, modalHandleCancel, form } = this.props;
const { getFieldProps, getFieldError } = form;
return (
<Modal ref="modal"
visible={modalVisible}
title='Add'
title="Add"
onOk={modalHandleOk}
onCancel={modalHandleCancel}
footer={[
<Button key="back" type="ghost" onClick={modalHandleCancel}>Cancle</Button>,
<Button key="submit" type="primary" onClick={this.modalHandleOk.bind(this)}>
Submit
</Button>
]}>
<Button key="back" type="ghost" onClick={modalHandleCancel}>Cancle</Button>,
<Button key="submit" type="primary" onClick={this.modalHandleOk.bind(this)}>
Submit
</Button>
]}
>
<Form horizontal>
<FormItem
label="URL:"
labelCol={{span: 6}}
wrapperCol={{span: 14}}
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('name') ? 'error' : 'success'}
>
<Input type="text" name="name" autoComplete="off" placeholder="2016-01-18-hello-world.md"
{...getFieldProps('name', {
rules: [{
type: "string",
required: true,
pattern: /^(((?:19|20)\d\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])-)+([a-zA-Z0-9-_])+(\.md|\.markdown|\.mdown|\.mkd|\.mkdown|\.ron|\.txt)$/,
message: "URL, eg: 2016-01-18-hello-world.md"
},
]})}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('name') ? getFieldError('name').join('') : ''}</p>
</Col>
</FormItem>
>
<Input type="text" name="name" autoComplete="off" placeholder="2016-01-18-hello-world.md"
{...getFieldProps('name', {
rules: [{
type: 'string',
required: true,
pattern: /^(((?:19|20)\d\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])-)+([a-zA-Z0-9-_])+(\.md|\.markdown|\.mdown|\.mkd|\.mkdown|\.ron|\.txt)$/,
message: 'URL, eg: 2016-01-18-hello-world.md',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('name') ? getFieldError('name').join('') : ''}</p>
</Col>
</FormItem>
<FormItem
label="Title:"
labelCol={{span: 6}}
wrapperCol={{span: 14}}
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('title') ? 'error' : 'success'}
>
<Input type="text" name="title" autoComplete="off" placeholder="title"
{...getFieldProps('title', {
rules: [{
type: "string",
required: true,
message: "Please input the title"
},
]})}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('title') ? getFieldError('title').join('') : ''}</p>
</Col>
</FormItem>
>
<Input type="text" name="title" autoComplete="off" placeholder="title"
{...getFieldProps('title', {
rules: [{
type: 'string',
required: true,
message: 'Please input the title',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('title') ? getFieldError('title').join('') : ''}</p>
</Col>
</FormItem>
<FormItem
label="Description:"
labelCol={{span: 6}}
wrapperCol={{span: 14}}
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('description') ? 'error' : 'success'}
>
<Input type="textarea" name="description" autoComplete="off" rows="5"
{...getFieldProps('description', {
rules: [{
type: "string",
required: true,
message: "Please input the description"
},
]})}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('description') ? getFieldError('description').join('') : ''}</p>
</Col>
</FormItem>
</Form>
</Modal>
)
>
<Input type="textarea" name="description" autoComplete="off" rows="5"
{...getFieldProps('description', {
rules: [{
type: 'string',
required: true,
message: 'Please input the description',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('description') ? getFieldError('description').join('') : ''}</p>
</Col>
</FormItem>
</Form>
</Modal>
);
}

modalHandleOk(e) {
e.preventDefault();
const { form, modalHandleOk } = this.props;
const { validateFields } = form;
validateFields((error, values) => {
if (!error) {
modalHandleOk(values);
} else {
console.log('error', error, values)
}
})
}
}

CreateFileForm.propTypes = {
form: PropTypes.object
}

export default createForm()(CreateFileForm);
export default createForm()(CreateFileForm);
9 changes: 8 additions & 1 deletion src/components/Desktop/Aside.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import classNames from 'classnames';

class Aside extends Component {

static propTypes = {
logout: PropTypes.func,
user: PropTypes.object,
repoInfo: PropTypes.object,
tree: PropTypes.object,
}

logout() {
const { logout } = this.props;
logout();
Expand Down Expand Up @@ -85,7 +92,7 @@ class Aside extends Component {
</Row>
</div>
</div>
)
);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/components/Desktop/Head.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Head extends Component {

static propTypes = {
logout: PropTypes.func,
addFile: PropTypes.func,
repoInfo: PropTypes.object,
params: PropTypes.object,
}

render() {
Expand All @@ -22,7 +25,7 @@ class Head extends Component {
const data = {
name: item,
path: crumbData.slice(0, index + 1).join('/'),
}
};
return (
<span key={index}>
{ index === crumbData.length - 1 &&
Expand Down Expand Up @@ -66,7 +69,6 @@ class Head extends Component {
</div>
);
}

}

export default Head;
Loading

0 comments on commit 4eb83d3

Please sign in to comment.