link to hub

Summary: Clicking on a notifications links to the Notification Hub highlighting the selected notification.

Reviewed By: jknoxville

Differential Revision: D10487822

fbshipit-source-id: ed907ec244bef970d1b30ddb719856949229d0c4
This commit is contained in:
Daniel Büchele
2018-10-22 06:58:02 -07:00
committed by Facebook Github Bot
parent 7b9bd8560e
commit c8a7ce5cfb
2 changed files with 18 additions and 8 deletions

View File

@@ -60,6 +60,8 @@ export default class Notifications extends FlipperDevicePlugin<{}> {
return ( return (
<ConnectedNotificationsTable <ConnectedNotificationsTable
onClear={this.onClear} onClear={this.onClear}
selectedID={this.props.deepLinkPayload}
onSelectPlugin={this.props.selectPlugin}
defaultFilters={this.context.store defaultFilters={this.context.store
.getState() .getState()
.notifications.blacklistedPlugins.map(value => ({ .notifications.blacklistedPlugins.map(value => ({
@@ -90,6 +92,7 @@ type Props = {|
selectedApp: ?string, selectedApp: ?string,
deepLinkPayload?: ?string, deepLinkPayload?: ?string,
}) => mixed, }) => mixed,
selectedID: ?string,
|}; |};
type State = {| type State = {|
@@ -128,11 +131,16 @@ const NoContent = styled(FlexColumn)({
}); });
class NotificationsTable extends Component<Props, State> { class NotificationsTable extends Component<Props, State> {
state = { static getDerivedStateFromProps(props: Props): State {
selectedNotification: null, return {
selectedNotification: props.selectedID,
}; };
}
contextMenuItems = [{label: 'Clear all', click: this.props.onClear}]; contextMenuItems = [{label: 'Clear all', click: this.props.onClear}];
state: State = {
selectedNotification: this.props.selectedID,
};
componentDidUpdate(prevProps: Props) { componentDidUpdate(prevProps: Props) {
if (this.props.filters.length !== prevProps.filters.length) { if (this.props.filters.length !== prevProps.filters.length) {
@@ -196,7 +204,8 @@ class NotificationsTable extends Component<Props, State> {
onHide={() => this.onHide(n.pluginId)} onHide={() => this.onHide(n.pluginId)}
selectPlugin={this.props.selectPlugin} selectPlugin={this.props.selectPlugin}
/> />
)); ))
.reverse();
const invalidatedNotifications = this.props.invalidatedNotifications const invalidatedNotifications = this.props.invalidatedNotifications
.filter(this.getFilter()) .filter(this.getFilter())
@@ -207,7 +216,8 @@ class NotificationsTable extends Component<Props, State> {
onClear={this.props.onClear} onClear={this.props.onClear}
inactive inactive
/> />
)); ))
.reverse();
return ( return (
<ContextMenu items={this.contextMenuItems} component={Content}> <ContextMenu items={this.contextMenuItems} component={Content}>

View File

@@ -65,9 +65,9 @@ export default (store: Store, logger: Logger) => {
notification.onclick = () => notification.onclick = () =>
store.dispatch( store.dispatch(
selectPlugin({ selectPlugin({
selectedPlugin: n.pluginId, selectedPlugin: 'notifications',
selectedApp: n.client, selectedApp: null,
deepLinkPayload: n.notification.action, deepLinkPayload: n.notification.id,
}), }),
); );
knownNotifications.add(n.notification.id); knownNotifications.add(n.notification.id);