File size: 1,395 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// @flow
import React from 'react';
import compose from 'recompose/compose';
import { withRouter, type History } from 'react-router-dom';
import { connect } from 'react-redux';
import { withCurrentUser } from 'src/components/withCurrentUser';
import { MobileTitlebar } from 'src/components/titlebar';
import { ErrorBoundary } from 'src/components/error';
import { isViewingMarketingPage } from 'src/helpers/is-viewing-marketing-page';

export type TitlebarPayloadProps = {
  title: string,
  titleIcon?: React$Node,
  rightAction?: React$Node,
  leftAction?: React$Element<*> | 'menu' | 'view-back',
};

type TitlebarProps = {
  ...$Exact<TitlebarPayloadProps>,
  history: History,
  currentUser: ?Object,
};

const GlobalTitlebar = (props: TitlebarProps): React$Node => {
  const {
    title = 'Spectrum',
    titleIcon = null,
    rightAction = null,
    leftAction = 'menu',
    history,
    currentUser,
  } = props;

  if (isViewingMarketingPage(history, currentUser)) {
    return null;
  }

  return (
    <ErrorBoundary fallbackComponent={<MobileTitlebar title="Error" />}>
      <MobileTitlebar
        title={title}
        titleIcon={titleIcon}
        leftAction={leftAction}
        rightAction={rightAction}
      />
    </ErrorBoundary>
  );
};

const map = (state): * => state.titlebar;

export default compose(
  withRouter,
  withCurrentUser,
  connect(map)
)(GlobalTitlebar);