2023-06-14 12:20:40 +00:00
|
|
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
2023-06-16 15:00:01 +00:00
|
|
|
import { T } from "inferno-i18next-dess";
|
2021-02-22 02:39:04 +00:00
|
|
|
import { Link } from "inferno-router";
|
2020-09-06 16:15:25 +00:00
|
|
|
import {
|
2021-07-17 20:42:55 +00:00
|
|
|
AddModToCommunity,
|
2022-07-30 03:38:37 +00:00
|
|
|
BlockCommunity,
|
2020-12-24 01:58:27 +00:00
|
|
|
CommunityModeratorView,
|
2021-07-17 20:42:55 +00:00
|
|
|
CommunityView,
|
2020-12-24 01:58:27 +00:00
|
|
|
DeleteCommunity,
|
2023-06-14 12:20:40 +00:00
|
|
|
EditCommunity,
|
2021-07-17 20:42:55 +00:00
|
|
|
FollowCommunity,
|
2022-12-19 15:57:29 +00:00
|
|
|
Language,
|
2023-05-11 18:32:32 +00:00
|
|
|
PersonView,
|
2022-06-23 19:44:05 +00:00
|
|
|
PurgeCommunity,
|
2021-07-17 20:42:55 +00:00
|
|
|
RemoveCommunity,
|
2021-02-22 02:39:04 +00:00
|
|
|
} from "lemmy-js-client";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { i18n } from "../../i18next";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { UserService } from "../../services";
|
2021-09-18 16:35:49 +00:00
|
|
|
import {
|
2022-06-21 21:42:29 +00:00
|
|
|
amAdmin,
|
|
|
|
amMod,
|
|
|
|
amTopMod,
|
2021-09-18 16:35:49 +00:00
|
|
|
getUnixTime,
|
2023-05-03 16:09:47 +00:00
|
|
|
hostname,
|
2021-09-18 16:35:49 +00:00
|
|
|
mdToHtml,
|
2023-06-14 12:20:40 +00:00
|
|
|
myAuthRequired,
|
2021-09-18 16:35:49 +00:00
|
|
|
} from "../../utils";
|
2023-06-16 22:31:47 +00:00
|
|
|
import { Badges } from "../common/badges";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { BannerIconHeader } from "../common/banner-icon-header";
|
2022-06-23 19:44:05 +00:00
|
|
|
import { Icon, PurgeWarning, Spinner } from "../common/icon";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { CommunityForm } from "../community/community-form";
|
|
|
|
import { CommunityLink } from "../community/community-link";
|
|
|
|
import { PersonListing } from "../person/person-listing";
|
2020-09-06 16:15:25 +00:00
|
|
|
|
|
|
|
interface SidebarProps {
|
2020-12-24 01:58:27 +00:00
|
|
|
community_view: CommunityView;
|
|
|
|
moderators: CommunityModeratorView[];
|
2023-05-11 18:32:32 +00:00
|
|
|
admins: PersonView[];
|
2022-12-19 15:57:29 +00:00
|
|
|
allLanguages: Language[];
|
|
|
|
siteLanguages: number[];
|
2023-01-04 16:56:24 +00:00
|
|
|
communityLanguages?: number[];
|
2022-06-21 21:42:29 +00:00
|
|
|
enableNsfw?: boolean;
|
2020-09-06 16:15:25 +00:00
|
|
|
showIcon?: boolean;
|
2022-12-19 15:57:29 +00:00
|
|
|
editable?: boolean;
|
2023-06-14 12:20:40 +00:00
|
|
|
onDeleteCommunity(form: DeleteCommunity): void;
|
|
|
|
onRemoveCommunity(form: RemoveCommunity): void;
|
|
|
|
onLeaveModTeam(form: AddModToCommunity): void;
|
|
|
|
onFollowCommunity(form: FollowCommunity): void;
|
|
|
|
onBlockCommunity(form: BlockCommunity): void;
|
|
|
|
onPurgeCommunity(form: PurgeCommunity): void;
|
|
|
|
onEditCommunity(form: EditCommunity): void;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface SidebarState {
|
2023-01-04 16:56:24 +00:00
|
|
|
removeReason?: string;
|
|
|
|
removeExpires?: string;
|
2020-09-06 16:15:25 +00:00
|
|
|
showEdit: boolean;
|
|
|
|
showRemoveDialog: boolean;
|
2022-06-23 19:44:05 +00:00
|
|
|
showPurgeDialog: boolean;
|
2023-01-04 16:56:24 +00:00
|
|
|
purgeReason?: string;
|
2020-09-06 16:15:25 +00:00
|
|
|
showConfirmLeaveModTeam: boolean;
|
2023-06-14 12:20:40 +00:00
|
|
|
deleteCommunityLoading: boolean;
|
|
|
|
removeCommunityLoading: boolean;
|
|
|
|
leaveModTeamLoading: boolean;
|
|
|
|
followCommunityLoading: boolean;
|
|
|
|
purgeCommunityLoading: boolean;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Sidebar extends Component<SidebarProps, SidebarState> {
|
2023-01-04 16:56:24 +00:00
|
|
|
state: SidebarState = {
|
2020-09-06 16:15:25 +00:00
|
|
|
showEdit: false,
|
|
|
|
showRemoveDialog: false,
|
2022-06-23 19:44:05 +00:00
|
|
|
showPurgeDialog: false,
|
2020-09-06 16:15:25 +00:00
|
|
|
showConfirmLeaveModTeam: false,
|
2023-06-14 12:20:40 +00:00
|
|
|
deleteCommunityLoading: false,
|
|
|
|
removeCommunityLoading: false,
|
|
|
|
leaveModTeamLoading: false,
|
|
|
|
followCommunityLoading: false,
|
|
|
|
purgeCommunityLoading: false,
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
this.handleEditCancel = this.handleEditCancel.bind(this);
|
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
componentWillReceiveProps(
|
|
|
|
nextProps: Readonly<{ children?: InfernoNode } & SidebarProps>
|
|
|
|
): void {
|
|
|
|
if (this.props.moderators != nextProps.moderators) {
|
|
|
|
this.setState({
|
|
|
|
showConfirmLeaveModTeam: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.props.community_view != nextProps.community_view) {
|
|
|
|
this.setState({
|
|
|
|
showEdit: false,
|
|
|
|
showPurgeDialog: false,
|
|
|
|
showRemoveDialog: false,
|
|
|
|
deleteCommunityLoading: false,
|
|
|
|
removeCommunityLoading: false,
|
|
|
|
leaveModTeamLoading: false,
|
|
|
|
followCommunityLoading: false,
|
|
|
|
purgeCommunityLoading: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{!this.state.showEdit ? (
|
|
|
|
this.sidebar()
|
|
|
|
) : (
|
|
|
|
<CommunityForm
|
2023-01-04 16:56:24 +00:00
|
|
|
community_view={this.props.community_view}
|
2022-12-19 15:57:29 +00:00
|
|
|
allLanguages={this.props.allLanguages}
|
|
|
|
siteLanguages={this.props.siteLanguages}
|
|
|
|
communityLanguages={this.props.communityLanguages}
|
2023-06-14 12:20:40 +00:00
|
|
|
onUpsertCommunity={this.props.onEditCommunity}
|
2020-09-06 16:15:25 +00:00
|
|
|
onCancel={this.handleEditCancel}
|
|
|
|
enableNsfw={this.props.enableNsfw}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sidebar() {
|
2023-05-03 16:09:47 +00:00
|
|
|
const myUSerInfo = UserService.Instance.myUserInfo;
|
|
|
|
const { name, actor_id } = this.props.community_view.community;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2023-06-16 21:56:06 +00:00
|
|
|
<aside className="mb-3">
|
|
|
|
<div id="sidebarContainer">
|
|
|
|
<section id="sidebarMain" className="card border-secondary mb-3">
|
|
|
|
<div className="card-body">
|
|
|
|
{this.communityTitle()}
|
|
|
|
{this.props.editable && this.adminButtons()}
|
|
|
|
{myUSerInfo && this.subscribe()}
|
|
|
|
{this.canPost && this.createPost()}
|
|
|
|
{myUSerInfo && this.blockCommunity()}
|
|
|
|
{!myUSerInfo && (
|
|
|
|
<div className="alert alert-info" role="alert">
|
|
|
|
<T
|
|
|
|
i18nKey="community_not_logged_in_alert"
|
|
|
|
interpolation={{
|
|
|
|
community: name,
|
|
|
|
instance: hostname(actor_id),
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
#<code className="user-select-all">#</code>#
|
|
|
|
</T>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section id="sidebarInfo" className="card border-secondary mb-3">
|
|
|
|
<div className="card-body">
|
|
|
|
{this.description()}
|
2023-06-17 00:35:44 +00:00
|
|
|
<Badges
|
|
|
|
community_view={this.props.community_view}
|
|
|
|
counts={this.props.community_view.counts}
|
|
|
|
/>
|
2023-06-16 21:56:06 +00:00
|
|
|
{this.mods()}
|
|
|
|
</div>
|
|
|
|
</section>
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
2023-06-16 21:56:06 +00:00
|
|
|
</aside>
|
2020-09-06 16:15:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
communityTitle() {
|
2023-06-05 21:31:12 +00:00
|
|
|
const community = this.props.community_view.community;
|
|
|
|
const subscribed = this.props.community_view.subscribed;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h5 className="mb-0">
|
2023-03-27 02:10:35 +00:00
|
|
|
{this.props.showIcon && !community.removed && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<BannerIconHeader icon={community.icon} banner={community.banner} />
|
|
|
|
)}
|
2023-06-13 10:34:21 +00:00
|
|
|
<span className="mr-2">
|
|
|
|
<CommunityLink community={community} hideAvatar />
|
|
|
|
</span>
|
2023-05-11 18:32:32 +00:00
|
|
|
{subscribed === "Subscribed" && (
|
2022-07-30 03:38:37 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-secondary btn-sm mr-2"
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleUnfollowCommunity)}
|
2020-09-23 23:01:45 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.followCommunityLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<Icon icon="check" classes="icon-inline text-success mr-1" />
|
|
|
|
{i18n.t("joined")}
|
|
|
|
</>
|
|
|
|
)}
|
2022-07-30 03:38:37 +00:00
|
|
|
</button>
|
2020-09-23 23:01:45 +00:00
|
|
|
)}
|
2023-05-11 18:32:32 +00:00
|
|
|
{subscribed === "Pending" && (
|
2022-07-30 03:38:37 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-warning mr-2"
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleUnfollowCommunity)}
|
2022-07-11 18:07:47 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.followCommunityLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
i18n.t("subscribe_pending")
|
|
|
|
)}
|
2022-07-30 03:38:37 +00:00
|
|
|
</button>
|
2022-06-23 13:35:53 +00:00
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
{community.removed && (
|
2020-09-23 23:01:45 +00:00
|
|
|
<small className="mr-2 text-muted font-italic">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("removed")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{community.deleted && (
|
2020-09-23 23:01:45 +00:00
|
|
|
<small className="mr-2 text-muted font-italic">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("deleted")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{community.nsfw && (
|
2020-09-23 23:01:45 +00:00
|
|
|
<small className="mr-2 text-muted font-italic">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("nsfw")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
</h5>
|
|
|
|
<CommunityLink
|
|
|
|
community={community}
|
|
|
|
realLink
|
|
|
|
useApubName
|
|
|
|
muted
|
|
|
|
hideAvatar
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
mods() {
|
|
|
|
return (
|
2022-09-22 15:03:35 +00:00
|
|
|
<ul className="list-inline small">
|
|
|
|
<li className="list-inline-item">{i18n.t("mods")}: </li>
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.props.moderators.map(mod => (
|
2022-09-22 15:03:35 +00:00
|
|
|
<li key={mod.moderator.id} className="list-inline-item">
|
2021-03-15 18:09:31 +00:00
|
|
|
<PersonListing person={mod.moderator} />
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:01:45 +00:00
|
|
|
createPost() {
|
2023-06-05 21:31:12 +00:00
|
|
|
const cv = this.props.community_view;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2022-09-21 14:04:57 +00:00
|
|
|
<Link
|
|
|
|
className={`btn btn-secondary btn-block mb-2 ${
|
|
|
|
cv.community.deleted || cv.community.removed ? "no-click" : ""
|
|
|
|
}`}
|
2023-04-15 14:47:10 +00:00
|
|
|
to={`/create_post?communityId=${cv.community.id}`}
|
2022-09-21 14:04:57 +00:00
|
|
|
>
|
|
|
|
{i18n.t("create_a_post")}
|
|
|
|
</Link>
|
2020-09-23 23:01:45 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
subscribe() {
|
2023-06-05 21:31:12 +00:00
|
|
|
const community_view = this.props.community_view;
|
2020-09-23 23:01:45 +00:00
|
|
|
return (
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="mb-2">
|
2023-05-11 18:32:32 +00:00
|
|
|
{community_view.subscribed == "NotSubscribed" && (
|
2022-09-21 14:04:57 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-secondary btn-block"
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleFollowCommunity)}
|
2022-09-21 14:04:57 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.followCommunityLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
i18n.t("subscribe")
|
|
|
|
)}
|
2022-09-21 14:04:57 +00:00
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
blockCommunity() {
|
2023-06-16 17:01:09 +00:00
|
|
|
const { subscribed, blocked } = this.props.community_view;
|
2022-09-21 14:04:57 +00:00
|
|
|
|
|
|
|
return (
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="mb-2">
|
2023-06-16 17:01:09 +00:00
|
|
|
{subscribed == "NotSubscribed" && (
|
|
|
|
<button
|
|
|
|
className="btn btn-danger btn-block"
|
|
|
|
onClick={linkEvent(this, this.handleBlockCommunity)}
|
|
|
|
>
|
|
|
|
{i18n.t(blocked ? "unblock_community" : "block_community")}
|
|
|
|
</button>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
description() {
|
2023-06-05 21:31:12 +00:00
|
|
|
const desc = this.props.community_view.community.description;
|
2023-01-04 16:56:24 +00:00
|
|
|
return (
|
|
|
|
desc && (
|
2022-06-21 21:42:29 +00:00
|
|
|
<div className="md-div" dangerouslySetInnerHTML={mdToHtml(desc)} />
|
2023-01-04 16:56:24 +00:00
|
|
|
)
|
|
|
|
);
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
adminButtons() {
|
2023-06-05 21:31:12 +00:00
|
|
|
const community_view = this.props.community_view;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<>
|
2022-09-22 15:03:35 +00:00
|
|
|
<ul className="list-inline mb-1 text-muted font-weight-bold">
|
2023-01-04 16:56:24 +00:00
|
|
|
{amMod(this.props.moderators) && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<>
|
|
|
|
<li className="list-inline-item-action">
|
2021-07-17 20:42:55 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2020-09-06 16:15:25 +00:00
|
|
|
onClick={linkEvent(this, this.handleEditClick)}
|
2021-02-22 02:39:04 +00:00
|
|
|
data-tippy-content={i18n.t("edit")}
|
|
|
|
aria-label={i18n.t("edit")}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="edit" classes="icon-inline" />
|
2021-07-17 20:42:55 +00:00
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
2023-01-04 16:56:24 +00:00
|
|
|
{!amTopMod(this.props.moderators) &&
|
2020-09-06 16:15:25 +00:00
|
|
|
(!this.state.showConfirmLeaveModTeam ? (
|
|
|
|
<li className="list-inline-item-action">
|
2021-07-17 20:42:55 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2020-09-06 16:15:25 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleShowConfirmLeaveModTeamClick
|
|
|
|
)}
|
|
|
|
>
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("leave_mod_team")}
|
2021-07-17 20:42:55 +00:00
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<li className="list-inline-item-action">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("are_you_sure")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
<li className="list-inline-item-action">
|
2021-07-17 20:42:55 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleLeaveModTeam)}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("yes")}
|
2021-07-17 20:42:55 +00:00
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
<li className="list-inline-item-action">
|
2021-07-17 20:42:55 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2020-09-06 16:15:25 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleCancelLeaveModTeamClick
|
|
|
|
)}
|
|
|
|
>
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("no")}
|
2021-07-17 20:42:55 +00:00
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
</>
|
|
|
|
))}
|
2023-01-04 16:56:24 +00:00
|
|
|
{amTopMod(this.props.moderators) && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<li className="list-inline-item-action">
|
2021-07-17 20:42:55 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleDeleteCommunity)}
|
2020-09-06 16:15:25 +00:00
|
|
|
data-tippy-content={
|
2020-12-24 01:58:27 +00:00
|
|
|
!community_view.community.deleted
|
2021-02-22 02:39:04 +00:00
|
|
|
? i18n.t("delete")
|
|
|
|
: i18n.t("restore")
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
2021-02-06 20:20:41 +00:00
|
|
|
aria-label={
|
|
|
|
!community_view.community.deleted
|
2021-02-22 02:39:04 +00:00
|
|
|
? i18n.t("delete")
|
|
|
|
: i18n.t("restore")
|
2021-02-06 20:20:41 +00:00
|
|
|
}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.deleteCommunityLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon
|
|
|
|
icon="trash"
|
|
|
|
classes={`icon-inline ${
|
|
|
|
community_view.community.deleted && "text-danger"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
)}{" "}
|
2021-07-17 20:42:55 +00:00
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
2022-09-28 12:50:47 +00:00
|
|
|
{amAdmin() && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<li className="list-inline-item">
|
2020-12-24 01:58:27 +00:00
|
|
|
{!this.props.community_view.community.removed ? (
|
2021-07-17 20:42:55 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2020-09-06 16:15:25 +00:00
|
|
|
onClick={linkEvent(this, this.handleModRemoveShow)}
|
|
|
|
>
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("remove")}
|
2021-07-17 20:42:55 +00:00
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
) : (
|
2021-07-17 20:42:55 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleRemoveCommunity)}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.removeCommunityLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
i18n.t("restore")
|
|
|
|
)}
|
2021-07-17 20:42:55 +00:00
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
)}
|
2022-06-23 19:44:05 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link text-muted d-inline-block"
|
2022-06-23 19:44:05 +00:00
|
|
|
onClick={linkEvent(this, this.handlePurgeCommunityShow)}
|
|
|
|
aria-label={i18n.t("purge_community")}
|
|
|
|
>
|
|
|
|
{i18n.t("purge_community")}
|
|
|
|
</button>
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
{this.state.showRemoveDialog && (
|
2023-06-14 12:20:40 +00:00
|
|
|
<form onSubmit={linkEvent(this, this.handleRemoveCommunity)}>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group">
|
|
|
|
<label className="col-form-label" htmlFor="remove-reason">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("reason")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="remove-reason"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-control mr-2"
|
2021-02-22 02:39:04 +00:00
|
|
|
placeholder={i18n.t("optional")}
|
2023-01-04 16:56:24 +00:00
|
|
|
value={this.state.removeReason}
|
2020-09-06 16:15:25 +00:00
|
|
|
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> */}
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group">
|
|
|
|
<button type="submit" className="btn btn-secondary">
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.removeCommunityLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
i18n.t("remove_community")
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
)}
|
2022-06-23 19:44:05 +00:00
|
|
|
{this.state.showPurgeDialog && (
|
2023-06-14 12:20:40 +00:00
|
|
|
<form onSubmit={linkEvent(this, this.handlePurgeCommunity)}>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group">
|
2022-06-23 19:44:05 +00:00
|
|
|
<PurgeWarning />
|
|
|
|
</div>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group">
|
|
|
|
<label className="sr-only" htmlFor="purge-reason">
|
2022-06-23 19:44:05 +00:00
|
|
|
{i18n.t("reason")}
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="purge-reason"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-control mr-2"
|
2022-06-23 19:44:05 +00:00
|
|
|
placeholder={i18n.t("reason")}
|
2023-01-04 16:56:24 +00:00
|
|
|
value={this.state.purgeReason}
|
2022-06-23 19:44:05 +00:00
|
|
|
onInput={linkEvent(this, this.handlePurgeReasonChange)}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group">
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.purgeCommunityLoading ? (
|
2022-06-23 19:44:05 +00:00
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<button
|
|
|
|
type="submit"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-secondary"
|
2022-06-23 19:44:05 +00:00
|
|
|
aria-label={i18n.t("purge_community")}
|
|
|
|
>
|
|
|
|
{i18n.t("purge_community")}
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleEditClick(i: Sidebar) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showEdit: true });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleEditCancel() {
|
2022-09-22 15:03:35 +00:00
|
|
|
this.setState({ showEdit: false });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleShowConfirmLeaveModTeamClick(i: Sidebar) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showConfirmLeaveModTeam: true });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleCancelLeaveModTeamClick(i: Sidebar) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showConfirmLeaveModTeam: false });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 19:22:15 +00:00
|
|
|
get canPost(): boolean {
|
|
|
|
return (
|
|
|
|
!this.props.community_view.community.posting_restricted_to_mods ||
|
2023-01-04 16:56:24 +00:00
|
|
|
amMod(this.props.moderators) ||
|
2022-09-28 12:50:47 +00:00
|
|
|
amAdmin()
|
2022-05-23 19:22:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
handleModRemoveShow(i: Sidebar) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showRemoveDialog: true });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveReasonChange(i: Sidebar, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ removeReason: event.target.value });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveExpiresChange(i: Sidebar, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ removeExpires: event.target.value });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-06-23 19:44:05 +00:00
|
|
|
handlePurgeCommunityShow(i: Sidebar) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showPurgeDialog: true, showRemoveDialog: false });
|
2022-06-23 19:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handlePurgeReasonChange(i: Sidebar, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ purgeReason: event.target.value });
|
2022-06-23 19:44:05 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
// TODO Do we need two of these?
|
|
|
|
handleUnfollowCommunity(i: Sidebar) {
|
|
|
|
i.setState({ followCommunityLoading: true });
|
|
|
|
i.props.onFollowCommunity({
|
|
|
|
community_id: i.props.community_view.community.id,
|
|
|
|
follow: false,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleFollowCommunity(i: Sidebar) {
|
|
|
|
i.setState({ followCommunityLoading: true });
|
|
|
|
i.props.onFollowCommunity({
|
|
|
|
community_id: i.props.community_view.community.id,
|
|
|
|
follow: true,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleBlockCommunity(i: Sidebar) {
|
2023-06-16 17:01:09 +00:00
|
|
|
const { community, blocked } = i.props.community_view;
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
i.props.onBlockCommunity({
|
2023-06-16 17:01:09 +00:00
|
|
|
community_id: community.id,
|
|
|
|
block: !blocked,
|
2023-06-14 12:20:40 +00:00
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
}
|
2022-06-23 19:44:05 +00:00
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
handleLeaveModTeam(i: Sidebar) {
|
|
|
|
const myId = UserService.Instance.myUserInfo?.local_user_view.person.id;
|
|
|
|
if (myId) {
|
|
|
|
i.setState({ leaveModTeamLoading: true });
|
|
|
|
i.props.onLeaveModTeam({
|
2023-01-04 16:56:24 +00:00
|
|
|
community_id: i.props.community_view.community.id,
|
2023-06-14 12:20:40 +00:00
|
|
|
person_id: 92,
|
|
|
|
added: false,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2023-01-04 16:56:24 +00:00
|
|
|
}
|
2022-06-23 19:44:05 +00:00
|
|
|
}
|
2022-07-30 03:38:37 +00:00
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
handleDeleteCommunity(i: Sidebar) {
|
|
|
|
i.setState({ deleteCommunityLoading: true });
|
|
|
|
i.props.onDeleteCommunity({
|
|
|
|
community_id: i.props.community_view.community.id,
|
|
|
|
deleted: !i.props.community_view.community.deleted,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleRemoveCommunity(i: Sidebar, event: any) {
|
2022-07-30 03:38:37 +00:00
|
|
|
event.preventDefault();
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ removeCommunityLoading: true });
|
|
|
|
i.props.onRemoveCommunity({
|
|
|
|
community_id: i.props.community_view.community.id,
|
|
|
|
removed: !i.props.community_view.community.removed,
|
|
|
|
reason: i.state.removeReason,
|
|
|
|
expires: getUnixTime(i.state.removeExpires), // TODO fix this
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2022-07-30 03:38:37 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
handlePurgeCommunity(i: Sidebar, event: any) {
|
2022-07-30 03:38:37 +00:00
|
|
|
event.preventDefault();
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ purgeCommunityLoading: true });
|
|
|
|
i.props.onPurgeCommunity({
|
|
|
|
community_id: i.props.community_view.community.id,
|
|
|
|
reason: i.state.purgeReason,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2022-07-30 03:38:37 +00:00
|
|
|
}
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|