Skip to content

Commit

Permalink
fix critical alert bug and remove unread heading
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaianirh committed Jan 23, 2020
1 parent af65aab commit 19a36b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const NotificationDrawerHeading: React.FC<NotificationDrawerHeadingProps> = ({
<div className="pf-c-notification-drawer">
<div className="pf-c-notification-drawer__header">
<h1 className="pf-c-notification-drawer__header-title">Notifications</h1>
<span className="pf-c-notification-drawer__header-status">{`${count} unread`}</span>
{count && (
<span className="pf-c-notification-drawer__header-status">{`${count} unread`}</span>
)}
</div>
<div className="pf-c-notification-drawer__body">
<div className="pf-c-notification-drawer__group-list">{children}</div>
Expand All @@ -17,7 +19,7 @@ const NotificationDrawerHeading: React.FC<NotificationDrawerHeadingProps> = ({

type NotificationDrawerHeadingProps = {
children: React.ReactNode;
count: number;
count?: number;
};

export default NotificationDrawerHeading;
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ const NotificationDrawer: React.FC<NotificationDrawerProps> = ({
isInline,
children,
notificationEntries,
count = 0,
}) => {
return (
<Drawer isExpanded={isExpanded} isInline={isInline}>
<DrawerContent>{children}</DrawerContent>
<DrawerPanelContent noPadding>
<NotificationDrawerHeading count={count}>{notificationEntries}</NotificationDrawerHeading>
<NotificationDrawerHeading>{notificationEntries}</NotificationDrawerHeading>
</DrawerPanelContent>
</Drawer>
);
Expand Down
8 changes: 6 additions & 2 deletions frontend/public/components/notification-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ export const ConnectedNotificationDrawer_: React.FC<ConnectedNotificationDrawerP
);
const criticalAlertList: React.ReactNode[] = getAlertNotificationEntries(
true,
loaded,
data,
toggleNotificationDrawer,
true,
);
const otherAlertList: React.ReactNode[] = getAlertNotificationEntries(
loaded,
Expand All @@ -160,6 +160,11 @@ export const ConnectedNotificationDrawer_: React.FC<ConnectedNotificationDrawerP
false,
);
const [isClusterUpdateExpanded, toggleClusterUpdateExpanded] = React.useState<boolean>(false);
React.useEffect(() => {
if (criticalAlertList.length > 0 && !isDrawerExpanded) {
toggleAlertExpanded(!_.isEmpty(criticalAlertList));
}
}, [criticalAlertList, isAlertExpanded, isDrawerExpanded]);

const criticalAlertCategory: React.ReactElement = (
<NotificationCategory
Expand Down Expand Up @@ -207,7 +212,6 @@ export const ConnectedNotificationDrawer_: React.FC<ConnectedNotificationDrawerP
isInline={isDesktop}
isExpanded={isDrawerExpanded}
notificationEntries={[criticalAlertCategory, nonCriticalAlertCategory, messageCategory]}
count={criticalAlertList.length + otherAlertList.length}
>
{children}
</NotificationDrawer>
Expand Down

0 comments on commit 19a36b7

Please sign in to comment.