notification button

Reviewed By: elboman

Differential Revision: D47437749

fbshipit-source-id: 6dd7ded014e79b23328f59994e053d4d48c4eb65
This commit is contained in:
Anton Kastritskiy
2023-07-18 03:52:34 -07:00
committed by Facebook GitHub Bot
parent 9a5d421e0a
commit e431caf0f9
2 changed files with 27 additions and 30 deletions

View File

@@ -11,7 +11,6 @@ import React, {cloneElement, useState, useCallback} from 'react';
import {Button, Divider, Badge, Tooltip, Menu, Modal} from 'antd'; import {Button, Divider, Badge, Tooltip, Menu, Modal} from 'antd';
import { import {
MobileFilled, MobileFilled,
BellOutlined,
SettingOutlined, SettingOutlined,
BugOutlined, BugOutlined,
ApiOutlined, ApiOutlined,
@@ -31,8 +30,6 @@ import config from '../fb-stubs/config';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import {setStaticView} from '../reducers/connections'; import {setStaticView} from '../reducers/connections';
import {SandyRatingButton} from '../chrome/RatingButton'; import {SandyRatingButton} from '../chrome/RatingButton';
import {filterNotifications} from './notification/notificationUtils';
import {useMemoize} from 'flipper-plugin';
import UpdateIndicator from '../chrome/UpdateIndicator'; import UpdateIndicator from '../chrome/UpdateIndicator';
import constants from '../fb-stubs/constants'; import constants from '../fb-stubs/constants';
import { import {
@@ -148,10 +145,6 @@ export const LeftRail = withTrackingScope(function LeftRail({
setToplevelSelection('appinspect'); setToplevelSelection('appinspect');
}} }}
/> />
<NotificationButton
toplevelSelection={toplevelSelection}
setToplevelSelection={setToplevelSelection}
/>
{getRenderHostInstance().GK('flipper_connection_troubleshoot') && ( {getRenderHostInstance().GK('flipper_connection_troubleshoot') && (
<ConnectionTroubleshootButton <ConnectionTroubleshootButton
toplevelSelection={toplevelSelection} toplevelSelection={toplevelSelection}
@@ -293,27 +286,6 @@ function ExtrasMenu() {
); );
} }
function NotificationButton({
toplevelSelection,
setToplevelSelection,
}: ToplevelProps) {
const notifications = useStore((state) => state.notifications);
const activeNotifications = useMemoize(filterNotifications, [
notifications.activeNotifications,
notifications.blocklistedPlugins,
notifications.blocklistedCategories,
]);
return (
<LeftRailButton
icon={<BellOutlined />}
title="Notifications"
selected={toplevelSelection === 'notification'}
count={activeNotifications.length}
onClick={() => setToplevelSelection('notification')}
/>
);
}
function ConnectionTroubleshootButton({ function ConnectionTroubleshootButton({
toplevelSelection, toplevelSelection,
setToplevelSelection, setToplevelSelection,

View File

@@ -12,6 +12,7 @@ import {
Layout, Layout,
styled, styled,
theme, theme,
useMemoize,
useValue, useValue,
withTrackingScope, withTrackingScope,
} from 'flipper-plugin'; } from 'flipper-plugin';
@@ -47,6 +48,7 @@ import {isProduction} from 'flipper-common';
import FpsGraph from '../chrome/FpsGraph'; import FpsGraph from '../chrome/FpsGraph';
import NetworkGraph from '../chrome/NetworkGraph'; import NetworkGraph from '../chrome/NetworkGraph';
import {errorCounterAtom} from '../chrome/ConsoleLogs'; import {errorCounterAtom} from '../chrome/ConsoleLogs';
import {filterNotifications} from './notification/notificationUtils';
import {css} from '@emotion/css'; import {css} from '@emotion/css';
export const Navbar = withTrackingScope(function Navbar({ export const Navbar = withTrackingScope(function Navbar({
@@ -89,7 +91,10 @@ export const Navbar = withTrackingScope(function Navbar({
toplevelSelection={toplevelSelection} toplevelSelection={toplevelSelection}
setToplevelSelection={setToplevelSelection} setToplevelSelection={setToplevelSelection}
/> />
<NavbarButton label="Alerts" icon={BellOutlined} /> <NotificationButton
toplevelSelection={toplevelSelection}
setToplevelSelection={setToplevelSelection}
/>
<SetupDoctorButton /> <SetupDoctorButton />
<NavbarButton label="Help" icon={QuestionCircleOutlined} /> <NavbarButton label="Help" icon={QuestionCircleOutlined} />
<NavbarButton label="More" icon={EllipsisOutlined} /> <NavbarButton label="More" icon={EllipsisOutlined} />
@@ -100,6 +105,27 @@ export const Navbar = withTrackingScope(function Navbar({
); );
}); });
function NotificationButton({
toplevelSelection,
setToplevelSelection,
}: ToplevelProps) {
const notifications = useStore((state) => state.notifications);
const activeNotifications = useMemoize(filterNotifications, [
notifications.activeNotifications,
notifications.blocklistedPlugins,
notifications.blocklistedCategories,
]);
return (
<NavbarButton
icon={BellOutlined}
label="Alerts"
toggled={toplevelSelection === 'notification'}
count={activeNotifications.length}
onClick={() => setToplevelSelection('notification')}
/>
);
}
function LeftSidebarToggleButton() { function LeftSidebarToggleButton() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const mainMenuVisible = useStore( const mainMenuVisible = useStore(
@@ -216,7 +242,6 @@ function NavbarButton({
}: { }: {
icon: (props: any) => any; icon: (props: any) => any;
label: string; label: string;
selected?: boolean;
// TODO remove optional // TODO remove optional
onClick?: () => void; onClick?: () => void;
toggled?: boolean; toggled?: boolean;