2015-08-06 13:56:37 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
2015-08-07 14:31:37 +02:00
|
|
|
import classnames from 'classnames';
|
2015-08-06 13:56:37 +02:00
|
|
|
|
|
|
|
let ActionPanel = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
title: React.PropTypes.string,
|
2015-08-10 11:57:38 +02:00
|
|
|
content: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.string,
|
|
|
|
React.PropTypes.element
|
|
|
|
]),
|
2015-08-06 13:56:37 +02:00
|
|
|
buttons: React.PropTypes.element,
|
|
|
|
onClick: React.PropTypes.func,
|
|
|
|
ignoreFocus: React.PropTypes.bool
|
|
|
|
},
|
|
|
|
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
isFocused: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
handleFocus() {
|
|
|
|
// if ignoreFocus (bool) is defined, then just ignore focusing on
|
|
|
|
// the property and input
|
|
|
|
if(this.props.ignoreFocus) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if onClick is defined from the outside,
|
|
|
|
// just call it
|
|
|
|
if(this.props.onClick) {
|
|
|
|
this.props.onClick();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.refs.input.getDOMNode().focus();
|
|
|
|
this.setState({
|
|
|
|
isFocused: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2015-08-07 14:31:37 +02:00
|
|
|
<div className={classnames('ascribe-panel-wrapper', {'is-focused': this.state.isFocused})}>
|
2015-08-10 09:22:39 +02:00
|
|
|
<div className="ascribe-panel-table">
|
|
|
|
<div className="ascribe-panel-content">
|
|
|
|
{this.props.content}
|
2015-08-07 11:27:44 +02:00
|
|
|
</div>
|
2015-08-10 09:22:39 +02:00
|
|
|
</div>
|
|
|
|
<div className="ascribe-panel-table">
|
|
|
|
<div className="ascribe-panel-content">
|
|
|
|
{this.props.buttons}
|
2015-08-07 11:27:44 +02:00
|
|
|
</div>
|
2015-08-06 13:56:37 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ActionPanel;
|