Debian Codegraph @

node/@patternfly/react-core/src/demos/NotificationDrawer/examples/NotificationDrawerGrouped.tsx

raw
1 import { Fragment, useRef, useState } from 'react';
2 import {
3 Avatar,
4 Brand,
5 Breadcrumb,
6 BreadcrumbItem,
7 Button,
8 ButtonVariant,
9 Content,
10 Divider,
11 Dropdown,
12 DropdownItem,
13 DropdownList,
14 EmptyState,
15 EmptyStateActions,
16 EmptyStateBody,
17 EmptyStateFooter,
18 EmptyStateVariant,
19 MenuToggle,
20 Nav,
21 NavItem,
22 NavList,
23 NotificationBadge,
24 NotificationDrawer,
25 NotificationDrawerBody,
26 NotificationDrawerGroup,
27 NotificationDrawerGroupList,
28 NotificationDrawerHeader,
29 NotificationDrawerList,
30 NotificationDrawerListItem,
31 NotificationDrawerListItemBody,
32 NotificationDrawerListItemHeader,
33 Page,
34 PageSection,
35 PageSidebar,
36 PageSidebarBody,
37 SkipToContent,
38 PageToggleButton,
39 Masthead,
40 MastheadMain,
41 MastheadBrand,
42 MastheadToggle,
43 MastheadContent,
44 MastheadLogo,
45 Toolbar,
46 ToolbarItem,
47 ToolbarGroup,
48 ToolbarContent
49 } from '@patternfly/react-core';
50 import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon';
51 import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
52 import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
53 import RhUiQuestionMarkCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-question-mark-circle-fill-icon';
54 import RhUiEllipsisVerticalFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ellipsis-vertical-fill-icon';
55 import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
56 import pfLogo from '@patternfly/react-core/src/demos/assets/pf-logo.PF-HorizontalLogo-Color.svg';
57
58 export const NotificationDrawerGrouped: React.FunctionComponent = () => {
59 const drawerRef = useRef<HTMLElement | null>(null);
60
61 const [isDropdownOpen, setIsDropdownOpen] = useState(false);
62 const [isKebabDropdownOpen, setIsKebabDropdownOpen] = useState(false);
63 const [isDrawerExpanded, setIsDrawerExpanded] = useState(false);
64 const [firstDrawerGroupExpanded, setFirstDrawerGroupExpanded] = useState(false);
65 const [secondDrawerGroupExpanded, setSecondDrawerGroupExpanded] = useState(true);
66 const [thirdDrawerGroupExpanded, setThirdDrawerGroupExpanded] = useState(false);
67
68 interface UnreadMap {
69 [groupName: string]: {
70 [notificationId: string]: boolean;
71 } | null;
72 }
73
74 const [activeItem, setActiveItem] = useState<number | string>(0);
75 const [isUnreadMap, setIsUnreadMap] = useState<UnreadMap | null>({
76 'group-1': {
77 'notification-5': true,
78 'notification-6': true
79 },
80 'group-2': {
81 'notification-9': true,
82 'notification-10': true
83 },
84 'group-3': null
85 });
86
87 const [shouldShowNotifications, setShouldShowNotifications] = useState(true);
88
89 interface ActionsMenu {
90 [toggleId: string]: boolean;
91 }
92
93 const [isActionsMenuOpen, setIsActionsMenuOpen] = useState<ActionsMenu | {}>({});
94
95 const onNavSelect = (
96 _event: React.FormEvent<HTMLInputElement>,
97 selectedItem: {
98 groupId: number | string;
99 itemId: number | string;
100 to: string;
101 }
102 ) => setActiveItem(selectedItem.itemId);
103
104 const onDropdownToggle = () => setIsDropdownOpen((prevState) => !prevState);
105 const onDropdownSelect = () => setIsDropdownOpen(false);
106 const onKebabDropdownToggle = () => setIsKebabDropdownOpen((prevState) => !prevState);
107 const onKebabDropdownSelect = () => setIsKebabDropdownOpen(false);
108 const onCloseNotificationDrawer = (_event: any) => setIsDrawerExpanded((prevState) => !prevState);
109
110 const onToggle = (id: string) => {
111 setIsActionsMenuOpen({ [id]: !isActionsMenuOpen[id] });
112 };
113
114 const closeActionsMenu = () => setIsActionsMenuOpen({});
115
116 const onListItemClick = (groupId: string, id: string) => {
117 if (isUnreadMap === null) {
118 return;
119 }
120 if (!isUnreadMap[groupId]) {
121 setIsUnreadMap({ ...isUnreadMap, [groupId]: { [id]: false } });
122 } else {
123 setIsUnreadMap({ ...isUnreadMap, [groupId]: { ...isUnreadMap[groupId], [id]: false } });
124 }
125 };
126
127 const isUnread = (groupId: string, id: string) =>
128 isUnreadMap && isUnreadMap[groupId] !== null && isUnreadMap[groupId][id];
129
130 const getNumberUnread = (groupId: string | null) => {
131 if (!isUnreadMap) {
132 return 0;
133 }
134
135 if (groupId) {
136 const group = isUnreadMap[groupId];
137 if (!group) {
138 return 0;
139 }
140 return Object.values(group).reduce((count, value) => (value ? count + 1 : count), 0);
141 }
142
143 return Object.keys(isUnreadMap).reduce((count, groupId) => {
144 const group = isUnreadMap[groupId];
145 if (!group) {
146 return count;
147 }
148
149 return Object.values(group).reduce((groupCount, value) => (value ? groupCount + 1 : groupCount), count);
150 }, 0);
151 };
152
153 const markAllRead = () => setIsUnreadMap(null);
154
155 const showNotifications = (showNotifications: boolean) => {
156 setIsUnreadMap(null);
157 setShouldShowNotifications(showNotifications);
158 };
159
160 const toggleFirstDrawer = (_event: any, value: boolean | ((prevState: boolean) => boolean)) => {
161 setFirstDrawerGroupExpanded(value);
162 };
163
164 const toggleSecondDrawer = (_event: any, value: boolean | ((prevState: boolean) => boolean)) => {
165 setSecondDrawerGroupExpanded(value);
166 };
167
168 const toggleThirdDrawer = (_event: any, value: boolean | ((prevState: boolean) => boolean)) => {
169 setThirdDrawerGroupExpanded(value);
170 };
171
172 const focusDrawer = (_event: any) => {
173 if (drawerRef.current === null) {
174 return;
175 }
176 // Prevent the NotificationDrawer from receiving focus if a drawer group item is opened
177 if (!document.activeElement?.closest(`.${drawerRef.current.className}`)) {
178 const firstTabbableItem = drawerRef.current.querySelector('a, button') as
179 | HTMLAnchorElement
180 | HTMLButtonElement
181 | null;
182 firstTabbableItem?.focus();
183 }
184 };
185
186 const PageNav = (
187 <Nav onSelect={onNavSelect} aria-label="Nav">
188 <NavList>
189 <NavItem itemId={0} isActive={activeItem === 0}>
190 System Panel
191 </NavItem>
192 <NavItem itemId={1} isActive={activeItem === 1}>
193 Policy
194 </NavItem>
195 <NavItem itemId={2} isActive={activeItem === 2}>
196 Authentication
197 </NavItem>
198 <NavItem itemId={3} isActive={activeItem === 3}>
199 Network Services
200 </NavItem>
201 <NavItem itemId={4} isActive={activeItem === 4}>
202 Server
203 </NavItem>
204 </NavList>
205 </Nav>
206 );
207 const kebabDropdownItems = (
208 <>
209 <DropdownItem>
210 <RhUiSettingsFillIcon /> Settings
211 </DropdownItem>
212 <DropdownItem>
213 <HelpIcon /> Help
214 </DropdownItem>
215 </>
216 );
217 const userDropdownItems = (
218 <>
219 <DropdownItem key="group 2 profile">My profile</DropdownItem>
220 <DropdownItem key="group 2 user">User management</DropdownItem>
221 <DropdownItem key="group 2 logout">Logout</DropdownItem>
222 </>
223 );
224 const headerToolbar = (
225 <Toolbar>
226 <ToolbarContent>
227 <ToolbarGroup align={{ default: 'alignEnd' }}>
228 <ToolbarGroup variant="action-group-plain">
229 <ToolbarItem visibility={{ default: 'visible' }} selected={isDrawerExpanded}>
230 <NotificationBadge
231 variant={getNumberUnread(null) === 0 ? 'read' : 'unread'}
232 onClick={(event: any) => onCloseNotificationDrawer(event)}
233 aria-label="Notifications"
234 isExpanded={isDrawerExpanded}
235 />
236 </ToolbarItem>
237 <ToolbarGroup
238 variant="action-group-plain"
239 visibility={{
240 default: 'hidden',
241 lg: 'visible'
242 }} /** the settings and help icon buttons are only visible on desktop sizes and replaced by a kebab dropdown for other sizes */
243 >
244 <ToolbarItem>
245 <Button aria-label="Settings actions" isSettings variant="plain" />
246 </ToolbarItem>
247 <ToolbarItem>
248 <Button
249 aria-label="Help actions"
250 variant={ButtonVariant.plain}
251 icon={<RhUiQuestionMarkCircleFillIcon />}
252 />
253 </ToolbarItem>
254 </ToolbarGroup>
255 </ToolbarGroup>
256 <ToolbarGroup>
257 <ToolbarItem
258 visibility={{
259 lg: 'hidden'
260 }} /** this kebab dropdown replaces the icon buttons and is hidden for desktop sizes */
261 >
262 <Dropdown
263 isOpen={isKebabDropdownOpen}
264 onSelect={onKebabDropdownSelect}
265 onOpenChange={setIsKebabDropdownOpen}
266 popperProps={{ position: 'right' }}
267 toggle={(toggleRef: React.RefObject<any>) => (
268 <MenuToggle
269 ref={toggleRef}
270 isExpanded={isKebabDropdownOpen}
271 onClick={onKebabDropdownToggle}
272 variant="plain"
273 aria-label="Settings and help"
274 icon={<RhUiEllipsisVerticalFillIcon />}
275 />
276 )}
277 >
278 <DropdownList>{kebabDropdownItems}</DropdownList>
279 </Dropdown>
280 </ToolbarItem>
281 <ToolbarItem
282 visibility={{ default: 'hidden', md: 'visible' }} /** this user dropdown is hidden on mobile sizes */
283 >
284 <Dropdown
285 isOpen={isDropdownOpen}
286 onSelect={onDropdownSelect}
287 onOpenChange={setIsDropdownOpen}
288 popperProps={{ position: 'right' }}
289 toggle={(toggleRef: React.RefObject<any>) => (
290 <MenuToggle
291 ref={toggleRef}
292 isExpanded={isDropdownOpen}
293 onClick={onDropdownToggle}
294 icon={<Avatar src={imgAvatar} alt="" size="sm" />}
295 >
296 John Smith
297 </MenuToggle>
298 )}
299 >
300 <DropdownList>{userDropdownItems}</DropdownList>
301 </Dropdown>
302 </ToolbarItem>
303 </ToolbarGroup>
304 </ToolbarGroup>
305 </ToolbarContent>
306 </Toolbar>
307 );
308
309 const masthead = (
310 <Masthead>
311 <MastheadMain>
312 <MastheadToggle>
313 <PageToggleButton isHamburgerButton aria-label="Global navigation" />
314 </MastheadToggle>
315 <MastheadBrand>
316 <MastheadLogo>
317 <Brand src={pfLogo} alt="PatternFly" heights={{ default: '36px' }} />
318 </MastheadLogo>
319 </MastheadBrand>
320 </MastheadMain>
321 <MastheadContent>{headerToolbar}</MastheadContent>
322 </Masthead>
323 );
324 const Sidebar = (
325 <PageSidebar>
326 <PageSidebarBody>{PageNav}</PageSidebarBody>
327 </PageSidebar>
328 );
329 const pageId = 'main-content-page-layout-default-nav';
330
331 const handleClick = (event) => {
332 event.preventDefault();
333
334 const mainContentElement = document.getElementById(pageId);
335 if (mainContentElement) {
336 mainContentElement.focus();
337 }
338 };
339
340 const PageSkipToContent = (
341 <SkipToContent onClick={handleClick} href={`#${pageId}`}>
342 Skip to content
343 </SkipToContent>
344 );
345
346 const PageBreadcrumb = (
347 <Breadcrumb>
348 <BreadcrumbItem>Section home</BreadcrumbItem>
349 <BreadcrumbItem to="#">Section title</BreadcrumbItem>
350 <BreadcrumbItem to="#">Section title</BreadcrumbItem>
351 <BreadcrumbItem to="#" isActive>
352 Section landing
353 </BreadcrumbItem>
354 </Breadcrumb>
355 );
356
357 const notificationDrawerActions = (
358 <>
359 <DropdownItem key="markAllRead" onClick={markAllRead}>
360 Mark all read
361 </DropdownItem>
362 <DropdownItem key="clearAll" onClick={() => showNotifications(false)}>
363 Clear all
364 </DropdownItem>
365 <DropdownItem key="unclearLast" onClick={() => showNotifications(true)}>
366 Unclear last
367 </DropdownItem>
368 <DropdownItem key="settings">Settings</DropdownItem>
369 </>
370 );
371 const notificationDrawerDropdownItems = (
372 <>
373 <DropdownItem
374 key="link"
375 to="#"
376 // Prevent default onClick behavior for demo purposes
377 onClick={(ev: any) => ev.preventDefault()}
378 >
379 Link
380 </DropdownItem>
381 <DropdownItem key="action">Action</DropdownItem>
382 <Divider component="li" key="separator" />
383 <DropdownItem key="disabled link" isDisabled>
384 Disabled Link
385 </DropdownItem>
386 </>
387 );
388
389 const notificationDrawer = (
390 <NotificationDrawer ref={drawerRef}>
391 <NotificationDrawerHeader count={getNumberUnread(null)} onClose={onCloseNotificationDrawer}>
392 <Dropdown
393 onSelect={closeActionsMenu}
394 isOpen={isActionsMenuOpen['toggle-id-0'] || false}
395 id="notification-0"
396 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
397 popperProps={{ position: 'right' }}
398 toggle={(toggleRef: React.RefObject<any>) => (
399 <MenuToggle
400 ref={toggleRef}
401 id="toggle-id-0"
402 aria-label="Notification drawer actions"
403 variant="plain"
404 onClick={() => onToggle('toggle-id-0')}
405 isExpanded={isActionsMenuOpen['toggle-id-0'] || false}
406 icon={<RhUiEllipsisVerticalFillIcon />}
407 />
408 )}
409 >
410 <DropdownList>{notificationDrawerActions}</DropdownList>
411 </Dropdown>
412 </NotificationDrawerHeader>
413 <NotificationDrawerBody>
414 {shouldShowNotifications && (
415 <NotificationDrawerGroupList>
416 <NotificationDrawerGroup
417 title="First notification group"
418 isExpanded={firstDrawerGroupExpanded}
419 count={getNumberUnread('group-1')}
420 onExpand={toggleFirstDrawer}
421 >
422 <NotificationDrawerList isHidden={!firstDrawerGroupExpanded}>
423 <NotificationDrawerListItem
424 variant="info"
425 onClick={() => onListItemClick('group-1', 'notification-5')}
426 isRead={!isUnread('group-1', 'notification-5')}
427 >
428 <NotificationDrawerListItemHeader
429 variant="info"
430 title="Unread info notification title"
431 srTitle="Info notification:"
432 >
433 <Dropdown
434 onSelect={closeActionsMenu}
435 isOpen={isActionsMenuOpen['toggle-id-5'] || false}
436 id="notification-5"
437 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
438 popperProps={{ position: 'right' }}
439 toggle={(toggleRef: React.RefObject<any>) => (
440 <MenuToggle
441 ref={toggleRef}
442 id="toggle-id-5"
443 aria-label="Notification drawer actions"
444 variant="plain"
445 onClick={() => onToggle('toggle-id-5')}
446 isExpanded={isActionsMenuOpen['toggle-id-5'] || false}
447 icon={<RhUiEllipsisVerticalFillIcon />}
448 />
449 )}
450 >
451 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
452 </Dropdown>
453 </NotificationDrawerListItemHeader>
454 <NotificationDrawerListItemBody timestamp="5 minutes ago">
455 This is an info notification description.
456 </NotificationDrawerListItemBody>
457 </NotificationDrawerListItem>
458 <NotificationDrawerListItem
459 variant="danger"
460 onClick={() => onListItemClick('group-1', 'notification-6')}
461 isRead={!isUnread('group-1', 'notification-6')}
462 >
463 <NotificationDrawerListItemHeader
464 variant="danger"
465 title="Unread danger notification title. This is a long title to show how the title will wrap if it is long and wraps to multiple lines."
466 srTitle="Danger notification:"
467 >
468 <Dropdown
469 onSelect={closeActionsMenu}
470 isOpen={isActionsMenuOpen['toggle-id-6'] || false}
471 id="notification-6"
472 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
473 popperProps={{ position: 'right' }}
474 toggle={(toggleRef: React.RefObject<any>) => (
475 <MenuToggle
476 ref={toggleRef}
477 id="toggle-id-6"
478 aria-label="Notification drawer actions"
479 variant="plain"
480 onClick={() => onToggle('toggle-id-6')}
481 isExpanded={isActionsMenuOpen['toggle-id-6'] || false}
482 icon={<RhUiEllipsisVerticalFillIcon />}
483 />
484 )}
485 >
486 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
487 </Dropdown>
488 </NotificationDrawerListItemHeader>
489 <NotificationDrawerListItemBody timestamp="10 minutes ago">
490 This is a danger notification description. This is a long description to show how the title will
491 wrap if it is long and wraps to multiple lines.
492 </NotificationDrawerListItemBody>
493 </NotificationDrawerListItem>
494 <NotificationDrawerListItem
495 variant="warning"
496 onClick={() => onListItemClick('group-1', 'notification-7')}
497 isRead={!isUnread('group-1', 'notification-7')}
498 >
499 <NotificationDrawerListItemHeader
500 variant="warning"
501 title="Read warning notification title"
502 srTitle="Warning notification:"
503 >
504 <Dropdown
505 onSelect={closeActionsMenu}
506 isOpen={isActionsMenuOpen['toggle-id-7'] || false}
507 id="notification-7"
508 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
509 popperProps={{ position: 'right' }}
510 toggle={(toggleRef: React.RefObject<any>) => (
511 <MenuToggle
512 ref={toggleRef}
513 id="toggle-id-7"
514 aria-label="Notification drawer actions"
515 variant="plain"
516 onClick={() => onToggle('toggle-id-7')}
517 isExpanded={isActionsMenuOpen['toggle-id-7'] || false}
518 icon={<RhUiEllipsisVerticalFillIcon />}
519 />
520 )}
521 >
522 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
523 </Dropdown>
524 </NotificationDrawerListItemHeader>
525 <NotificationDrawerListItemBody timestamp="20 minutes ago">
526 This is a warning notification description.
527 </NotificationDrawerListItemBody>
528 </NotificationDrawerListItem>
529 <NotificationDrawerListItem
530 variant="success"
531 onClick={() => onListItemClick('group-1', 'notification-8')}
532 isRead={!isUnread('group-1', 'notification-8')}
533 >
534 <NotificationDrawerListItemHeader
535 variant="success"
536 title="Read success notification title"
537 srTitle="Success notification:"
538 >
539 <Dropdown
540 onSelect={closeActionsMenu}
541 isOpen={isActionsMenuOpen['toggle-id-8'] || false}
542 id="notification-8"
543 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
544 popperProps={{ position: 'right' }}
545 toggle={(toggleRef: React.RefObject<any>) => (
546 <MenuToggle
547 ref={toggleRef}
548 id="toggle-id-8"
549 aria-label="Notification drawer actions"
550 variant="plain"
551 onClick={() => onToggle('toggle-id-8')}
552 isExpanded={isActionsMenuOpen['toggle-id-8'] || false}
553 icon={<RhUiEllipsisVerticalFillIcon />}
554 />
555 )}
556 >
557 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
558 </Dropdown>
559 </NotificationDrawerListItemHeader>
560 <NotificationDrawerListItemBody timestamp="30 minutes ago">
561 This is a success notification description.
562 </NotificationDrawerListItemBody>
563 </NotificationDrawerListItem>
564 </NotificationDrawerList>
565 </NotificationDrawerGroup>
566 <NotificationDrawerGroup
567 title="Second notification group"
568 isExpanded={secondDrawerGroupExpanded}
569 count={getNumberUnread('group-2')}
570 onExpand={toggleSecondDrawer}
571 >
572 <NotificationDrawerList isHidden={!secondDrawerGroupExpanded}>
573 <NotificationDrawerListItem
574 variant="info"
575 onClick={() => onListItemClick('group-2', 'notification-9')}
576 isRead={!isUnread('group-2', 'notification-9')}
577 >
578 <NotificationDrawerListItemHeader
579 variant="info"
580 title="Unread info notification title"
581 srTitle="Info notification:"
582 >
583 <Dropdown
584 onSelect={closeActionsMenu}
585 isOpen={isActionsMenuOpen['toggle-id-9'] || false}
586 id="notification-9"
587 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
588 popperProps={{ position: 'right' }}
589 toggle={(toggleRef: React.RefObject<any>) => (
590 <MenuToggle
591 ref={toggleRef}
592 id="toggle-id-9"
593 aria-label="Notification drawer actions"
594 variant="plain"
595 onClick={() => onToggle('toggle-id-9')}
596 isExpanded={isActionsMenuOpen['toggle-id-9'] || false}
597 icon={<RhUiEllipsisVerticalFillIcon />}
598 />
599 )}
600 >
601 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
602 </Dropdown>
603 </NotificationDrawerListItemHeader>
604 <NotificationDrawerListItemBody timestamp="5 minutes ago">
605 This is an info notification description.
606 </NotificationDrawerListItemBody>
607 </NotificationDrawerListItem>
608 <NotificationDrawerListItem
609 variant="danger"
610 onClick={() => onListItemClick('group-2', 'notification-10')}
611 isRead={!isUnread('group-2', 'notification-10')}
612 >
613 <NotificationDrawerListItemHeader
614 variant="danger"
615 title="Unread danger notification title. This is a long title to show how the title will wrap if it is long and wraps to multiple lines."
616 srTitle="Danger notification:"
617 >
618 <Dropdown
619 onSelect={closeActionsMenu}
620 isOpen={isActionsMenuOpen['toggle-id-10'] || false}
621 id="notification-10"
622 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
623 popperProps={{ position: 'right' }}
624 toggle={(toggleRef: React.RefObject<any>) => (
625 <MenuToggle
626 ref={toggleRef}
627 id="toggle-id-10"
628 aria-label="Notification drawer actions"
629 variant="plain"
630 onClick={() => onToggle('toggle-id-10')}
631 isExpanded={isActionsMenuOpen['toggle-id-10'] || false}
632 icon={<RhUiEllipsisVerticalFillIcon />}
633 />
634 )}
635 >
636 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
637 </Dropdown>
638 </NotificationDrawerListItemHeader>
639 <NotificationDrawerListItemBody timestamp="10 minutes ago">
640 This is a danger notification description. This is a long description to show how the title will
641 wrap if it is long and wraps to multiple lines.
642 </NotificationDrawerListItemBody>
643 </NotificationDrawerListItem>
644 <NotificationDrawerListItem
645 variant="warning"
646 onClick={() => onListItemClick('group-2', 'notification-11')}
647 isRead={!isUnread('group-2', 'notification-11')}
648 >
649 <NotificationDrawerListItemHeader
650 variant="warning"
651 title="Read warning notification title"
652 srTitle="Warning notification:"
653 >
654 <Dropdown
655 onSelect={closeActionsMenu}
656 isOpen={isActionsMenuOpen['toggle-id-11'] || false}
657 id="notification-11"
658 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
659 popperProps={{ position: 'right' }}
660 toggle={(toggleRef: React.RefObject<any>) => (
661 <MenuToggle
662 ref={toggleRef}
663 id="toggle-id-11"
664 aria-label="Notification drawer actions"
665 variant="plain"
666 onClick={() => onToggle('toggle-id-11')}
667 isExpanded={isActionsMenuOpen['toggle-id-11'] || false}
668 icon={<RhUiEllipsisVerticalFillIcon />}
669 />
670 )}
671 >
672 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
673 </Dropdown>
674 </NotificationDrawerListItemHeader>
675 <NotificationDrawerListItemBody timestamp="20 minutes ago">
676 This is a warning notification description.
677 </NotificationDrawerListItemBody>
678 </NotificationDrawerListItem>
679 <NotificationDrawerListItem
680 variant="success"
681 onClick={() => onListItemClick('group-2', 'notification-12')}
682 isRead={!isUnread('group-2', 'notification-12')}
683 >
684 <NotificationDrawerListItemHeader
685 variant="success"
686 title="Read success notification title"
687 srTitle="Success notification:"
688 >
689 <Dropdown
690 onSelect={closeActionsMenu}
691 isOpen={isActionsMenuOpen['toggle-id-12'] || false}
692 id="notification-12"
693 onOpenChange={(isOpen: boolean) => !isOpen && closeActionsMenu()}
694 popperProps={{ position: 'right' }}
695 toggle={(toggleRef: React.RefObject<any>) => (
696 <MenuToggle
697 ref={toggleRef}
698 id="toggle-id-12"
699 aria-label="Notification drawer actions"
700 variant="plain"
701 onClick={() => onToggle('toggle-id-12')}
702 isExpanded={isActionsMenuOpen['toggle-id-12'] || false}
703 icon={<RhUiEllipsisVerticalFillIcon />}
704 />
705 )}
706 >
707 <DropdownList>{notificationDrawerDropdownItems}</DropdownList>
708 </Dropdown>
709 </NotificationDrawerListItemHeader>
710 <NotificationDrawerListItemBody timestamp="30 minutes ago">
711 This is a success notification description.
712 </NotificationDrawerListItemBody>
713 </NotificationDrawerListItem>
714 </NotificationDrawerList>
715 </NotificationDrawerGroup>
716 <NotificationDrawerGroup
717 title="Third notification group"
718 isExpanded={thirdDrawerGroupExpanded}
719 count={getNumberUnread('group-3')}
720 onExpand={toggleThirdDrawer}
721 >
722 <NotificationDrawerList isHidden={!thirdDrawerGroupExpanded}>
723 <EmptyState
724 headingLevel="h2"
725 titleText="No alerts found"
726 icon={SearchIcon}
727 variant={EmptyStateVariant.full}
728 >
729 <EmptyStateBody>
730 There are currently no critical alerts firing. There may be firing alerts of other severities or
731 silenced critical alerts however.
732 </EmptyStateBody>
733 <EmptyStateFooter>
734 <EmptyStateActions>
735 <Button variant="link">Action</Button>
736 </EmptyStateActions>
737 </EmptyStateFooter>
738 </EmptyState>
739 </NotificationDrawerList>
740 </NotificationDrawerGroup>
741 </NotificationDrawerGroupList>
742 )}
743 {!shouldShowNotifications && (
744 <EmptyState headingLevel="h2" titleText="No alerts found" icon={SearchIcon} variant={EmptyStateVariant.full}>
745 <EmptyStateBody>
746 There are currently no alerts. There may be silenced critical alerts however.
747 </EmptyStateBody>
748 <EmptyStateFooter>
749 <EmptyStateActions>
750 <Button variant="link">Action</Button>
751 </EmptyStateActions>
752 </EmptyStateFooter>
753 </EmptyState>
754 )}
755 </NotificationDrawerBody>
756 </NotificationDrawer>
757 );
758
759 return (
760 <Fragment>
761 <Page
762 masthead={masthead}
763 sidebar={Sidebar}
764 isManagedSidebar
765 notificationDrawer={notificationDrawer}
766 isNotificationDrawerExpanded={isDrawerExpanded}
767 onNotificationDrawerExpand={(
768 event: React.MouseEvent<Element, MouseEvent> | KeyboardEvent | React.TransitionEvent<Element>
769 ) => focusDrawer(event)}
770 skipToContent={PageSkipToContent}
771 breadcrumb={PageBreadcrumb}
772 mainContainerId={pageId}
773 >
774 <PageSection aria-labelledby="main-title">
775 <Content>
776 <h1 id="main-title">Main title</h1>
777 <p>
778 Body text should be Red Hat Text at 1rem(16px). It should have leading of 1.5rem(24px) because <br />
779 of its relative line height of 1.5.
780 </p>
781 </Content>
782 </PageSection>
783 <PageSection aria-label="Panel section">Panel section content</PageSection>
784 </Page>
785 </Fragment>
786 );
787 };