mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 10:41:14 +00:00
31 lines
861 B
JavaScript
31 lines
861 B
JavaScript
import React from 'react';
|
|
|
|
export default class ShowMore extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
super(props, context);
|
|
this.handleClick = this.handleClick.bind(this);
|
|
}
|
|
|
|
handleClick(ev) {
|
|
ev.preventDefault();
|
|
this.props.handleClick();
|
|
}
|
|
|
|
render() {
|
|
const { collection, notShown, expanded, hideNumber } = this.props;
|
|
const showLimitAction = collection && (expanded || notShown > 0);
|
|
const limitActionText = !hideNumber && !expanded && notShown > 0 ? `+${notShown}` : '';
|
|
const limitActionIcon = !expanded && notShown > 0 ? 'fa fa-caret-down' : 'fa fa-caret-up';
|
|
|
|
if (!showLimitAction) {
|
|
return <span/>;
|
|
}
|
|
return (
|
|
<div className="show-more" onClick={this.handleClick}>
|
|
{limitActionText} <span className={'show-more-icon ' + limitActionIcon}/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|