File size: 2,589 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// @flow
import * as React from 'react';
import { UserHoverProfile } from 'src/components/hoverProfile';
import {
  Container,
  MetaContainer,
  TextRow,
  MetaTitle,
  MetaSubtitle,
  Divider,
  MetaSubtitleText,
  MetaSubtitleLocked,
  MetaSubtitleWatercooler,
  MetaSubtitlePinned,
} from './style';
import Timestamp from './timestamp';
import type { HeaderProps } from './index';

class Header extends React.Component<HeaderProps> {
  render() {
    const {
      active,
      viewContext,
      thread: { community, channel, id, watercooler, isLocked, author },
    } = this.props;

    const isPinned = id === community.pinnedThreadId;

    return (
      <Container active={active}>
        <MetaContainer>
          <TextRow>
            <MetaTitle active={active} to={`/${community.slug}`}>
              {community.name}
            </MetaTitle>

            <Divider></Divider>
            <Timestamp {...this.props} />
          </TextRow>

          <TextRow>
            {viewContext === 'userProfileReplies' && (
              <MetaSubtitleText>
                {author.user.username ? (
                  <UserHoverProfile username={author.user.username}>
                    <MetaSubtitle
                      active={active}
                      to={`/users/${author.user.username}`}
                    >
                      By {author.user.name}
                    </MetaSubtitle>
                  </UserHoverProfile>
                ) : (
                  <MetaSubtitleText active={active}>
                    By {author.user.name}
                  </MetaSubtitleText>
                )}

                <Divider></Divider>
              </MetaSubtitleText>
            )}

            <MetaSubtitle
              active={active}
              to={`/${community.slug}/${channel.slug}`}
            >
              # {channel.name}
            </MetaSubtitle>

            {watercooler && (
              <MetaSubtitleWatercooler active={active}>
                <Divider></Divider>
                Watercooler
              </MetaSubtitleWatercooler>
            )}

            {isLocked && (
              <MetaSubtitleLocked active={active}>
                <Divider></Divider>
                Locked
              </MetaSubtitleLocked>
            )}

            {isPinned && (
              <MetaSubtitlePinned active={active}>
                <Divider></Divider>
                Pinned
              </MetaSubtitlePinned>
            )}
          </TextRow>
        </MetaContainer>
      </Container>
    );
  }
}

export default Header;