Cleanup global notifications UI

Summary: We don't need to show plugin-related details and button "open globalError" (which anyway doesn't work) when showing global notifications.

Reviewed By: passy

Differential Revision: D28900468

fbshipit-source-id: 54347ede4f1e4dbfb0e41be5c50374fda35c1223
This commit is contained in:
Anton Nikolaev
2021-06-07 05:52:50 -07:00
committed by Facebook GitHub Bot
parent 90d40ac385
commit 9a2677fc24
2 changed files with 18 additions and 11 deletions

View File

@@ -12,6 +12,8 @@ import {Actions} from './';
import {getStringFromErrorLike} from '../utils'; import {getStringFromErrorLike} from '../utils';
import React from 'react'; import React from 'react';
export const GLOBAL_NOTIFICATION_PLUGIN_ID = 'Flipper';
export type PluginNotification = { export type PluginNotification = {
notification: Notification; notification: Notification;
pluginId: string; pluginId: string;
@@ -208,7 +210,7 @@ export function addErrorNotification(
console.warn(title, message, error); console.warn(title, message, error);
return addNotification({ return addNotification({
client: null, client: null,
pluginId: 'globalError', pluginId: GLOBAL_NOTIFICATION_PLUGIN_ID,
notification: { notification: {
id: title, id: title,
title, title,

View File

@@ -24,6 +24,7 @@ import {useDispatch, useStore} from '../../utils/useStore';
import {selectPlugin} from '../../reducers/connections'; import {selectPlugin} from '../../reducers/connections';
import { import {
clearAllNotifications, clearAllNotifications,
GLOBAL_NOTIFICATION_PLUGIN_ID,
PluginNotification as PluginNotificationOrig, PluginNotification as PluginNotificationOrig,
updateCategoryBlocklist, updateCategoryBlocklist,
updatePluginBlocklist, updatePluginBlocklist,
@@ -39,7 +40,7 @@ type NotificationExtra = {
onHidePlugin: () => void; onHidePlugin: () => void;
clientName: string | undefined; clientName: string | undefined;
appName: string | undefined; appName: string | undefined;
pluginName: string; pluginName: string | null | undefined;
iconName: string | null | undefined; iconName: string | null | undefined;
}; };
type PluginNotification = NotificationData & NotificationExtra; type PluginNotification = NotificationData & NotificationExtra;
@@ -152,17 +153,21 @@ function NotificationEntry({notification}: {notification: PluginNotification}) {
</Layout.Horizontal> </Layout.Horizontal>
{actions} {actions}
</Layout.Right> </Layout.Right>
<Title level={4} ellipsis={{rows: 2}}> <Title level={4} ellipsis={{rows: 3}}>
{title} {title}
</Title> </Title>
<Text type="secondary" style={{fontSize: theme.fontSize.small}}> {pluginName !== GLOBAL_NOTIFICATION_PLUGIN_ID && (
{clientName && appName <>
? `${clientName}/${appName}` <Text type="secondary" style={{fontSize: theme.fontSize.small}}>
: clientName ?? appName ?? 'Not Connected'} {clientName && appName
</Text> ? `${clientName}/${appName}`
<Button style={{width: 'fit-content'}} size="small" onClick={onOpen}> : clientName ?? appName ?? 'Not Connected'}
Open {pluginName} </Text>
</Button> <Button style={{width: 'fit-content'}} size="small" onClick={onOpen}>
Open {pluginName}
</Button>
</>
)}
<DetailCollapse detail={message} /> <DetailCollapse detail={message} />
</ItemContainer> </ItemContainer>
); );