+
{titleText}
+ Existing moderators:
+
+
+
+ {hasMods ? null : (
+
{i18n('noModeratorsToRemove')}
+ )}
+
+
+
+
+
+ );
+ }
+
+ private onClickOK() {
+ const removedMods = this.state.modList
+ .filter(d => !d.checkmarked)
+ .map(d => d.id);
+
+ if (removedMods.length > 0) {
+ this.props.onSubmit(removedMods);
+ }
+
+ this.closeDialog();
+ }
+
+ private onKeyUp(event: any) {
+ switch (event.key) {
+ case 'Enter':
+ this.onClickOK();
+ break;
+ case 'Esc':
+ case 'Escape':
+ this.closeDialog();
+ break;
+ default:
+ }
+ }
+
+ private closeDialog() {
+ window.removeEventListener('keyup', this.onKeyUp);
+
+ this.props.onClose();
+ }
+
+ private onModClicked(selected: any) {
+ const updatedFriends = this.state.modList.map(member => {
+ if (member.id === selected.id) {
+ return { ...member, checkmarked: !member.checkmarked };
+ } else {
+ return member;
+ }
+ });
+
+ this.setState(state => {
+ return {
+ ...state,
+ modList: updatedFriends,
+ };
+ });
+ }
+}