Skip to content

Commit

Permalink
chore: major frontend JS cleanup (#3609)
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat authored May 7, 2023
1 parent dde6562 commit be8f7be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion js/src/forum/addFlagsToPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function () {
user,
reason,
}),
detail ? <span className="Post-flagged-detail">{detail}</span> : '',
!!detail && <span className="Post-flagged-detail">{detail}</span>,
];
}
};
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/components/FlagList.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class FlagList extends Component {
) : !this.state.loading ? (
<div className="NotificationList-empty">{app.translator.trans('flarum-flags.forum.flagged_posts.empty_text')}</div>
) : (
LoadingIndicator.component({ className: 'LoadingIndicator--block' })
<LoadingIndicator className="LoadingIndicator--block" />
)}
</ul>
</div>
Expand Down
16 changes: 4 additions & 12 deletions js/src/forum/components/FlagPostModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ export default class FlagPostModal extends Modal {
<input type="radio" name="reason" checked={this.reason() === 'off_topic'} value="off_topic" onclick={withAttr('value', this.reason)} />
<strong>{app.translator.trans('flarum-flags.forum.flag_post.reason_off_topic_label')}</strong>
{app.translator.trans('flarum-flags.forum.flag_post.reason_off_topic_text')}
{this.reason() === 'off_topic' ? (
{this.reason() === 'off_topic' && (
<textarea
className="FormControl"
placeholder={app.translator.trans('flarum-flags.forum.flag_post.reason_details_placeholder')}
value={this.reasonDetail()}
oninput={withAttr('value', this.reasonDetail)}
></textarea>
) : (
''
)}
</label>,
70
Expand All @@ -95,15 +93,13 @@ export default class FlagPostModal extends Modal {
{app.translator.trans('flarum-flags.forum.flag_post.reason_inappropriate_text', {
a: guidelinesUrl ? <a href={guidelinesUrl} target="_blank" /> : undefined,
})}
{this.reason() === 'inappropriate' ? (
{this.reason() === 'inappropriate' && (
<textarea
className="FormControl"
placeholder={app.translator.trans('flarum-flags.forum.flag_post.reason_details_placeholder')}
value={this.reasonDetail()}
oninput={withAttr('value', this.reasonDetail)}
></textarea>
) : (
''
)}
</label>,
60
Expand All @@ -115,15 +111,13 @@ export default class FlagPostModal extends Modal {
<input type="radio" name="reason" checked={this.reason() === 'spam'} value="spam" onclick={withAttr('value', this.reason)} />
<strong>{app.translator.trans('flarum-flags.forum.flag_post.reason_spam_label')}</strong>
{app.translator.trans('flarum-flags.forum.flag_post.reason_spam_text')}
{this.reason() === 'spam' ? (
{this.reason() === 'spam' && (
<textarea
className="FormControl"
placeholder={app.translator.trans('flarum-flags.forum.flag_post.reason_details_placeholder')}
value={this.reasonDetail()}
oninput={withAttr('value', this.reasonDetail)}
></textarea>
) : (
''
)}
</label>,
50
Expand All @@ -134,10 +128,8 @@ export default class FlagPostModal extends Modal {
<label className="checkbox">
<input type="radio" name="reason" checked={this.reason() === 'other'} value="other" onclick={withAttr('value', this.reason)} />
<strong>{app.translator.trans('flarum-flags.forum.flag_post.reason_other_label')}</strong>
{this.reason() === 'other' ? (
{this.reason() === 'other' && (
<textarea className="FormControl" value={this.reasonDetail()} oninput={withAttr('value', this.reasonDetail)}></textarea>
) : (
''
)}
</label>,
10
Expand Down
4 changes: 2 additions & 2 deletions js/src/forum/components/FlagsDropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import app from 'flarum/forum/app';
import NotificationsDropdown from 'flarum/components/NotificationsDropdown';
import NotificationsDropdown from 'flarum/forum/components/NotificationsDropdown';

import FlagList from './FlagList';

Expand All @@ -14,7 +14,7 @@ export default class FlagsDropdown extends NotificationsDropdown {
getMenu() {
return (
<div className={'Dropdown-menu ' + this.attrs.menuClassName} onclick={this.menuClick.bind(this)}>
{this.showing ? FlagList.component({ state: this.attrs.state }) : ''}
{this.showing && <FlagList state={this.attrs.state} />}
</div>
);
}
Expand Down

0 comments on commit be8f7be

Please sign in to comment.