2016-07-16 02:06:10 +00:00
|
|
|
import React, {Component, PropTypes} from 'react';
|
2016-04-03 22:54:39 +00:00
|
|
|
import {connect} from 'react-redux'
|
2016-07-16 02:06:10 +00:00
|
|
|
import Dropdown from '../components/base/Dropdown';
|
2016-07-21 21:55:03 +00:00
|
|
|
import DropdownHint from '../components/base/DropdownHint';
|
2016-08-15 17:04:36 +00:00
|
|
|
import GenerateCodeModal from '../components/modals/GenerateCodeModal';
|
2016-07-22 22:27:04 +00:00
|
|
|
import PromptModal from '../components/modals/PromptModal';
|
2016-07-16 02:06:10 +00:00
|
|
|
import * as db from '../database';
|
2016-08-15 17:04:36 +00:00
|
|
|
import {getModal} from '../components/modals/index';
|
2016-07-14 22:48:56 +00:00
|
|
|
|
2016-04-03 22:54:39 +00:00
|
|
|
|
|
|
|
class RequestActionsDropdown extends Component {
|
2016-07-14 22:48:56 +00:00
|
|
|
_promptUpdateName () {
|
|
|
|
const {request} = this.props;
|
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
getModal(PromptModal).show({
|
2016-07-14 22:48:56 +00:00
|
|
|
headerName: 'Rename Request',
|
2016-07-19 20:21:33 +00:00
|
|
|
defaultValue: request.name,
|
2016-07-25 22:27:29 +00:00
|
|
|
hint: 'also rename requests by double clicking in the sidebar'
|
2016-07-14 22:48:56 +00:00
|
|
|
}).then(name => {
|
|
|
|
db.requestUpdate(request, {name});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-04-03 22:54:39 +00:00
|
|
|
render () {
|
2016-07-14 22:48:56 +00:00
|
|
|
const {request, ...other} = this.props;
|
2016-04-03 22:54:39 +00:00
|
|
|
|
|
|
|
return (
|
2016-04-04 07:15:30 +00:00
|
|
|
<Dropdown {...other}>
|
2016-04-09 21:41:27 +00:00
|
|
|
<button>
|
2016-08-15 17:04:36 +00:00
|
|
|
<i className="fa fa-caret-down"></i>
|
2016-04-03 22:54:39 +00:00
|
|
|
</button>
|
2016-04-04 07:15:30 +00:00
|
|
|
<ul>
|
2016-04-05 05:35:21 +00:00
|
|
|
<li>
|
2016-08-17 21:05:14 +00:00
|
|
|
<button onClick={e => db.requestDuplicate(request)}>
|
2016-07-19 20:21:33 +00:00
|
|
|
<i className="fa fa-copy"></i> Duplicate
|
2016-07-21 21:55:03 +00:00
|
|
|
<DropdownHint char="D"></DropdownHint>
|
2016-04-05 05:35:21 +00:00
|
|
|
</button>
|
|
|
|
</li>
|
2016-04-08 04:05:08 +00:00
|
|
|
<li>
|
2016-07-14 22:48:56 +00:00
|
|
|
<button onClick={e => this._promptUpdateName()}>
|
2016-04-08 06:49:42 +00:00
|
|
|
<i className="fa fa-edit"></i> Rename
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
2016-08-15 17:04:36 +00:00
|
|
|
<button onClick={e => getModal(GenerateCodeModal).show(request)}>
|
|
|
|
<i className="fa fa-code"></i> Generate Code
|
2016-04-08 06:49:42 +00:00
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
2016-04-27 03:17:05 +00:00
|
|
|
<button onClick={e => db.requestRemove(request)}>
|
2016-04-08 06:49:42 +00:00
|
|
|
<i className="fa fa-trash-o"></i> Delete
|
2016-04-08 04:05:08 +00:00
|
|
|
</button>
|
|
|
|
</li>
|
2016-04-03 22:54:39 +00:00
|
|
|
</ul>
|
|
|
|
</Dropdown>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestActionsDropdown.propTypes = {
|
2016-07-14 22:48:56 +00:00
|
|
|
request: PropTypes.object.isRequired
|
2016-04-03 22:54:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
2016-07-14 22:48:56 +00:00
|
|
|
return {};
|
2016-04-03 22:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
2016-07-14 22:48:56 +00:00
|
|
|
return {}
|
2016-04-03 22:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(RequestActionsDropdown);
|