/*
* A copoment for the request log table
*/
import React, { PropTypes } from 'react';
import { formatDate } from 'common/commonUtil';
import Style from './record-row.less';
import CommonStyle from '../style/common.less';
import ClassBind from 'classnames/bind';
const StyleBind = ClassBind.bind(Style);
class RecordRow extends React.Component {
constructor() {
super();
this.state = {
};
}
static propTypes = {
data: PropTypes.object,
detailHanlder: PropTypes.func,
className: PropTypes.string
}
getMethodDiv(item) {
const httpsIcon =
;
return {item.method}
{item.protocol === 'https' ? httpsIcon : null}
;
}
getCodeDiv(item) {
const statusCode = parseInt(item.statusCode, 10);
const className = StyleBind({ okStatus: statusCode === 200, errorStatus: statusCode >= 400 });
return {item.statusCode};
}
shouldComponentUpdate(nextProps) {
if (nextProps.data._render) {
nextProps.data._render = false;
return true;
} else {
return false;
}
}
render() {
const data = this.props.data;
if (!data) {
return null;
}
return (
{data.id} |
{this.getMethodDiv(data)} |
{this.getCodeDiv(data)} |
{data.host} |
{data.path} |
{data.mime} |
{formatDate(data.startTime, 'hh:mm:ss')} |
);
}
}
export default RecordRow;