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:
Cassie Tarakajian 2017-01-13 11:55:13 -05:00
parent 311e8442a1
commit 286a5dd6c6
4 changed files with 16 additions and 4 deletions

View file

@ -223,6 +223,7 @@ class Editor extends React.Component {
</span> </span>
<Timer <Timer
projectSavedTime={this.props.projectSavedTime} projectSavedTime={this.props.projectSavedTime}
isUserOwner={this.props.isUserOwner}
/> />
</div> </div>
<button <button
@ -287,7 +288,8 @@ Editor.propTypes = {
files: PropTypes.array.isRequired, files: PropTypes.array.isRequired,
isExpanded: PropTypes.bool.isRequired, isExpanded: PropTypes.bool.isRequired,
collapseSidebar: PropTypes.func.isRequired, collapseSidebar: PropTypes.func.isRequired,
expandSidebar: PropTypes.func.isRequired expandSidebar: PropTypes.func.isRequired,
isUserOwner: PropTypes.bool
}; };
export default Editor; export default Editor;

View file

@ -1,5 +1,6 @@
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
import moment from 'moment'; import moment from 'moment';
import classNames from 'classnames';
class Timer extends React.Component { class Timer extends React.Component {
constructor(props) { constructor(props) {
@ -31,8 +32,12 @@ class Timer extends React.Component {
} }
render() { render() {
const timerClass = classNames({
'timer__saved-time': true,
'timer__saved-time--notOwner': !this.props.isUserOwner
});
return ( return (
<span className="timer__saved-time"> <span className={timerClass}>
{this.props.projectSavedTime !== '' ? this.showSavedTime() : null} {this.props.projectSavedTime !== '' ? this.showSavedTime() : null}
</span> </span>
); );
@ -40,7 +45,8 @@ class Timer extends React.Component {
} }
Timer.propTypes = { Timer.propTypes = {
projectSavedTime: PropTypes.string.isRequired projectSavedTime: PropTypes.string.isRequired,
isUserOwner: PropTypes.bool
}; };
export default Timer; export default Timer;

View file

@ -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); clearInterval(this.autosaveInterval);
this.autosaveInterval = null; this.autosaveInterval = null;
} }
@ -322,6 +322,7 @@ class IDEView extends React.Component {
isExpanded={this.props.ide.sidebarIsExpanded} isExpanded={this.props.ide.sidebarIsExpanded}
expandSidebar={this.props.expandSidebar} expandSidebar={this.props.expandSidebar}
collapseSidebar={this.props.collapseSidebar} collapseSidebar={this.props.collapseSidebar}
isUserOwner={this.isUserOwner()}
/> />
<Console <Console
consoleEvents={this.props.console} consoleEvents={this.props.console}

View file

@ -4,4 +4,7 @@
} }
font-size: #{12 / $base-font-size}rem; font-size: #{12 / $base-font-size}rem;
padding-right: #{30 / $base-font-size}rem; padding-right: #{30 / $base-font-size}rem;
&.timer__saved-time--notOwner {
display: none;
}
} }