Skip to content

Commit

Permalink
[feat]: add error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
pizn committed Jan 21, 2016
1 parent 1b55f46 commit de6c006
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 15 deletions.
11 changes: 8 additions & 3 deletions src/components/Desktop/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ class List extends Component {
)
return (
<div className="leaf-desktop-list">
{ tree.loading &&
{ !tree.loaded &&
<div className="leaf-desktop-list-loading">
<Icon type="loading" />
{ !tree.error &&
<Icon type="loading" />
}
{ tree.error &&
<Icon type="frown-circle" />
}
</div>
}
{ !tree.loading &&
{ tree.loaded &&
<ul className="leaf-desktop-list-cnt clearfix">
{files}
</ul>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Post/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ class Editor extends Component {
<div className={containerClassName} >
{ !blob.loaded &&
<div className="loading">
<Icon type="loading" />
{ !blob.error &&
<Icon type="loading" />
}
</div>
}
<div className={penClassName}>
Expand Down
10 changes: 7 additions & 3 deletions src/components/Post/Head.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class Head extends Component {

render() {
const { blob, meta, params } = this.props;

// define backUrl
let backDir;
let backDir = '';
if (blob.loaded) {
backDir = params.splat.split(blob.data.name)[0];
backDir = backDir !== '' ? 'd/' + backDir : '';
Expand Down Expand Up @@ -75,7 +74,12 @@ class Head extends Component {
}
{ !blob.loaded &&
<h1 className="title">
<Icon type="loading" />
{ !blob.error &&
<Icon type="loading"/>
}
{ blob.error &&
<Icon type="frown-circle" />
}
</h1>
}
</Col>
Expand Down
1 change: 0 additions & 1 deletion src/containers/Dir.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Dir extends Component {
dispatch(actions.readRepoTree(repo));
});
} else {
console.log('here');
const repo = {
username: this.props.user.data.login,
reponame: this.props.repoInfo.data.name,
Expand Down
19 changes: 15 additions & 4 deletions src/containers/Post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ class Post extends Component {
}

handleRemoveReques() {
const { dispatch, user, params, repoInfo, history } = this.props;
const { dispatch, user, params, repoInfo, history, blob } = this.props;
let backDir
if (blob.loaded) {
backDir = params.splat.split(blob.data.name)[0];
backDir = backDir !== '' ? 'd/' + backDir : '';
}

const repo = {
username: user.data.login,
reponame: repoInfo.data.name,
Expand All @@ -163,7 +169,7 @@ class Post extends Component {
//message.success('删除成功');
})
.then(() => {
history.pushState(null, '_posts/');
history.pushState(null, '_posts/' + backDir);
});
}

Expand All @@ -180,7 +186,7 @@ class Post extends Component {
this.handleSaveMeta(data.meta);
}

handleEditMetaCancle() {
handleEditMetaCancel() {
this.setState({
editMeta: false,
});
Expand Down Expand Up @@ -218,6 +224,11 @@ class Post extends Component {
head: defaultValue.head,
body: defaultValue.body,
});
} else {
if (blob.error) {
const msg = blob.error.request && blob.error.request.message;
message.error(msg || 'Something error');
}
}
}

Expand Down Expand Up @@ -245,7 +256,7 @@ class Post extends Component {
metaData={this.state.head}
modalVisible={this.state.editMeta}
modalHandleOk={this.handleEditMetaSubmit.bind(this)}
modalHandleCancel={this.handleEditMetaCancle.bind(this)}
modalHandleCancel={this.handleEditMetaCancel.bind(this)}
/>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/styles/leaf.less
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
a {
line-height: 32px;
padding: 0 32px;
color: #666;
color: #444;
display: block;

.anticon {
Expand All @@ -354,6 +354,7 @@

&:hover {
color: #444;
background: #f7f8f9;
}
}
}
Expand Down Expand Up @@ -481,14 +482,13 @@
text-align: center;
min-height: 42px;
max-height: 63px;

overflow: hidden;
}
}

&:hover {
background: #fff;
border: 1px solid @border-color;
border: 1px solid darken(@border-color, 2%);
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
}
}
Expand Down

0 comments on commit de6c006

Please sign in to comment.