Skip to content

Commit

Permalink
Dashboards: PfAggregateStatusCard: fix prop types and handle empty ar…
Browse files Browse the repository at this point in the history
…ray.
  • Loading branch information
martinpovolny committed Sep 30, 2019
1 parent 01ebb0d commit 94450e8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/javascript/components/pf_aggregate_status_card.jsx
Expand Up @@ -12,6 +12,8 @@ const PfAggregateStatusCard = ({
${isAltLayout() ? ' card-pf-aggregate-status-alt' : ''}
${shouldShowTopBorder() ? ' card-pf-accented' : ''}`;

const notifications = data.notifications || [];

const renderNormalLayout = () => (
<div className={normalLayoutClass}>
<h2 className="card-pf-title">
Expand All @@ -28,7 +30,7 @@ const PfAggregateStatusCard = ({
</h2>
<div className="card-pf-body">
<p className="card-pf-aggregate-status-notifications">
{ data.notifications.map(notification => (
{ notifications.map(notification => (
<span key={notification} className="card-pf-aggregate-status-notification">
<a href={notification.href}>
{ notification.iconImage && (
Expand Down Expand Up @@ -93,14 +95,25 @@ const PfAggregateStatusCard = ({
PfAggregateStatusCard.propTypes = {
layout: PropTypes.string,
className: PropTypes.string,
data: PropTypes.arrayOf(PropTypes.any).isRequired,
data: PropTypes.shape({
iconImage: PropTypes.string,
iconClass: PropTypes.string,
largeIcon: PropTypes.bool,
notifications: PropTypes.arrayOf(PropTypes.any),
notification: PropTypes.shape({
iconImage: PropTypes.string,
iconClass: PropTypes.string,
count: PropTypes.number,
}),
}).isRequired,
showTopBorder: PropTypes.bool.isRequired,
altLayout: PropTypes.bool,
};

PfAggregateStatusCard.defaultProps = {
layout: null,
className: null, // bylo to tam?
data: {},
altLayout: false,
showTopBorder: false, // urcite?
};
Expand Down

0 comments on commit 94450e8

Please sign in to comment.