Compare commits

...

1 commit

2 changed files with 65 additions and 1 deletions

View file

@ -7,9 +7,10 @@ import {
DeleteCommunityForm, DeleteCommunityForm,
RemoveCommunityForm, RemoveCommunityForm,
UserView, UserView,
AddModToCommunityForm,
} from '../interfaces'; } from '../interfaces';
import { WebSocketService, UserService } from '../services'; import { WebSocketService, UserService } from '../services';
import { mdToHtml, getUnixTime, pictrsAvatarThumbnail } 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';
@ -30,6 +31,7 @@ interface SidebarState {
showRemoveDialog: boolean; showRemoveDialog: boolean;
removeReason: string; removeReason: string;
removeExpires: string; removeExpires: string;
showConfirmLeaveModTeam: boolean;
} }
export class Sidebar extends Component<SidebarProps, SidebarState> { export class Sidebar extends Component<SidebarProps, SidebarState> {
@ -38,6 +40,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
showRemoveDialog: false, showRemoveDialog: false,
removeReason: null, removeReason: null,
removeExpires: null, removeExpires: null,
showConfirmLeaveModTeam: false,
}; };
constructor(props: any, context: any) { constructor(props: any, context: any) {
@ -248,6 +251,45 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
</svg> </svg>
</span> </span>
</li> </li>
{!this.amCreator &&
(!this.state.showConfirmLeaveModTeam ? (
<li className="list-inline-item-action">
<span
class="pointer"
onClick={linkEvent(
this,
this.handleShowConfirmLeaveModTeamClick
)}
>
{i18n.t('leave_mod_team')}
</span>
</li>
) : (
<>
<li className="list-inline-item-action">
{i18n.t('are_you_sure')}
</li>
<li className="list-inline-item-action">
<span
class="pointer"
onClick={linkEvent(this, this.handleLeaveModTeamClick)}
>
{i18n.t('yes')}
</span>
</li>
<li className="list-inline-item-action">
<span
class="pointer"
onClick={linkEvent(
this,
this.handleCancelLeaveModTeamClick
)}
>
{i18n.t('no')}
</span>
</li>
</>
))}
{this.amCreator && ( {this.amCreator && (
<li className="list-inline-item-action"> <li className="list-inline-item-action">
<span <span
@ -344,6 +386,27 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
WebSocketService.Instance.deleteCommunity(deleteForm); WebSocketService.Instance.deleteCommunity(deleteForm);
} }
handleShowConfirmLeaveModTeamClick(i: Sidebar) {
i.state.showConfirmLeaveModTeam = true;
i.setState(i.state);
}
handleLeaveModTeamClick(i: Sidebar) {
let form: AddModToCommunityForm = {
user_id: UserService.Instance.user.id,
community_id: i.props.community.id,
added: false,
};
WebSocketService.Instance.addModToCommunity(form);
i.state.showConfirmLeaveModTeam = false;
i.setState(i.state);
}
handleCancelLeaveModTeamClick(i: Sidebar) {
i.state.showConfirmLeaveModTeam = false;
i.setState(i.state);
}
handleUnsubscribe(communityId: number) { handleUnsubscribe(communityId: number) {
event.preventDefault(); event.preventDefault();
let form: FollowCommunityForm = { let form: FollowCommunityForm = {

View file

@ -72,6 +72,7 @@
"site_config": "Site Configuration", "site_config": "Site Configuration",
"remove_as_mod": "remove as mod", "remove_as_mod": "remove as mod",
"appoint_as_mod": "appoint as mod", "appoint_as_mod": "appoint as mod",
"leave_mod_team": "leave mod team",
"modlog": "Modlog", "modlog": "Modlog",
"admin": "admin", "admin": "admin",
"admins": "admins", "admins": "admins",