var BS, BackButton, History, Link, React, TransitionActions, TransitionStore, _, ref, ref1;
React = require('react');
BS = require('react-bootstrap');
_ = require('underscore');
ref = require('react-router'), History = ref.History, Link = ref.Link;
ref1 = require('../../flux/transition'), TransitionActions = ref1.TransitionActions, TransitionStore = ref1.TransitionStore;
BackButton = React.createClass({
displayName: 'BackButton',
propTypes: {
bsStyle: React.PropTypes.string,
fallbackLink: React.PropTypes.shape({
to: React.PropTypes.string,
params: React.PropTypes.object,
text: React.PropTypes.string
}).isRequired
},
getDefaultProps: function() {
return {
bsStyle: 'default'
};
},
contextTypes: {
router: React.PropTypes.func
},
render: function() {
var backText, className, fallbackLink, historyInfo, href, ref2, text;
historyInfo = TransitionStore.getPrevious(this.context.router);
ref2 = this.props, fallbackLink = ref2.fallbackLink, className = ref2.className;
text = fallbackLink.text;
backText = historyInfo.name ? "Back to " + historyInfo.name : fallbackLink.text;
href = historyInfo.path || this.context.router.makeHref(this.props.fallbackLink.to, this.props.fallbackLink.params);
return React.createElement(Link, {
"className": "btn btn-" + this.props.bsStyle,
"to": href
}, backText);
}
});
module.exports = BackButton;
|