Loading indicator for document saving
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
.loader {
|
.loader {
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 2px;
|
height: 2px;
|
||||||
background-color: #03A9F4;
|
background-color: #03A9F4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
z-index: 9999;
|
||||||
|
|
||||||
background-color: #03A9F4;
|
background-color: #03A9F4;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
animation: loading 4s ease-in-out infinite;
|
animation: loading 4s ease-in-out infinite;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const initialState = {
|
|||||||
data: null,
|
data: null,
|
||||||
error: null,
|
error: null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const doc = (state = initialState, action) => {
|
const doc = (state = initialState, action) => {
|
||||||
@@ -44,20 +45,20 @@ const doc = (state = initialState, action) => {
|
|||||||
case SAVE_DOCUMENT_PENDING: {
|
case SAVE_DOCUMENT_PENDING: {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isLoading: true,
|
isSaving: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case SAVE_DOCUMENT_SUCCESS: {
|
case SAVE_DOCUMENT_SUCCESS: {
|
||||||
return {
|
return {
|
||||||
data: action.date,
|
data: action.date,
|
||||||
isLoading: false,
|
isSaving: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case SAVE_DOCUMENT_FAILURE: {
|
case SAVE_DOCUMENT_FAILURE: {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
error: action.error,
|
error: action.error,
|
||||||
isLoading: false,
|
isSaving: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class DocumentEdit extends Component {
|
|||||||
saveDocumentAsync: React.PropTypes.func.isRequired,
|
saveDocumentAsync: React.PropTypes.func.isRequired,
|
||||||
text: React.PropTypes.string,
|
text: React.PropTypes.string,
|
||||||
title: React.PropTypes.string,
|
title: React.PropTypes.string,
|
||||||
|
isSaving: React.PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@@ -88,6 +89,7 @@ class DocumentEdit extends Component {
|
|||||||
)}
|
)}
|
||||||
title={ title }
|
title={ title }
|
||||||
fixed={ true }
|
fixed={ true }
|
||||||
|
loading={ this.props.isSaving }
|
||||||
>
|
>
|
||||||
{ (this.props.isLoading && !this.props.document) ? (
|
{ (this.props.isLoading && !this.props.document) ? (
|
||||||
<CenteredContent>
|
<CenteredContent>
|
||||||
@@ -111,6 +113,7 @@ const mapStateToProps = (state) => {
|
|||||||
text: state.editor.text,
|
text: state.editor.text,
|
||||||
title: state.editor.title,
|
title: state.editor.title,
|
||||||
isLoading: state.document.isLoading,
|
isLoading: state.document.isLoading,
|
||||||
|
isSaving: state.document.isSaving,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ class Editor extends Component {
|
|||||||
)}
|
)}
|
||||||
title={ title }
|
title={ title }
|
||||||
fixed={ true }
|
fixed={ true }
|
||||||
|
loading={ this.props.isSaving }
|
||||||
>
|
>
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
onChange={ this.props.updateText }
|
onChange={ this.props.updateText }
|
||||||
@@ -84,7 +85,7 @@ const mapStateToProps = (state) => {
|
|||||||
return {
|
return {
|
||||||
text: state.editor.text,
|
text: state.editor.text,
|
||||||
title: state.editor.title,
|
title: state.editor.title,
|
||||||
isSaving: state.document.isLoading,
|
isSaving: state.document.isSaving,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user