Some more prettifying, cleaning up community and main.tsx

This commit is contained in:
Dessalines 2020-07-29 00:23:24 -04:00
parent 52b221e3c9
commit ae78b3473f
11 changed files with 451 additions and 387 deletions

View file

@ -187,7 +187,6 @@ export class Community extends Component<any, State> {
return ( return (
<div class="container"> <div class="container">
<Helmet title={this.documentTitle} /> <Helmet title={this.documentTitle} />
{this.selects()}
{this.state.loading ? ( {this.state.loading ? (
<h5> <h5>
<svg class="icon icon-spinner spin"> <svg class="icon icon-spinner spin">
@ -197,19 +196,7 @@ export class Community extends Component<any, State> {
) : ( ) : (
<div class="row"> <div class="row">
<div class="col-12 col-md-8"> <div class="col-12 col-md-8">
<h5> {this.selects()}
{this.state.community.title}
{this.state.community.removed && (
<small className="ml-2 text-muted font-italic">
{i18n.t('removed')}
</small>
)}
{this.state.community.nsfw && (
<small className="ml-2 text-muted font-italic">
{i18n.t('nsfw')}
</small>
)}
</h5>
{this.listings()} {this.listings()}
{this.paginator()} {this.paginator()}
</div> </div>

View file

@ -33,7 +33,7 @@ export class DataTypeSelect extends Component<
render() { render() {
return ( return (
<div class="btn-group btn-group-toggle"> <div class="btn-group btn-group-toggle flex-wrap mb-2">
<label <label
className={`pointer btn btn-outline-secondary className={`pointer btn btn-outline-secondary
${this.state.type_ == DataType.Post && 'active'} ${this.state.type_ == DataType.Post && 'active'}

View file

@ -171,7 +171,7 @@ export class Inbox extends Component<any, InboxState> {
unreadOrAllRadios() { unreadOrAllRadios() {
return ( return (
<div class="btn-group btn-group-toggle"> <div class="btn-group btn-group-toggle flex-wrap mb-2">
<label <label
className={`btn btn-outline-secondary pointer className={`btn btn-outline-secondary pointer
${this.state.unreadOrAll == UnreadOrAll.Unread && 'active'} ${this.state.unreadOrAll == UnreadOrAll.Unread && 'active'}
@ -204,7 +204,7 @@ export class Inbox extends Component<any, InboxState> {
messageTypeRadios() { messageTypeRadios() {
return ( return (
<div class="btn-group btn-group-toggle"> <div class="btn-group btn-group-toggle flex-wrap mb-2">
<label <label
className={`btn btn-outline-secondary pointer className={`btn btn-outline-secondary pointer
${this.state.messageType == MessageType.All && 'active'} ${this.state.messageType == MessageType.All && 'active'}

View file

@ -34,7 +34,7 @@ export class ListingTypeSelect extends Component<
render() { render() {
return ( return (
<div class="btn-group btn-group-toggle"> <div class="btn-group btn-group-toggle flex-wrap mb-2">
<label <label
className={`btn btn-outline-secondary className={`btn btn-outline-secondary
${this.state.type_ == ListingType.Subscribed && 'active'} ${this.state.type_ == ListingType.Subscribed && 'active'}

View file

@ -194,63 +194,52 @@ export class Main extends Component<any, MainState> {
<main role="main" class="col-12 col-md-8"> <main role="main" class="col-12 col-md-8">
{this.posts()} {this.posts()}
</main> </main>
<aside class="col-12 col-md-4">{this.my_sidebar()}</aside> <aside class="col-12 col-md-4">{this.mySidebar()}</aside>
</div> </div>
</div> </div>
); );
} }
my_sidebar() { mySidebar() {
return ( return (
<div> <div>
{!this.state.loading && ( {!this.state.loading && (
<div> <div>
<div class="card bg-transparent border-secondary mb-3"> <div class="card bg-transparent border-secondary mb-3">
<div class="card-header bg-transparent border-secondary">
{this.siteName()}
{this.adminButtons()}
</div>
<div class="card-body"> <div class="card-body">
{this.trendingCommunities()} {this.trendingCommunities()}
{UserService.Instance.user && {this.createCommunityButton()}
this.state.subscribedCommunities.length > 0 && ( {/*
<div> {this.subscribedCommunities()}
<h5> */}
<T i18nKey="subscribed_to_communities">
#
<Link class="text-body" to="/communities">
#
</Link>
</T>
</h5>
<ul class="list-inline">
{this.state.subscribedCommunities.map(community => (
<li class="list-inline-item">
<CommunityLink
community={{
name: community.community_name,
id: community.community_id,
local: community.community_local,
actor_id: community.community_actor_id,
}}
/>
</li>
))}
</ul>
</div>
)}
<Link
class="btn btn-secondary btn-block"
to="/create_community"
>
{i18n.t('create_a_community')}
</Link>
</div> </div>
</div> </div>
{this.sidebar()}
{this.landing()} <div class="card bg-transparent border-secondary mb-3">
<div class="card-body">{this.sidebar()}</div>
</div>
<div class="card bg-transparent border-secondary">
<div class="card-body">{this.landing()}</div>
</div>
</div> </div>
)} )}
</div> </div>
); );
} }
createCommunityButton() {
return (
<Link class="btn btn-secondary btn-block" to="/create_community">
{i18n.t('create_a_community')}
</Link>
);
}
trendingCommunities() { trendingCommunities() {
return ( return (
<div> <div>
@ -273,6 +262,38 @@ export class Main extends Component<any, MainState> {
); );
} }
subscribedCommunities() {
return (
UserService.Instance.user &&
this.state.subscribedCommunities.length > 0 && (
<div>
<h5>
<T i18nKey="subscribed_to_communities">
#
<Link class="text-body" to="/communities">
#
</Link>
</T>
</h5>
<ul class="list-inline">
{this.state.subscribedCommunities.map(community => (
<li class="list-inline-item">
<CommunityLink
community={{
name: community.community_name,
id: community.community_id,
local: community.community_local,
actor_id: community.community_actor_id,
}}
/>
</li>
))}
</ul>
</div>
)
);
}
sidebar() { sidebar() {
return ( return (
<div> <div>
@ -305,136 +326,147 @@ export class Main extends Component<any, MainState> {
siteInfo() { siteInfo() {
return ( return (
<div> <div>
<div class="card bg-transparent border-secondary mb-3"> {this.state.siteRes.site.description && this.siteDescription()}
<div class="card-body"> {this.badges()}
<h5 class="mb-0">{`${this.state.siteRes.site.name}`}</h5> {this.admins()}
{this.canAdmin && ( </div>
<ul class="list-inline mb-1 text-muted font-weight-bold"> );
<li className="list-inline-item-action"> }
<span
class="pointer" siteName() {
onClick={linkEvent(this, this.handleEditClick)} return <h5 class="mb-0">{`${this.state.siteRes.site.name}`}</h5>;
data-tippy-content={i18n.t('edit')} }
>
<svg class="icon icon-inline"> admins() {
<use xlinkHref="#icon-edit"></use> return (
</svg> <ul class="mt-1 list-inline small mb-0">
</span> <li class="list-inline-item">{i18n.t('admins')}:</li>
</li> {this.state.siteRes.admins.map(admin => (
</ul> <li class="list-inline-item">
)} <UserListing
<ul class="my-2 list-inline"> user={{
{/* name: admin.name,
avatar: admin.avatar,
local: admin.local,
actor_id: admin.actor_id,
id: admin.id,
}}
/>
</li>
))}
</ul>
);
}
badges() {
return (
<ul class="my-2 list-inline">
{/*
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_online', { count: this.state.siteRes.online })} {i18n.t('number_online', { count: this.state.siteRes.online })}
</li> </li>
*/} */}
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_of_users', { {i18n.t('number_of_users', {
count: this.state.siteRes.site.number_of_users, count: this.state.siteRes.site.number_of_users,
})} })}
</li> </li>
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_of_communities', { {i18n.t('number_of_communities', {
count: this.state.siteRes.site.number_of_communities, count: this.state.siteRes.site.number_of_communities,
})} })}
</li> </li>
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_of_posts', { {i18n.t('number_of_posts', {
count: this.state.siteRes.site.number_of_posts, count: this.state.siteRes.site.number_of_posts,
})} })}
</li> </li>
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_of_comments', { {i18n.t('number_of_comments', {
count: this.state.siteRes.site.number_of_comments, count: this.state.siteRes.site.number_of_comments,
})} })}
</li> </li>
<li className="list-inline-item"> <li className="list-inline-item">
<Link className="badge badge-light" to="/modlog"> <Link className="badge badge-light" to="/modlog">
{i18n.t('modlog')} {i18n.t('modlog')}
</Link> </Link>
</li> </li>
</ul> </ul>
<ul class="mt-1 list-inline small mb-0"> );
<li class="list-inline-item">{i18n.t('admins')}:</li> }
{this.state.siteRes.admins.map(admin => (
<li class="list-inline-item"> adminButtons() {
<UserListing return (
user={{ this.canAdmin && (
name: admin.name, <ul class="list-inline mb-1 text-muted font-weight-bold">
avatar: admin.avatar, <li className="list-inline-item-action">
local: admin.local, <span
actor_id: admin.actor_id, class="pointer"
id: admin.id, onClick={linkEvent(this, this.handleEditClick)}
}} data-tippy-content={i18n.t('edit')}
/> >
</li> <svg class="icon icon-inline">
))} <use xlinkHref="#icon-edit"></use>
</ul> </svg>
</div> </span>
</div> </li>
{this.state.siteRes.site.description && ( </ul>
<div class="card bg-transparent border-secondary mb-3"> )
<div class="card-body"> );
<div }
className="md-div"
dangerouslySetInnerHTML={mdToHtml( siteDescription() {
this.state.siteRes.site.description return (
)} <div
/> className="md-div"
</div> dangerouslySetInnerHTML={mdToHtml(this.state.siteRes.site.description)}
</div> />
)}
</div>
); );
} }
landing() { landing() {
return ( return (
<div class="card bg-transparent border-secondary"> <>
<div class="card-body"> <h5>
<h5> {i18n.t('powered_by')}
{i18n.t('powered_by')} <svg class="icon mx-2">
<svg class="icon mx-2"> <use xlinkHref="#icon-mouse">#</use>
<use xlinkHref="#icon-mouse">#</use> </svg>
</svg> <a href={repoUrl}>
<a href={repoUrl}> Lemmy<sup>beta</sup>
Lemmy<sup>beta</sup> </a>
</a> </h5>
</h5> <p class="mb-0">
<p class="mb-0"> <T i18nKey="landing_0">
<T i18nKey="landing_0"> #
<a href="https://en.wikipedia.org/wiki/Social_network_aggregation">
# #
<a href="https://en.wikipedia.org/wiki/Social_network_aggregation"> </a>
# <a href="https://en.wikipedia.org/wiki/Fediverse">#</a>
</a> <br class="big"></br>
<a href="https://en.wikipedia.org/wiki/Fediverse">#</a> <code>#</code>
<br class="big"></br> <br></br>
<code>#</code> <b>#</b>
<br></br> <br class="big"></br>
<b>#</b> <a href={repoUrl}>#</a>
<br class="big"></br> <br class="big"></br>
<a href={repoUrl}>#</a> <a href="https://www.rust-lang.org">#</a>
<br class="big"></br> <a href="https://actix.rs/">#</a>
<a href="https://www.rust-lang.org">#</a> <a href="https://infernojs.org">#</a>
<a href="https://actix.rs/">#</a> <a href="https://www.typescriptlang.org/">#</a>
<a href="https://infernojs.org">#</a> <br class="big"></br>
<a href="https://www.typescriptlang.org/">#</a> <a href="https://github.com/LemmyNet/lemmy/graphs/contributors?type=a">
<br class="big"></br> #
<a href="https://github.com/LemmyNet/lemmy/graphs/contributors?type=a"> </a>
# </T>
</a> </p>
</T> </>
</p>
</div>
</div>
); );
} }
posts() { posts() {
return ( return (
<div class="main-content-wrapper"> <div class="main-content-wrapper">
{this.selects()}
{this.state.loading ? ( {this.state.loading ? (
<h5> <h5>
<svg class="icon icon-spinner spin"> <svg class="icon icon-spinner spin">
@ -443,6 +475,7 @@ export class Main extends Component<any, MainState> {
</h5> </h5>
) : ( ) : (
<div> <div>
{this.selects()}
{this.listings()} {this.listings()}
{this.paginator()} {this.paginator()}
</div> </div>

View file

@ -312,7 +312,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
<div class="row"> <div class="row">
<div className="col-12"> <div className="col-12">
<div className="post-title"> <div className="post-title">
<h5 className="mb-0 d-inline"> <h5 className="mb-1 d-inline-block">
{this.props.showBody && post.url ? ( {this.props.showBody && post.url ? (
<a <a
className="text-body" className="text-body"
@ -434,7 +434,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</div> </div>
<div class="row"> <div class="row">
<div className="details col-12"> <div className="details col-12">
<ul class="list-inline mb-0 text-muted small"> <ul class="list-inline mb-1 text-muted small">
<li className="list-inline-item"> <li className="list-inline-item">
<span>{i18n.t('by')} </span> <span>{i18n.t('by')} </span>
<UserListing <UserListing
@ -501,9 +501,27 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</li> </li>
</> </>
)} )}
<li className="list-inline-item"></li> </ul>
<ul class="list-inline mb-1 text-muted small">
<li className="list-inline-item">
<Link
className="text-muted"
title={i18n.t('number_of_comments', {
count: post.number_of_comments,
})}
to={`/post/${post.id}`}
>
<svg class="mr-1 icon icon-inline">
<use xlinkHref="#icon-message-square"></use>
</svg>
{i18n.t('number_of_comments', {
count: post.number_of_comments,
})}
</Link>
</li>
{this.state.upvotes !== this.state.score && ( {this.state.upvotes !== this.state.score && (
<> <>
<li className="list-inline-item"></li>
<span <span
class="unselectable pointer mr-2" class="unselectable pointer mr-2"
data-tippy-content={this.pointsTippy} data-tippy-content={this.pointsTippy}
@ -525,23 +543,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</span> </span>
</li> </li>
</span> </span>
<li className="list-inline-item"></li>
</> </>
)} )}
<li className="list-inline-item">
<Link
className="text-muted"
title={i18n.t('number_of_comments', {
count: post.number_of_comments,
})}
to={`/post/${post.id}`}
>
<svg class="mr-1 icon icon-inline">
<use xlinkHref="#icon-message-square"></use>
</svg>
{post.number_of_comments}
</Link>
</li>
</ul> </ul>
{this.props.post.duplicates && ( {this.props.post.duplicates && (
<ul class="list-inline mb-1 small text-muted"> <ul class="list-inline mb-1 small text-muted">

View file

@ -232,7 +232,7 @@ export class Post extends Component<any, PostState> {
sortRadios() { sortRadios() {
return ( return (
<> <>
<div class="btn-group btn-group-toggle mr-3 mb-2"> <div class="btn-group btn-group-toggle flex-wrap mr-3 mb-2">
<label <label
className={`btn btn-outline-secondary pointer ${ className={`btn btn-outline-secondary pointer ${
this.state.commentSort === CommentSortType.Hot && 'active' this.state.commentSort === CommentSortType.Hot && 'active'
@ -286,7 +286,7 @@ export class Post extends Component<any, PostState> {
/> />
</label> </label>
</div> </div>
<div class="btn-group btn-group-toggle mb-2"> <div class="btn-group btn-group-toggle flex-wrap mb-2">
<label <label
className={`btn btn-outline-secondary pointer ${ className={`btn btn-outline-secondary pointer ${
this.state.commentViewType === CommentViewType.Chat && 'active' this.state.commentViewType === CommentViewType.Chat && 'active'

View file

@ -196,14 +196,14 @@ export class Search extends Component<any, SearchState> {
> >
<input <input
type="text" type="text"
class="form-control mr-2" class="form-control mr-2 mb-2"
value={this.state.searchText} value={this.state.searchText}
placeholder={`${i18n.t('search')}...`} placeholder={`${i18n.t('search')}...`}
onInput={linkEvent(this, this.handleQChange)} onInput={linkEvent(this, this.handleQChange)}
required required
minLength={3} minLength={3}
/> />
<button type="submit" class="btn btn-secondary mr-2"> <button type="submit" class="btn btn-secondary mr-2 mb-2">
{this.state.loading ? ( {this.state.loading ? (
<svg class="icon icon-spinner spin"> <svg class="icon icon-spinner spin">
<use xlinkHref="#icon-spinner"></use> <use xlinkHref="#icon-spinner"></use>
@ -222,7 +222,7 @@ export class Search extends Component<any, SearchState> {
<select <select
value={this.state.type_} value={this.state.type_}
onChange={linkEvent(this, this.handleTypeChange)} onChange={linkEvent(this, this.handleTypeChange)}
class="custom-select w-auto" class="custom-select w-auto mb-2"
> >
<option disabled>{i18n.t('type')}</option> <option disabled>{i18n.t('type')}</option>
<option value={SearchType.All}>{i18n.t('all')}</option> <option value={SearchType.All}>{i18n.t('all')}</option>

View file

@ -9,7 +9,7 @@ import {
UserView, UserView,
} from '../interfaces'; } from '../interfaces';
import { WebSocketService, UserService } from '../services'; import { WebSocketService, UserService } from '../services';
import { mdToHtml, getUnixTime, hostname } from '../utils'; import { mdToHtml, getUnixTime } from '../utils';
import { CommunityForm } from './community-form'; import { CommunityForm } from './community-form';
import { UserListing } from './user-listing'; import { UserListing } from './user-listing';
import { CommunityLink } from './community-link'; import { CommunityLink } from './community-link';
@ -63,211 +63,250 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
} }
sidebar() { sidebar() {
let community = this.props.community;
let name_: string, link: string;
if (community.local) {
name_ = community.name;
link = `/c/${community.name}`;
} else {
name_ = `${community.name}@${hostname(community.actor_id)}`;
link = community.actor_id;
}
return ( return (
<div> <div>
<div class="card bg-transparent border-secondary mb-3">
<div class="card-header bg-transparent border-secondary">
{this.communityTitle()}
{this.adminButtons()}
</div>
<div class="card-body">{this.subscribes()}</div>
</div>
<div class="card bg-transparent border-secondary mb-3"> <div class="card bg-transparent border-secondary mb-3">
<div class="card-body"> <div class="card-body">
<h5 className="mb-0"> {this.description()}
<span>{community.title}</span> {this.badges()}
{community.removed && ( {this.mods()}
<small className="ml-2 text-muted font-italic"> </div>
{i18n.t('removed')} </div>
</small> </div>
)} );
{community.deleted && ( }
<small className="ml-2 text-muted font-italic">
{i18n.t('deleted')} communityTitle() {
</small> let community = this.props.community;
)} return (
</h5> <h5 className="mb-2">
<CommunityLink community={community} realLink /> <span>{community.title}</span>
<ul class="list-inline mb-1 text-muted font-weight-bold"> {community.removed && (
{this.canMod && ( <small className="ml-2 text-muted font-italic">
<> {i18n.t('removed')}
<li className="list-inline-item-action"> </small>
<span )}
class="pointer" {community.deleted && (
onClick={linkEvent(this, this.handleEditClick)} <small className="ml-2 text-muted font-italic">
data-tippy-content={i18n.t('edit')} {i18n.t('deleted')}
> </small>
<svg class="icon icon-inline"> )}
<use xlinkHref="#icon-edit"></use> {community.nsfw && (
</svg> <small className="ml-2 text-muted font-italic">
</span> {i18n.t('nsfw')}
</li> </small>
{this.amCreator && ( )}
<li className="list-inline-item-action"> </h5>
<span );
class="pointer" }
onClick={linkEvent(this, this.handleDeleteClick)}
data-tippy-content={ badges() {
!community.deleted let community = this.props.community;
? i18n.t('delete') return (
: i18n.t('restore') <ul class="my-1 list-inline">
} {/*
>
<svg
class={`icon icon-inline ${
community.deleted && 'text-danger'
}`}
>
<use xlinkHref="#icon-trash"></use>
</svg>
</span>
</li>
)}
</>
)}
{this.canAdmin && (
<li className="list-inline-item">
{!this.props.community.removed ? (
<span
class="pointer"
onClick={linkEvent(this, this.handleModRemoveShow)}
>
{i18n.t('remove')}
</span>
) : (
<span
class="pointer"
onClick={linkEvent(this, this.handleModRemoveSubmit)}
>
{i18n.t('restore')}
</span>
)}
</li>
)}
</ul>
{this.state.showRemoveDialog && (
<form onSubmit={linkEvent(this, this.handleModRemoveSubmit)}>
<div class="form-group row">
<label class="col-form-label" htmlFor="remove-reason">
{i18n.t('reason')}
</label>
<input
type="text"
id="remove-reason"
class="form-control mr-2"
placeholder={i18n.t('optional')}
value={this.state.removeReason}
onInput={linkEvent(this, this.handleModRemoveReasonChange)}
/>
</div>
{/* TODO hold off on expires for now */}
{/* <div class="form-group row"> */}
{/* <label class="col-form-label">Expires</label> */}
{/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.removeExpires} onInput={linkEvent(this, this.handleModRemoveExpiresChange)} /> */}
{/* </div> */}
<div class="form-group row">
<button type="submit" class="btn btn-secondary">
{i18n.t('remove_community')}
</button>
</div>
</form>
)}
<ul class="my-1 list-inline">
{/*
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_online', { count: this.props.online })} {i18n.t('number_online', { count: this.props.online })}
</li> </li>
*/} */}
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_of_subscribers', { {i18n.t('number_of_subscribers', {
count: community.number_of_subscribers, count: community.number_of_subscribers,
})} })}
</li> </li>
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_of_posts', { {i18n.t('number_of_posts', {
count: community.number_of_posts, count: community.number_of_posts,
})} })}
</li> </li>
<li className="list-inline-item badge badge-light"> <li className="list-inline-item badge badge-light">
{i18n.t('number_of_comments', { {i18n.t('number_of_comments', {
count: community.number_of_comments, count: community.number_of_comments,
})} })}
</li> </li>
<li className="list-inline-item"> <li className="list-inline-item">
<Link className="badge badge-light" to="/communities"> <Link className="badge badge-light" to="/communities">
{community.category_name} {community.category_name}
</Link> </Link>
</li> </li>
<li className="list-inline-item"> <li className="list-inline-item">
<Link <Link
className="badge badge-light" className="badge badge-light"
to={`/modlog/community/${this.props.community.id}`} to={`/modlog/community/${this.props.community.id}`}
> >
{i18n.t('modlog')} {i18n.t('modlog')}
</Link> </Link>
</li> </li>
</ul> <li className="list-inline-item badge badge-light">
<ul class="list-inline small"> <CommunityLink community={community} realLink />
<li class="list-inline-item">{i18n.t('mods')}: </li> </li>
{this.props.moderators.map(mod => ( </ul>
<li class="list-inline-item"> );
<UserListing }
user={{
name: mod.user_name, mods() {
avatar: mod.avatar, return (
id: mod.user_id, <ul class="list-inline small">
local: mod.user_local, <li class="list-inline-item">{i18n.t('mods')}: </li>
actor_id: mod.user_actor_id, {this.props.moderators.map(mod => (
}} <li class="list-inline-item">
/> <UserListing
</li> user={{
))} name: mod.user_name,
</ul> avatar: mod.avatar,
{/* TODO the to= needs to be able to handle community_ids as well, since they're federated */} id: mod.user_id,
<Link local: mod.user_local,
class={`btn btn-secondary btn-block mb-3 ${ actor_id: mod.user_actor_id,
(community.deleted || community.removed) && 'no-click' }}
}`} />
to={`/create_post?community=${community.name}`} </li>
> ))}
{i18n.t('create_a_post')} </ul>
</Link> );
<div> }
{community.subscribed ? (
<button subscribes() {
class="btn btn-secondary btn-block" let community = this.props.community;
onClick={linkEvent(community.id, this.handleUnsubscribe)} return (
> <div class="d-flex flex-wrap">
{i18n.t('unsubscribe')} <Link
</button> class={`btn btn-secondary flex-fill mr-2 mb-2 ${
) : ( community.deleted || community.removed ? 'no-click' : ''
<button }`}
class="btn btn-secondary btn-block" to={`/create_post?community=${community.name}`}
onClick={linkEvent(community.id, this.handleSubscribe)} >
> {i18n.t('create_a_post')}
{i18n.t('subscribe')} </Link>
</button> {community.subscribed ? (
)} <a
</div> class="btn btn-secondary flex-fill mb-2"
</div> href="#"
</div> onClick={linkEvent(community.id, this.handleUnsubscribe)}
{community.description && ( >
<div class="card bg-transparent border-secondary"> {i18n.t('unsubscribe')}
<div class="card-body"> </a>
<div ) : (
className="md-div" <a
dangerouslySetInnerHTML={mdToHtml(community.description)} class="btn btn-secondary flex-fill mb-2"
/> href="#"
</div> onClick={linkEvent(community.id, this.handleSubscribe)}
</div> >
{i18n.t('subscribe')}
</a>
)} )}
</div> </div>
); );
} }
description() {
let community = this.props.community;
return (
community.description && (
<div
className="md-div"
dangerouslySetInnerHTML={mdToHtml(community.description)}
/>
)
);
}
adminButtons() {
let community = this.props.community;
return (
<>
<ul class="list-inline mb-1 text-muted font-weight-bold">
{this.canMod && (
<>
<li className="list-inline-item-action">
<span
class="pointer"
onClick={linkEvent(this, this.handleEditClick)}
data-tippy-content={i18n.t('edit')}
>
<svg class="icon icon-inline">
<use xlinkHref="#icon-edit"></use>
</svg>
</span>
</li>
{this.amCreator && (
<li className="list-inline-item-action">
<span
class="pointer"
onClick={linkEvent(this, this.handleDeleteClick)}
data-tippy-content={
!community.deleted ? i18n.t('delete') : i18n.t('restore')
}
>
<svg
class={`icon icon-inline ${
community.deleted && 'text-danger'
}`}
>
<use xlinkHref="#icon-trash"></use>
</svg>
</span>
</li>
)}
</>
)}
{this.canAdmin && (
<li className="list-inline-item">
{!this.props.community.removed ? (
<span
class="pointer"
onClick={linkEvent(this, this.handleModRemoveShow)}
>
{i18n.t('remove')}
</span>
) : (
<span
class="pointer"
onClick={linkEvent(this, this.handleModRemoveSubmit)}
>
{i18n.t('restore')}
</span>
)}
</li>
)}
</ul>
{this.state.showRemoveDialog && (
<form onSubmit={linkEvent(this, this.handleModRemoveSubmit)}>
<div class="form-group row">
<label class="col-form-label" htmlFor="remove-reason">
{i18n.t('reason')}
</label>
<input
type="text"
id="remove-reason"
class="form-control mr-2"
placeholder={i18n.t('optional')}
value={this.state.removeReason}
onInput={linkEvent(this, this.handleModRemoveReasonChange)}
/>
</div>
{/* TODO hold off on expires for now */}
{/* <div class="form-group row"> */}
{/* <label class="col-form-label">Expires</label> */}
{/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.removeExpires} onInput={linkEvent(this, this.handleModRemoveExpiresChange)} /> */}
{/* </div> */}
<div class="form-group row">
<button type="submit" class="btn btn-secondary">
{i18n.t('remove_community')}
</button>
</div>
</form>
)}
</>
);
}
handleEditClick(i: Sidebar) { handleEditClick(i: Sidebar) {
i.state.showEdit = true; i.state.showEdit = true;
i.setState(i.state); i.setState(i.state);
@ -293,6 +332,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
} }
handleUnsubscribe(communityId: number) { handleUnsubscribe(communityId: number) {
event.preventDefault();
let form: FollowCommunityForm = { let form: FollowCommunityForm = {
community_id: communityId, community_id: communityId,
follow: false, follow: false,
@ -301,6 +341,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
} }
handleSubscribe(communityId: number) { handleSubscribe(communityId: number) {
event.preventDefault();
let form: FollowCommunityForm = { let form: FollowCommunityForm = {
community_id: communityId, community_id: communityId,
follow: true, follow: true,

View file

@ -35,7 +35,7 @@ export class SortSelect extends Component<SortSelectProps, SortSelectState> {
<select <select
value={this.state.sort} value={this.state.sort}
onChange={linkEvent(this, this.handleSortChange)} onChange={linkEvent(this, this.handleSortChange)}
class="custom-select w-auto mr-2" class="custom-select w-auto mr-2 mb-2"
> >
<option disabled>{i18n.t('sort_type')}</option> <option disabled>{i18n.t('sort_type')}</option>
{!this.props.hideHot && ( {!this.props.hideHot && (

View file

@ -274,7 +274,7 @@ export class User extends Component<any, UserState> {
viewRadios() { viewRadios() {
return ( return (
<div class="btn-group btn-group-toggle"> <div class="btn-group btn-group-toggle flex-wrap mb-2">
<label <label
className={`btn btn-outline-secondary pointer className={`btn btn-outline-secondary pointer
${this.state.view == UserDetailsView.Overview && 'active'} ${this.state.view == UserDetailsView.Overview && 'active'}