Merge branch 'master' of https://github.com/processing/p5.js-web-editor
This commit is contained in:
commit
0095e96c62
6 changed files with 35 additions and 9 deletions
|
@ -65,6 +65,9 @@ export class FileNode extends React.Component {
|
||||||
|
|
||||||
toggleFileOptions(e) {
|
toggleFileOptions(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
if (!this.props.canEdit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.state.isOptionsOpen) {
|
if (this.state.isOptionsOpen) {
|
||||||
this.setState({ isOptionsOpen: false });
|
this.setState({ isOptionsOpen: false });
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +91,7 @@ export class FileNode extends React.Component {
|
||||||
renderChild(childId) {
|
renderChild(childId) {
|
||||||
return (
|
return (
|
||||||
<li key={childId}>
|
<li key={childId}>
|
||||||
<ConnectedFileNode id={childId} parentId={this.props.id} />
|
<ConnectedFileNode id={childId} parentId={this.props.id} canEdit={this.props.canEdit} />
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +253,8 @@ FileNode.propTypes = {
|
||||||
newFile: PropTypes.func.isRequired,
|
newFile: PropTypes.func.isRequired,
|
||||||
newFolder: PropTypes.func.isRequired,
|
newFolder: PropTypes.func.isRequired,
|
||||||
showFolderChildren: PropTypes.func.isRequired,
|
showFolderChildren: PropTypes.func.isRequired,
|
||||||
hideFolderChildren: PropTypes.func.isRequired
|
hideFolderChildren: PropTypes.func.isRequired,
|
||||||
|
canEdit: PropTypes.bool.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
FileNode.defaultProps = {
|
FileNode.defaultProps = {
|
||||||
|
@ -261,8 +265,7 @@ FileNode.defaultProps = {
|
||||||
|
|
||||||
function mapStateToProps(state, ownProps) {
|
function mapStateToProps(state, ownProps) {
|
||||||
// this is a hack, state is updated before ownProps
|
// this is a hack, state is updated before ownProps
|
||||||
return state.files.find(file => file.id === ownProps.id) || { ...ownProps, name: 'test', fileType: 'file' };
|
return state.files.find(file => file.id === ownProps.id) || { name: 'test', fileType: 'file' };
|
||||||
// return state.files.find(file => file.id === ownProps.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps(dispatch) {
|
function mapDispatchToProps(dispatch) {
|
||||||
|
|
|
@ -8,6 +8,10 @@ class NewFileForm extends React.Component {
|
||||||
this.createFile = this.props.createFile.bind(this);
|
this.createFile = this.props.createFile.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.fileName.focus();
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fields: { name }, handleSubmit } = this.props;
|
const { fields: { name }, handleSubmit } = this.props;
|
||||||
return (
|
return (
|
||||||
|
@ -25,6 +29,7 @@ class NewFileForm extends React.Component {
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Name"
|
placeholder="Name"
|
||||||
{...domOnlyProps(name)}
|
{...domOnlyProps(name)}
|
||||||
|
ref={(element) => { this.fileName = element; }}
|
||||||
/>
|
/>
|
||||||
<input type="submit" value="Add File" aria-label="add file" />
|
<input type="submit" value="Add File" aria-label="add file" />
|
||||||
{name.touched && name.error && <span className="form-error">{name.error}</span>}
|
{name.touched && name.error && <span className="form-error">{name.error}</span>}
|
||||||
|
|
|
@ -41,11 +41,12 @@ class Sidebar extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const canEditProject = this.userCanEditProject();
|
||||||
const sidebarClass = classNames({
|
const sidebarClass = classNames({
|
||||||
'sidebar': true,
|
'sidebar': true,
|
||||||
'sidebar--contracted': !this.props.isExpanded,
|
'sidebar--contracted': !this.props.isExpanded,
|
||||||
'sidebar--project-options': this.props.projectOptionsVisible,
|
'sidebar--project-options': this.props.projectOptionsVisible,
|
||||||
'sidebar--cant-edit': !this.userCanEditProject()
|
'sidebar--cant-edit': !canEditProject
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -82,7 +83,10 @@ class Sidebar extends React.Component {
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ConnectedFileNode id={this.props.files.filter(file => file.name === 'root')[0].id} />
|
<ConnectedFileNode
|
||||||
|
id={this.props.files.filter(file => file.name === 'root')[0].id}
|
||||||
|
canEdit={canEditProject}
|
||||||
|
/>
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
.sidebar__root-item {
|
.sidebar__root-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow-y: scroll;
|
overflow-y: auto;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,6 @@
|
||||||
@include icon();
|
@include icon();
|
||||||
@include themify() {
|
@include themify() {
|
||||||
padding: #{4 / $base-font-size}rem 0;
|
padding: #{4 / $base-font-size}rem 0;
|
||||||
background-color: map-get($theme-map, 'file-selected-color');
|
|
||||||
padding-right: #{6 / $base-font-size}rem;
|
padding-right: #{6 / $base-font-size}rem;
|
||||||
}
|
}
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -137,9 +136,18 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.sidebar__file-item:hover > .file-item__content & {
|
||||||
|
display: inline-block;
|
||||||
|
.sidebar--cant-edit & {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
& svg {
|
& svg {
|
||||||
width: #{10 / $base-font-size}rem;
|
width: #{10 / $base-font-size}rem;
|
||||||
}
|
}
|
||||||
|
.sidebar__file-item--open > .file-item__content & {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar__file-item-options {
|
.sidebar__file-item-options {
|
||||||
|
|
|
@ -64,6 +64,11 @@ export function validateSignup(formProps) {
|
||||||
if (!formProps.password) {
|
if (!formProps.password) {
|
||||||
errors.password = 'Please enter a password';
|
errors.password = 'Please enter a password';
|
||||||
}
|
}
|
||||||
|
if (formProps.password) {
|
||||||
|
if (formProps.password.length < 6) {
|
||||||
|
errors.password = 'Password must be at least 6 characters';
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!formProps.confirmPassword) {
|
if (!formProps.confirmPassword) {
|
||||||
errors.confirmPassword = 'Please enter a password confirmation';
|
errors.confirmPassword = 'Please enter a password confirmation';
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,8 @@ module.exports = [{
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
compress: {
|
compress: {
|
||||||
warnings: false
|
warnings: false,
|
||||||
|
drop_console :true
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
new webpack.LoaderOptionsPlugin({
|
new webpack.LoaderOptionsPlugin({
|
||||||
|
|
Loading…
Reference in a new issue