Change NotificationsHub to StaticView
Summary: - Point the Noitifications to the static view - Add function to check activeness of static view - Add `SupportRequestDetails` to type (needed?) Reviewed By: mweststrate Differential Revision: D18810149 fbshipit-source-id: a33f61f521f3db0dd2a73e56d99b12d029b46a57
This commit is contained in:
committed by
Facebook Github Bot
parent
8df91d198f
commit
07487e8122
@@ -37,7 +37,7 @@ import {
|
||||
Info,
|
||||
} from 'flipper';
|
||||
import React, {Component, PureComponent, Fragment} from 'react';
|
||||
import NotificationsHub from '../NotificationsHub';
|
||||
import NotificationScreen from '../chrome/NotificationScreen';
|
||||
import {
|
||||
selectPlugin,
|
||||
starPlugin,
|
||||
@@ -286,7 +286,6 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
staticView,
|
||||
selectPlugin,
|
||||
setStaticView,
|
||||
numNotifications,
|
||||
uninitializedClients,
|
||||
} = this.props;
|
||||
const clients = getAvailableClients(selectedDevice, this.props.clients);
|
||||
@@ -377,38 +376,10 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
</ListItem>
|
||||
)}
|
||||
</Plugins>
|
||||
{!GK.get('flipper_disable_notifications') && (
|
||||
<ListItem
|
||||
active={selectedPlugin === 'notifications'}
|
||||
onClick={() =>
|
||||
selectPlugin({
|
||||
selectedPlugin: 'notifications',
|
||||
selectedApp: null,
|
||||
deepLinkPayload: null,
|
||||
})
|
||||
}
|
||||
style={{
|
||||
borderTop: `1px solid ${colors.blackAlpha10}`,
|
||||
}}>
|
||||
<PluginIcon
|
||||
color={colors.light50}
|
||||
name={
|
||||
numNotifications > 0
|
||||
? NotificationsHub.icon || 'bell'
|
||||
: 'bell-null'
|
||||
}
|
||||
isActive={selectedPlugin === NotificationsHub.id}
|
||||
/>
|
||||
<PluginName
|
||||
count={numNotifications}
|
||||
isActive={selectedPlugin === NotificationsHub.id}>
|
||||
{NotificationsHub.title}
|
||||
</PluginName>
|
||||
</ListItem>
|
||||
)}
|
||||
{this.renderNotificationsEntry()}
|
||||
{this.state.showSupportForm &&
|
||||
(function() {
|
||||
const active = staticView && staticView === SupportRequestFormV2;
|
||||
const active = isStaticViewActive(staticView, SupportRequestFormV2);
|
||||
return (
|
||||
<ListItem
|
||||
active={active}
|
||||
@@ -441,6 +412,10 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
return null;
|
||||
}
|
||||
const {staticView, setStaticView} = this.props;
|
||||
const supportRequestDetailsactive = isStaticViewActive(
|
||||
staticView,
|
||||
SupportRequestDetails,
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<ListItem>
|
||||
@@ -451,21 +426,14 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
{this.state.showSupportForm &&
|
||||
(selectedDevice as ArchivedDevice).supportRequestDetails && (
|
||||
<ListItem
|
||||
active={
|
||||
staticView != null && staticView === SupportRequestDetails
|
||||
}
|
||||
active={supportRequestDetailsactive}
|
||||
onClick={() => setStaticView(SupportRequestDetails)}>
|
||||
<PluginIcon
|
||||
color={colors.light50}
|
||||
name={'app-dailies'}
|
||||
isActive={
|
||||
staticView != null && staticView === SupportRequestDetails
|
||||
}
|
||||
isActive={supportRequestDetailsactive}
|
||||
/>
|
||||
<PluginName
|
||||
isActive={
|
||||
staticView != null && staticView === SupportRequestDetails
|
||||
}>
|
||||
<PluginName isActive={supportRequestDetailsactive}>
|
||||
Support Request Details
|
||||
</PluginName>
|
||||
</ListItem>
|
||||
@@ -593,6 +561,41 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
renderNotificationsEntry() {
|
||||
if (GK.get('flipper_disable_notifications')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const active = isStaticViewActive(
|
||||
this.props.staticView,
|
||||
NotificationScreen,
|
||||
);
|
||||
return (
|
||||
<ListItem
|
||||
active={active}
|
||||
onClick={() => this.props.setStaticView(NotificationScreen)}
|
||||
style={{
|
||||
borderTop: `1px solid ${colors.blackAlpha10}`,
|
||||
}}>
|
||||
<PluginIcon
|
||||
color={colors.light50}
|
||||
name={this.props.numNotifications > 0 ? 'bell' : 'bell-null'}
|
||||
isActive={active}
|
||||
/>
|
||||
<PluginName count={this.props.numNotifications} isActive={active}>
|
||||
Notifications
|
||||
</PluginName>
|
||||
</ListItem>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isStaticViewActive(
|
||||
current: StaticView,
|
||||
selected: StaticView,
|
||||
): boolean {
|
||||
return current && selected && current === selected;
|
||||
}
|
||||
|
||||
function getFavoritePlugins(
|
||||
|
||||
102
src/chrome/NotificationScreen.tsx
Normal file
102
src/chrome/NotificationScreen.tsx
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {PureComponent, Fragment} from 'react';
|
||||
import {Logger} from '../fb-interfaces/Logger';
|
||||
import {connect} from 'react-redux';
|
||||
import {State as Store} from '../reducers/index';
|
||||
import {ConnectedNotificationsTable} from '../NotificationsHub';
|
||||
import {Button, colors, styled, FlexColumn} from '../ui';
|
||||
import {clearAllNotifications} from '../reducers/notifications';
|
||||
import {selectPlugin} from '../reducers/connections';
|
||||
import React from 'react';
|
||||
|
||||
type StateFromProps = {
|
||||
deepLinkPayload: string | null;
|
||||
blacklistedPlugins: Array<string>;
|
||||
blacklistedCategories: Array<string>;
|
||||
};
|
||||
|
||||
type DispatchFromProps = {
|
||||
clearAllNotifications: () => void;
|
||||
selectPlugin: (payload: {
|
||||
selectedPlugin: string | null;
|
||||
selectedApp: string | null | undefined;
|
||||
deepLinkPayload: string | null;
|
||||
}) => any;
|
||||
};
|
||||
|
||||
type OwnProps = {
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
type Props = StateFromProps & DispatchFromProps & OwnProps;
|
||||
|
||||
type State = {};
|
||||
|
||||
const Container = styled(FlexColumn)({
|
||||
width: 0,
|
||||
flexGrow: 1,
|
||||
flexShrink: 1,
|
||||
backgroundColor: colors.white,
|
||||
});
|
||||
|
||||
class Notifications extends PureComponent<Props, State> {
|
||||
render() {
|
||||
const {
|
||||
blacklistedPlugins,
|
||||
blacklistedCategories,
|
||||
deepLinkPayload,
|
||||
logger,
|
||||
clearAllNotifications,
|
||||
selectPlugin,
|
||||
} = this.props;
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Container>
|
||||
<ConnectedNotificationsTable
|
||||
onClear={clearAllNotifications}
|
||||
selectedID={deepLinkPayload}
|
||||
onSelectPlugin={selectPlugin}
|
||||
logger={logger}
|
||||
defaultFilters={[
|
||||
...blacklistedPlugins.map(value => ({
|
||||
value,
|
||||
type: 'exclude',
|
||||
key: 'plugin',
|
||||
})),
|
||||
...blacklistedCategories.map(value => ({
|
||||
value,
|
||||
type: 'exclude',
|
||||
key: 'category',
|
||||
})),
|
||||
]}
|
||||
actions={
|
||||
<Fragment>
|
||||
<Button onClick={clearAllNotifications}>Clear</Button>
|
||||
</Fragment>
|
||||
}
|
||||
/>
|
||||
</Container>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
||||
({
|
||||
connections: {deepLinkPayload},
|
||||
notifications: {blacklistedPlugins, blacklistedCategories},
|
||||
}) => ({
|
||||
deepLinkPayload,
|
||||
blacklistedPlugins,
|
||||
blacklistedCategories,
|
||||
}),
|
||||
{clearAllNotifications, selectPlugin},
|
||||
)(Notifications);
|
||||
Reference in New Issue
Block a user