Skip to content

Commit 9105249

Browse files
LakshSinglacatarak
authored andcommitted
Add New File and New Folder buttons in Navbar (feature: #758) (#763)
* Add New File and New Folder buttons in Navbar (feature: #758) * Moved the Add File and Add Folder butons from File to Sketch (feature: #758)
1 parent 661a367 commit 9105249

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

client/components/Nav.jsx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3+
import { bindActionCreators } from 'redux';
4+
import { connect } from 'react-redux';
5+
import { withRouter } from 'react-router';
36
import { Link } from 'react-router';
47
import InlineSVG from 'react-inlinesvg';
58
import classNames from 'classnames';
9+
import * as IDEActions from '../modules/IDE/actions/ide';
610

711
import {
812
metaKeyName,
@@ -315,6 +319,30 @@ class Nav extends React.PureComponent {
315319
<span>Sketch</span>
316320
<InlineSVG src={triangleUrl} />
317321
</button>
322+
<li className="nav__dropdown-item">
323+
<button
324+
onClick={() => {
325+
this.props.newFile();
326+
this.setDropdown('none');
327+
}}
328+
onFocus={this.handleFocus.bind(this, 'sketch')}
329+
onBlur={this.handleBlur}
330+
>
331+
Add File
332+
</button>
333+
</li>
334+
<li className="nav__dropdown-item">
335+
<button
336+
onClick={() => {
337+
this.props.newFolder();
338+
this.setDropdown('none');
339+
}}
340+
onFocus={this.handleFocus.bind(this, 'sketch')}
341+
onBlur={this.handleBlur}
342+
>
343+
Add Folder
344+
</button>
345+
</li>
318346
<li className="nav__dropdown-item">
319347
<button
320348
onClick={() => {
@@ -558,7 +586,9 @@ Nav.propTypes = {
558586
}),
559587
startSketch: PropTypes.func.isRequired,
560588
stopSketch: PropTypes.func.isRequired,
561-
setAllAccessibleOutput: PropTypes.func.isRequired
589+
setAllAccessibleOutput: PropTypes.func.isRequired,
590+
newFile: PropTypes.func.isRequired,
591+
newFolder: PropTypes.func.isRequired
562592
};
563593

564594
Nav.defaultProps = {
@@ -569,4 +599,14 @@ Nav.defaultProps = {
569599
cmController: {}
570600
};
571601

572-
export default Nav;
602+
function mapDispatchToProps(dispatch) {
603+
return bindActionCreators(
604+
Object.assign(
605+
{},
606+
IDEActions
607+
),
608+
dispatch
609+
);
610+
}
611+
612+
export default withRouter(connect(() => ({}), mapDispatchToProps)(Nav));

0 commit comments

Comments
 (0)