Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/476 show progress indicator #527

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/react/containers/EditorContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class EditorContainer extends Component {
}

publish() {
const { updateEntry, entry, entryEditClose, createEntry, isEditing } = this.props;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing entryEditClose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit explains it: 0ef8038

This function was used to close the editor immediately after clicking 'Publish Update'. When a user on a slower network/server clicked this, the editor disappeared instantly, however it would take several seconds for the entries text to actually update - there was no visual feedback that their action was processing.

By not using this function the editor does not instantly get removed. Not being removed right away allows the editor component to check if the store > user > entries entry has a true isPublishing state, adding necessary indicators of progress.

The editor is already set to close by changing the isEditing state to false, on the UPDATE_ENTRY_SUCCESS Redux action in the user.js reducer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes @sboisvert, I see the problem now, I had that in the wrong commit. My mistake.

const { updateEntry, entry, createEntry, isEditing } = this.props;
const { editorState, authors } = this.state;
const content = this.getContent();
const authorIds = authors.map(author => author.id);
Expand Down Expand Up @@ -224,7 +224,20 @@ class EditorContainer extends Component {
readOnly,
} = this.state;

const { isEditing, config } = this.props;
const { isEditing, config, api, user, entry } = this.props;

const isPublishingUpdate = (
entry && user.entries[entry.id] && user.entries[entry.id].isPublishing
);
const isPublishingNew = (!isEditing && api.isPublishingNew);
const isPublishing = (isPublishingNew || isPublishingUpdate);

let publishBtnText;
if (isPublishing) {
publishBtnText = 'Publishing...';
} else {
publishBtnText = isEditing ? 'Publish Update' : 'Publish New Entry';
}

return (
<div className="liveblog-editor-container">
Expand Down Expand Up @@ -296,21 +309,23 @@ class EditorContainer extends Component {
clearable={false}
cache={false}
/>
<button className="liveblog-btn liveblog-publish-btn" onClick={this.publish.bind(this)}>
{isEditing ? 'Publish Update' : 'Publish New Entry'}
<button className={`liveblog-btn liveblog-publish-btn ${isPublishing ? 'liveblog-publish-btn--active' : ''}`} onClick={this.publish.bind(this)}>
{ publishBtnText }
</button>
</div>
);
}
}

EditorContainer.propTypes = {
api: PropTypes.object,
config: PropTypes.object,
updateEntry: PropTypes.func,
entry: PropTypes.object,
entryEditClose: PropTypes.func,
createEntry: PropTypes.func,
isEditing: PropTypes.bool,
isPublishing: PropTypes.bool,
authors: PropTypes.array,
getAuthors: PropTypes.func,
};
Expand Down
13 changes: 13 additions & 0 deletions src/styles/core/editor/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@
font-size: .9rem;
}

.liveblog-publish-btn--active {
&, &:hover {
animation: liveblog-publish-btn--active-animation 2.5s infinite linear;
background-size: 100px 100%;
background-image: linear-gradient(-45deg,darken($color-primary, 5%) 28%,$color-primary 0,$color-primary 72%,darken($color-primary, 5%) 0);
}
}
@keyframes liveblog-publish-btn--active-animation {
0% {
background-position: 200px 0;
}
}

.liveblog-cancel-btn {
background: $color-grey-light;
color: $color-grey-dark;
Expand Down