fixes #5, turns autosave off when a user logs off, hide timer component when user is not owner of sketch
This commit is contained in:
parent
311e8442a1
commit
286a5dd6c6
4 changed files with 16 additions and 4 deletions
|
@ -223,6 +223,7 @@ class Editor extends React.Component {
|
|||
</span>
|
||||
<Timer
|
||||
projectSavedTime={this.props.projectSavedTime}
|
||||
isUserOwner={this.props.isUserOwner}
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
|
@ -287,7 +288,8 @@ Editor.propTypes = {
|
|||
files: PropTypes.array.isRequired,
|
||||
isExpanded: PropTypes.bool.isRequired,
|
||||
collapseSidebar: PropTypes.func.isRequired,
|
||||
expandSidebar: PropTypes.func.isRequired
|
||||
expandSidebar: PropTypes.func.isRequired,
|
||||
isUserOwner: PropTypes.bool
|
||||
};
|
||||
|
||||
export default Editor;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import React, { PropTypes } from 'react';
|
||||
import moment from 'moment';
|
||||
import classNames from 'classnames';
|
||||
|
||||
class Timer extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -31,8 +32,12 @@ class Timer extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const timerClass = classNames({
|
||||
'timer__saved-time': true,
|
||||
'timer__saved-time--notOwner': !this.props.isUserOwner
|
||||
});
|
||||
return (
|
||||
<span className="timer__saved-time">
|
||||
<span className={timerClass}>
|
||||
{this.props.projectSavedTime !== '' ? this.showSavedTime() : null}
|
||||
</span>
|
||||
);
|
||||
|
@ -40,7 +45,8 @@ class Timer extends React.Component {
|
|||
}
|
||||
|
||||
Timer.propTypes = {
|
||||
projectSavedTime: PropTypes.string.isRequired
|
||||
projectSavedTime: PropTypes.string.isRequired,
|
||||
isUserOwner: PropTypes.bool
|
||||
};
|
||||
|
||||
export default Timer;
|
|
@ -110,7 +110,7 @@ class IDEView extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.autosaveInterval && !this.props.project.id) {
|
||||
if (this.autosaveInterval && (!this.props.project.id || !this.isUserOwner())) {
|
||||
clearInterval(this.autosaveInterval);
|
||||
this.autosaveInterval = null;
|
||||
}
|
||||
|
@ -322,6 +322,7 @@ class IDEView extends React.Component {
|
|||
isExpanded={this.props.ide.sidebarIsExpanded}
|
||||
expandSidebar={this.props.expandSidebar}
|
||||
collapseSidebar={this.props.collapseSidebar}
|
||||
isUserOwner={this.isUserOwner()}
|
||||
/>
|
||||
<Console
|
||||
consoleEvents={this.props.console}
|
||||
|
|
|
@ -4,4 +4,7 @@
|
|||
}
|
||||
font-size: #{12 / $base-font-size}rem;
|
||||
padding-right: #{30 / $base-font-size}rem;
|
||||
&.timer__saved-time--notOwner {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue