summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post-form.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-05-28 12:55:18 -0400
committerDessalines <tyhou13@gmx.com>2020-05-28 12:55:18 -0400
commitd9ec95ab5b78b13e44d9cc4247218b5766c9d3f2 (patch)
tree7f46fa7b470e1ba7a3237ddb8e77d463ee5b5e2a /ui/src/components/post-form.tsx
parentdd5cedcfeafb9c82d1c65e9a0211f8645e263be4 (diff)
For top-bar post creation, dont select a default community. Fixes #729
Diffstat (limited to 'ui/src/components/post-form.tsx')
-rw-r--r--ui/src/components/post-form.tsx20
1 files changed, 14 insertions, 6 deletions
diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx
index 912d8e58..6f1e34e0 100644
--- a/ui/src/components/post-form.tsx
+++ b/ui/src/components/post-form.tsx
@@ -194,8 +194,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
<form>
<label
htmlFor="file-upload"
- className={`${UserService.Instance.user &&
- 'pointer'} d-inline-block float-right text-muted font-weight-bold`}
+ className={`${
+ UserService.Instance.user && 'pointer'
+ } d-inline-block float-right text-muted font-weight-bold`}
data-tippy-content={i18n.t('upload_image')}
>
<svg class="icon icon-inline">
@@ -288,8 +289,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
)}
{this.state.postForm.body && (
<button
- className={`mt-1 mr-2 btn btn-sm btn-secondary ${this.state
- .previewMode && 'active'}`}
+ className={`mt-1 mr-2 btn btn-sm btn-secondary ${
+ this.state.previewMode && 'active'
+ }`}
onClick={linkEvent(this, this.handlePreviewToggle)}
>
{i18n.t('preview')}
@@ -328,6 +330,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
value={this.state.postForm.community_id}
onInput={linkEvent(this, this.handlePostCommunityChange)}
>
+ <option>{i18n.t('select_a_community')}</option>
{this.state.communities.map(community => (
<option value={community.id}>{community.name}</option>
))}
@@ -355,7 +358,11 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
)}
<div class="form-group row">
<div class="col-sm-10">
- <button type="submit" class="btn btn-secondary mr-2">
+ <button
+ disabled={!this.state.postForm.community_id}
+ type="submit"
+ class="btn btn-secondary mr-2"
+ >
{this.state.loading ? (
<svg class="icon icon-spinner spin">
<use xlinkHref="#icon-spinner"></use>
@@ -561,7 +568,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
).id;
this.state.postForm.community_id = foundCommunityId;
} else {
- this.state.postForm.community_id = data.communities[0].id;
+ // By default, the null valued 'Select a Community'
}
this.setState(this.state);
@@ -571,6 +578,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
let selector = new Selectr(selectId, { nativeDropdown: false });
selector.on('selectr.select', option => {
this.state.postForm.community_id = Number(option.value);
+ this.setState(this.state);
});
}
} else if (res.op == UserOperation.CreatePost) {