Skip to content

Commit 57f0c5e

Browse files
committed
duplicated upload button; old discussion-f route
1 parent 2622ff2 commit 57f0c5e

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

saas/app/components/discussions/CreateDiscussionForm.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ class CreateDiscussionForm extends React.Component<Props, State> {
132132
<p />
133133
<PostEditor
134134
content={this.state.content}
135-
onChanged={(content) => this.setState({ content })}
135+
onChanged={this.onContentChanged}
136136
members={Array.from(store.currentTeam.members.values())}
137137
store={store}
138+
parentComponent="CDF"
138139
/>
139140
<p />
140141
<div>
@@ -181,6 +182,11 @@ class CreateDiscussionForm extends React.Component<Props, State> {
181182
this.props.onClose();
182183
};
183184

185+
private onContentChanged = (content: string) => {
186+
console.log('onContentChanged', content);
187+
this.setState({ content });
188+
};
189+
184190
private onSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
185191
event.preventDefault();
186192

saas/app/components/discussions/DiscussionListItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DiscussionListItem extends React.Component<Props> {
4545
<li key={discussion._id} style={{ whiteSpace: 'nowrap', paddingRight: '10px' }}>
4646
<Link
4747
scroll={false}
48-
href={`/discussion-f?teamSlug=${team.slug}&discussionSlug=${discussion.slug}`}
48+
href={`/discussion?teamSlug=${team.slug}&discussionSlug=${discussion.slug}`}
4949
as={`/teams/${team.slug}/discussions/${discussion.slug}`}
5050
>
5151
<a

saas/app/components/posts/PostEditor.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type Props = {
4343
members: User[];
4444
textareaHeight?: string;
4545
placeholder?: string;
46+
parentComponent: string;
4647
};
4748

4849
type State = { htmlContent: string };
@@ -58,7 +59,7 @@ class PostEditor extends React.Component<Props, State> {
5859

5960
public render() {
6061
const { htmlContent } = this.state;
61-
const { content, members, store } = this.props;
62+
const { content, members, store, parentComponent } = this.props;
6263
const { currentUser } = store;
6364

6465
const membersMinusCurrentUser = members.filter((member) => member._id !== currentUser._id);
@@ -86,21 +87,21 @@ class PostEditor extends React.Component<Props, State> {
8687
</div>
8788

8889
<div style={{ display: 'inline', float: 'left' }}>
89-
<label htmlFor="upload-file-post-editor">
90+
<label htmlFor={'upload-file-post-editor-' + parentComponent}>
9091
<Button component="span" style={{ color: '#58a6ff' }}>
9192
<InsertPhotoIcon style={{ fontSize: '22px' }} />
9293
</Button>
9394
</label>
9495
<input
9596
accept="image/*"
96-
name="upload-file-post-editor"
97-
id="upload-file-post-editor"
97+
name={'upload-file-post-editor-' + parentComponent}
98+
id={'upload-file-post-editor-' + parentComponent}
9899
type="file"
99100
style={{ display: 'none' }}
100-
onChange={(event) => {
101+
onChange={async (event) => {
101102
const file = event.target.files[0];
103+
await this.uploadFile(file);
102104
event.target.value = '';
103-
this.uploadFile(file);
104105
}}
105106
/>
106107
</div>
@@ -257,7 +258,7 @@ class PostEditor extends React.Component<Props, State> {
257258
bucket,
258259
});
259260

260-
let imageMarkdown;
261+
let fileHtmlOrMarkdown;
261262
let fileUrl;
262263

263264
if (file.type.startsWith('image/')) {
@@ -275,7 +276,7 @@ class PostEditor extends React.Component<Props, State> {
275276

276277
const finalWidth = width > 768 ? '100%' : `${width}px`;
277278

278-
imageMarkdown = `
279+
fileHtmlOrMarkdown = `
279280
<div>
280281
<img style="max-width: ${finalWidth}; width:100%" src="${fileUrl}" alt="Async" class="s3-image" />
281282
</div>`;
@@ -286,14 +287,13 @@ class PostEditor extends React.Component<Props, State> {
286287
);
287288

288289
fileUrl = responseFromApiServerForUpload.url;
289-
imageMarkdown = `[${file.name}](${fileUrl})`;
290+
fileHtmlOrMarkdown = `[${file.name}](${fileUrl})`;
290291
}
291292

292-
const content = `${this.props.content}\n${imageMarkdown.replace(/\s+/g, ' ')}`;
293+
const content = `${this.props.content}\n${fileHtmlOrMarkdown.replace(/\s+/g, ' ')}`;
293294

294295
this.props.onChanged(content);
295296

296-
NProgress.done();
297297
notify('You successfully uploaded file.');
298298
} catch (error) {
299299
console.log(error);

saas/app/components/posts/PostForm.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class PostForm extends React.Component<Props, State> {
110110
members={members}
111111
store={store}
112112
textareaHeight="100%"
113+
parentComponent="PF"
113114
/>
114115
<p />
115116
<div style={{ margin: '20px 0px' }}>

saas/app/pages/discussion.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ function DiscussionPageCompFunctional({
112112

113113
if (!slug && currentTeam.discussions.length > 0) {
114114
Router.replace(
115-
`/discussion-f?teamSlug=${teamSlug}&discussionSlug=${currentTeam.orderedDiscussions[0].slug}`,
116-
`/teams/${teamSlug}/discussions-f/${currentTeam.orderedDiscussions[0].slug}`,
115+
`/discussion?teamSlug=${teamSlug}&discussionSlug=${currentTeam.orderedDiscussions[0].slug}`,
116+
`/teams/${teamSlug}/discussions/${currentTeam.orderedDiscussions[0].slug}`,
117117
);
118118
return;
119119
}

0 commit comments

Comments
 (0)