| 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 |
2x
2x
2x
2x
2x
2x
2x
2x
87x
6x
81x
2x
87x
2x
2x
2x
| import React from 'react';
import PropTypes from 'prop-types';
import {
Card,
LinkifiedText,
} from '@bufferapp/components';
import PostFooter from '../PostFooter';
import PostHeader from '../PostHeader';
import RetweetPanel from '../RetweetPanel';
const postContainerStyle = {
display: 'flex',
width: '100%',
};
const postStyle = {
flexGrow: 1,
minWidth: 0,
};
const postContentStyle = {
padding: '1rem',
whiteSpace: 'pre-line',
};
const retweetProfileWrapperStyle = {
marginBottom: '1rem',
};
const commentStyle = {
marginBottom: '1rem',
};
/* eslint-disable react/prop-types */
const renderRetweetComment = ({
retweetComment,
retweetCommentLinks,
}) => (
<div style={commentStyle}>
<LinkifiedText
links={retweetCommentLinks}
newTab
size={'mini'}
unstyled
>
{ retweetComment }
</LinkifiedText>
</div>
);
const renderContent = ({
children,
retweetComment,
retweetCommentLinks,
retweetProfile,
}) => {
if (retweetProfile) {
return (
<div style={postContentStyle}>
{ retweetComment ? renderRetweetComment({ retweetComment, retweetCommentLinks }) : '' }
<Card
color={'off-white'}
reducedPadding
>
<div style={retweetProfileWrapperStyle}>
<RetweetPanel {...retweetProfile} />
</div>
{ children }
</Card>
</div>
);
}
return (
<div style={postContentStyle}>
{ children }
</div>
);
};
/* eslint-enable react/prop-types */
const Post = ({
children,
hasPermission,
isConfirmingDelete,
isDeleting,
isMoving,
isPastDue,
isWorking,
manager,
onApproveClick,
onCancelConfirmClick,
onDeleteClick,
onDeleteConfirmClick,
onEditClick,
onMoveToDraftsClick,
onRequestApprovalClick,
onRescheduleClick,
draftDetails,
retweetComment,
retweetCommentLinks,
retweetProfile,
scheduledAt,
view,
}) =>
<div style={postContainerStyle}>
<div style={postStyle}>
<Card
faded={isDeleting}
noPadding
>
<PostHeader
draftDetails={draftDetails}
/>
{renderContent({
children,
retweetProfile,
retweetComment,
retweetCommentLinks,
})}
<PostFooter
hasPermission={hasPermission}
isDeleting={isDeleting}
isConfirmingDelete={isConfirmingDelete}
isMoving={isMoving}
isPastDue={isPastDue}
isWorking={isWorking}
manager={manager}
onApproveClick={onApproveClick}
onCancelConfirmClick={onCancelConfirmClick}
onDeleteClick={onDeleteClick}
onDeleteConfirmClick={onDeleteConfirmClick}
onEditClick={onEditClick}
onMoveToDraftsClick={onMoveToDraftsClick}
onRequestApprovalClick={onRequestApprovalClick}
onRescheduleClick={onRescheduleClick}
draftDetails={draftDetails}
scheduledAt={scheduledAt}
view={view}
/>
</Card>
</div>
</div>;
Post.commonPropTypes = {
hasPermission: PropTypes.bool.isRequired,
isConfirmingDelete: PropTypes.bool,
isDeleting: PropTypes.bool,
isMoving: PropTypes.bool,
isPastDue: PropTypes.bool,
isWorking: PropTypes.bool,
manager: PropTypes.bool,
onApproveClick: PropTypes.func,
onCancelConfirmClick: PropTypes.func.isRequired,
onDeleteClick: PropTypes.func.isRequired,
onDeleteConfirmClick: PropTypes.func.isRequired,
onEditClick: PropTypes.func.isRequired,
onRescheduleClick: PropTypes.func,
onMoveToDraftsClick: PropTypes.func,
onRequestApprovalClick: PropTypes.func,
draftDetails: PropTypes.shape({
avatarUrl: PropTypes.string,
createdAt: PropTypes.string,
email: PropTypes.string,
isRetweet: PropTypes.bool,
postAction: PropTypes.string,
userName: PropTypes.string,
via: PropTypes.string,
}).isRequired,
retweetProfile: PropTypes.shape({
avatarUrl: PropTypes.string,
handle: PropTypes.string,
name: PropTypes.string,
}),
retweetComment: PropTypes.string,
retweetCommentLinks: PropTypes.arrayOf(
PropTypes.shape({
rawString: PropTypes.string,
displayString: PropTypes.string,
expandedUrl: PropTypes.string,
indices: PropTypes.arrayOf(PropTypes.number),
}),
),
scheduledAt: PropTypes.number,
view: PropTypes.string.isRequired,
};
Post.propTypes = {
...Post.commonPropTypes,
children: PropTypes.node.isRequired,
};
Post.defaultProps = {
isConfirmingDelete: false,
isDeleting: false,
isMoving: false,
isPastDue: false,
isWorking: false,
manager: false,
};
export default Post;
|