]> Untitled Git - lemmy.git/blobdiff - ui/src/components/comment-node.tsx
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / ui / src / components / comment-node.tsx
index 524367bcea1892d26e20270109022fc6cfa2b573..1992c4fc846bb9c6d4b1b656c5d8cd90aac2eda1 100644 (file)
@@ -3,8 +3,10 @@ import { Link } from 'inferno-router';
 import {
   CommentNode as CommentNodeI,
   CommentLikeForm,
-  CommentForm as CommentFormI,
-  EditUserMentionForm,
+  DeleteCommentForm,
+  RemoveCommentForm,
+  MarkCommentAsReadForm,
+  MarkUserMentionAsReadForm,
   SaveCommentForm,
   BanFromCommunityForm,
   BanUserForm,
@@ -14,18 +16,15 @@ import {
   AddAdminForm,
   TransferCommunityForm,
   TransferSiteForm,
-  BanType,
-  CommentSortType,
   SortType,
-} from '../interfaces';
+} from 'lemmy-js-client';
+import { CommentSortType, BanType } from '../interfaces';
 import { WebSocketService, UserService } from '../services';
 import {
   mdToHtml,
   getUnixTime,
   canMod,
   isMod,
-  pictshareAvatarThumbnail,
-  showAvatars,
   setupTippy,
   colorList,
 } from '../utils';
@@ -33,6 +32,8 @@ import moment from 'moment';
 import { MomentTime } from './moment-time';
 import { CommentForm } from './comment-form';
 import { CommentNodes } from './comment-nodes';
+import { UserListing } from './user-listing';
+import { CommunityLink } from './community-link';
 import { i18n } from '../i18next';
 
 interface CommentNodeState {
@@ -41,6 +42,7 @@ interface CommentNodeState {
   showRemoveDialog: boolean;
   removeReason: string;
   showBanDialog: boolean;
+  removeData: boolean;
   banReason: string;
   banExpires: string;
   banType: BanType;
@@ -56,14 +58,18 @@ interface CommentNodeState {
   upvotes: number;
   downvotes: number;
   borderColor: string;
+  readLoading: boolean;
+  saveLoading: boolean;
 }
 
 interface CommentNodeProps {
   node: CommentNodeI;
+  noBorder?: boolean;
   noIndent?: boolean;
   viewOnly?: boolean;
   locked?: boolean;
   markable?: boolean;
+  showContext?: boolean;
   moderators: Array<CommunityUser>;
   admins: Array<UserView>;
   // TODO is this necessary, can't I get it from the node itself?
@@ -71,6 +77,7 @@ interface CommentNodeProps {
   showCommunity?: boolean;
   sort?: CommentSortType;
   sortType?: SortType;
+  enableDownvotes: boolean;
 }
 
 export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
@@ -80,6 +87,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     showRemoveDialog: false,
     removeReason: null,
     showBanDialog: false,
+    removeData: null,
     banReason: null,
     banExpires: null,
     banType: BanType.Community,
@@ -97,6 +105,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     borderColor: this.props.node.comment.depth
       ? colorList[this.props.node.comment.depth % colorList.length]
       : colorList[0],
+    readLoading: false,
+    saveLoading: false,
   };
 
   constructor(props: any, context: any) {
@@ -113,6 +123,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     this.state.upvotes = nextProps.node.comment.upvotes;
     this.state.downvotes = nextProps.node.comment.downvotes;
     this.state.score = nextProps.node.comment.score;
+    this.state.readLoading = false;
+    this.state.saveLoading = false;
     this.setState(this.state);
   }
 
@@ -121,20 +133,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     return (
       <div
         className={`comment ${
-          node.comment.parent_id && !this.props.noIndent ? 'ml-2' : ''
+          node.comment.parent_id && !this.props.noIndent ? 'ml-1' : ''
         }`}
       >
-        {!node.comment.parent_id && !this.props.noIndent && (
-          <>
-            <hr class="d-sm-none my-2" />
-            <div class="d-none d-sm-block d-sm-none my-3" />
-          </>
-        )}
         <div
           id={`comment-${node.comment.id}`}
-          className={`details comment-node mb-1 ${
-            this.isCommentNew ? 'mark' : ''
-          }`}
+          className={`details comment-node py-2 ${
+            !this.props.noBorder ? 'border-top border-light' : ''
+          } ${this.isCommentNew ? 'mark' : ''}`}
           style={
             !this.props.noIndent &&
             this.props.node.comment.parent_id &&
@@ -142,101 +148,104 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
           }
         >
           <div
-            class={`${!this.props.noIndent &&
+            class={`${
+              !this.props.noIndent &&
               this.props.node.comment.parent_id &&
-              'ml-2'}`}
+              'ml-2'
+            }`}
           >
-            <ul class="list-inline mb-1 text-muted small">
-              <li className="list-inline-item">
-                <Link
-                  className="text-body font-weight-bold"
-                  to={`/u/${node.comment.creator_name}`}
-                >
-                  {node.comment.creator_avatar && showAvatars() && (
-                    <img
-                      height="32"
-                      width="32"
-                      src={pictshareAvatarThumbnail(
-                        node.comment.creator_avatar
-                      )}
-                      class="rounded-circle mr-1"
-                    />
-                  )}
-                  <span>{node.comment.creator_name}</span>
-                </Link>
-              </li>
+            <div class="d-flex flex-wrap align-items-center text-muted small">
+              <span class="mr-2">
+                <UserListing
+                  user={{
+                    name: node.comment.creator_name,
+                    preferred_username: node.comment.creator_preferred_username,
+                    avatar: node.comment.creator_avatar,
+                    id: node.comment.creator_id,
+                    local: node.comment.creator_local,
+                    actor_id: node.comment.creator_actor_id,
+                    published: node.comment.creator_published,
+                  }}
+                />
+              </span>
+
               {this.isMod && (
-                <li className="list-inline-item badge badge-light">
+                <div className="badge badge-light d-none d-sm-inline mr-2">
                   {i18n.t('mod')}
-                </li>
+                </div>
               )}
               {this.isAdmin && (
-                <li className="list-inline-item badge badge-light">
+                <div className="badge badge-light d-none d-sm-inline mr-2">
                   {i18n.t('admin')}
-                </li>
+                </div>
               )}
               {this.isPostCreator && (
-                <li className="list-inline-item badge badge-light">
+                <div className="badge badge-light d-none d-sm-inline mr-2">
                   {i18n.t('creator')}
-                </li>
+                </div>
               )}
               {(node.comment.banned_from_community || node.comment.banned) && (
-                <li className="list-inline-item badge badge-danger">
+                <div className="badge badge-danger mr-2">
                   {i18n.t('banned')}
-                </li>
+                </div>
               )}
               {this.props.showCommunity && (
-                <li className="list-inline-item">
-                  <span> {i18n.t('to')} </span>
-                  <Link to={`/c/${node.comment.community_name}`}>
-                    {node.comment.community_name}
+                <>
+                  <span class="mx-1">{i18n.t('to')}</span>
+                  <CommunityLink
+                    community={{
+                      name: node.comment.community_name,
+                      id: node.comment.community_id,
+                      local: node.comment.community_local,
+                      actor_id: node.comment.community_actor_id,
+                      icon: node.comment.community_icon,
+                    }}
+                  />
+                  <span class="mx-2">•</span>
+                  <Link class="mr-2" to={`/post/${node.comment.post_id}`}>
+                    {node.comment.post_name}
                   </Link>
-                </li>
+                </>
               )}
-              <li className="list-inline-item">•</li>
-              <li className="list-inline-item">
-                <span
-                  className={`unselectable pointer ${this.scoreColor}`}
-                  onClick={linkEvent(node, this.handleCommentUpvote)}
-                  data-tippy-content={i18n.t('number_of_points', {
-                    count: this.state.score,
-                  })}
-                >
-                  <svg class="icon icon-inline mr-1">
-                    <use xlinkHref="#icon-zap"></use>
+              <button
+                class="btn text-muted"
+                onClick={linkEvent(this, this.handleCommentCollapse)}
+              >
+                {this.state.collapsed ? (
+                  <svg class="icon icon-inline">
+                    <use xlinkHref="#icon-plus-square"></use>
                   </svg>
-                  {this.state.score}
-                </span>
-              </li>
-              <li className="list-inline-item">•</li>
-              <li className="list-inline-item">
-                <span>
-                  <MomentTime data={node.comment} />
-                </span>
-              </li>
-              <li className="list-inline-item">
-                <div
-                  className="unselectable pointer text-monospace"
-                  onClick={linkEvent(this, this.handleCommentCollapse)}
-                >
-                  {this.state.collapsed ? (
-                    <svg class="icon icon-inline">
-                      <use xlinkHref="#icon-plus-square"></use>
-                    </svg>
-                  ) : (
-                    <svg class="icon icon-inline">
-                      <use xlinkHref="#icon-minus-square"></use>
-                    </svg>
-                  )}
-                </div>
-              </li>
-            </ul>
+                ) : (
+                  <svg class="icon icon-inline">
+                    <use xlinkHref="#icon-minus-square"></use>
+                  </svg>
+                )}
+              </button>
+              {/* This is an expanding spacer for mobile */}
+              <div className="mr-lg-4 flex-grow-1 flex-lg-grow-0 unselectable pointer mx-2"></div>
+              <button
+                className={`btn p-0 unselectable pointer ${this.scoreColor}`}
+                onClick={linkEvent(node, this.handleCommentUpvote)}
+                data-tippy-content={this.pointsTippy}
+              >
+                <svg class="icon icon-inline mr-1">
+                  <use xlinkHref="#icon-zap"></use>
+                </svg>
+                <span class="mr-1">{this.state.score}</span>
+              </button>
+              <span className="mr-1">•</span>
+              <span>
+                <MomentTime data={node.comment} />
+              </span>
+            </div>
+            {/* end of user row */}
             {this.state.showEdit && (
               <CommentForm
                 node={node}
                 edit
                 onReplyCancel={this.handleReplyCancel}
                 disabled={this.props.locked}
+                focus
               />
             )}
             {!this.state.showEdit && !this.state.collapsed && (
@@ -251,106 +260,88 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
                     )}
                   />
                 )}
-                <ul class="list-inline mb-0 text-muted font-weight-bold h5">
+                <div class="d-flex justify-content-between justify-content-lg-start flex-wrap text-muted font-weight-bold">
+                  {this.props.showContext && this.linkBtn}
                   {this.props.markable && (
-                    <li className="list-inline-item-action">
-                      <span
-                        class="pointer"
-                        onClick={linkEvent(this, this.handleMarkRead)}
-                        data-tippy-content={
-                          node.comment.read
-                            ? i18n.t('mark_as_unread')
-                            : i18n.t('mark_as_read')
-                        }
-                      >
+                    <button
+                      class="btn btn-link btn-animate text-muted"
+                      onClick={linkEvent(this, this.handleMarkRead)}
+                      data-tippy-content={
+                        node.comment.read
+                          ? i18n.t('mark_as_unread')
+                          : i18n.t('mark_as_read')
+                      }
+                    >
+                      {this.state.readLoading ? (
+                        this.loadingIcon
+                      ) : (
                         <svg
-                          class={`icon icon-inline ${node.comment.read &&
-                            'text-success'}`}
+                          class={`icon icon-inline ${
+                            node.comment.read && 'text-success'
+                          }`}
                         >
                           <use xlinkHref="#icon-check"></use>
                         </svg>
-                      </span>
-                    </li>
+                      )}
+                    </button>
                   )}
                   {UserService.Instance.user && !this.props.viewOnly && (
                     <>
-                      <li className="list-inline-item-action">
+                      <button
+                        className={`btn btn-link btn-animate ${
+                          this.state.my_vote == 1 ? 'text-info' : 'text-muted'
+                        }`}
+                        onClick={linkEvent(node, this.handleCommentUpvote)}
+                        data-tippy-content={i18n.t('upvote')}
+                      >
+                        <svg class="icon icon-inline">
+                          <use xlinkHref="#icon-arrow-up"></use>
+                        </svg>
+                        {this.state.upvotes !== this.state.score && (
+                          <span class="ml-1">{this.state.upvotes}</span>
+                        )}
+                      </button>
+                      {this.props.enableDownvotes && (
                         <button
-                          className={`vote-animate btn btn-link p-0 mb-1 ${
-                            this.state.my_vote == 1 ? 'text-info' : 'text-muted'
+                          className={`btn btn-link btn-animate ${
+                            this.state.my_vote == -1
+                              ? 'text-danger'
+                              : 'text-muted'
                           }`}
-                          onClick={linkEvent(node, this.handleCommentUpvote)}
-                          data-tippy-content={i18n.t('upvote')}
+                          onClick={linkEvent(node, this.handleCommentDownvote)}
+                          data-tippy-content={i18n.t('downvote')}
                         >
                           <svg class="icon icon-inline">
-                            <use xlinkHref="#icon-arrow-up"></use>
+                            <use xlinkHref="#icon-arrow-down"></use>
                           </svg>
                           {this.state.upvotes !== this.state.score && (
-                            <span class="ml-1">{this.state.upvotes}</span>
+                            <span class="ml-1">{this.state.downvotes}</span>
                           )}
                         </button>
-                      </li>
-                      {WebSocketService.Instance.site.enable_downvotes && (
-                        <li className="list-inline-item-action">
-                          <button
-                            className={`vote-animate btn btn-link p-0 mb-1 ${
-                              this.state.my_vote == -1
-                                ? 'text-danger'
-                                : 'text-muted'
-                            }`}
-                            onClick={linkEvent(
-                              node,
-                              this.handleCommentDownvote
-                            )}
-                            data-tippy-content={i18n.t('downvote')}
-                          >
-                            <svg class="icon icon-inline">
-                              <use xlinkHref="#icon-arrow-down"></use>
-                            </svg>
-                            {this.state.upvotes !== this.state.score && (
-                              <span class="ml-1">{this.state.downvotes}</span>
-                            )}
-                          </button>
-                        </li>
                       )}
-                      <li className="list-inline-item-action">
-                        <span
-                          class="pointer"
-                          onClick={linkEvent(this, this.handleReplyClick)}
-                          data-tippy-content={i18n.t('reply')}
-                        >
-                          <svg class="icon icon-inline">
-                            <use xlinkHref="#icon-reply1"></use>
-                          </svg>
-                        </span>
-                      </li>
-                      <li className="list-inline-item-action">
-                        <Link
-                          className="text-muted"
-                          to={`/post/${node.comment.post_id}/comment/${node.comment.id}`}
-                          title={i18n.t('link')}
+                      <button
+                        class="btn btn-link btn-animate text-muted"
+                        onClick={linkEvent(this, this.handleReplyClick)}
+                        data-tippy-content={i18n.t('reply')}
+                      >
+                        <svg class="icon icon-inline">
+                          <use xlinkHref="#icon-reply1"></use>
+                        </svg>
+                      </button>
+                      {!this.state.showAdvanced ? (
+                        <button
+                          className="btn btn-link btn-animate text-muted"
+                          onClick={linkEvent(this, this.handleShowAdvanced)}
+                          data-tippy-content={i18n.t('more')}
                         >
                           <svg class="icon icon-inline">
-                            <use xlinkHref="#icon-link"></use>
+                            <use xlinkHref="#icon-more-vertical"></use>
                           </svg>
-                        </Link>
-                      </li>
-                      {!this.state.showAdvanced ? (
-                        <li className="list-inline-item-action">
-                          <span
-                            className="unselectable pointer"
-                            onClick={linkEvent(this, this.handleShowAdvanced)}
-                            data-tippy-content={i18n.t('more')}
-                          >
-                            <svg class="icon icon-inline">
-                              <use xlinkHref="#icon-more-vertical"></use>
-                            </svg>
-                          </span>
-                        </li>
+                        </button>
                       ) : (
                         <>
                           {!this.myComment && (
-                            <li className="list-inline-item-action">
+                            <button class="btn btn-link btn-animate">
                               <Link
                                 class="text-muted"
                                 to={`/create_private_message?recipient_id=${node.comment.creator_id}`}
@@ -360,340 +351,322 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
                                   <use xlinkHref="#icon-mail"></use>
                                 </svg>
                               </Link>
-                            </li>
+                            </button>
                           )}
-                          <li className="list-inline-item-action">
-                            <span
-                              class="pointer"
-                              onClick={linkEvent(
-                                this,
-                                this.handleSaveCommentClick
-                              )}
-                              data-tippy-content={
-                                node.comment.saved
-                                  ? i18n.t('unsave')
-                                  : i18n.t('save')
-                              }
-                            >
+                          {!this.props.showContext && this.linkBtn}
+                          <button
+                            class="btn btn-link btn-animate text-muted"
+                            onClick={linkEvent(
+                              this,
+                              this.handleSaveCommentClick
+                            )}
+                            data-tippy-content={
+                              node.comment.saved
+                                ? i18n.t('unsave')
+                                : i18n.t('save')
+                            }
+                          >
+                            {this.state.saveLoading ? (
+                              this.loadingIcon
+                            ) : (
                               <svg
-                                class={`icon icon-inline ${node.comment.saved &&
-                                  'text-warning'}`}
+                                class={`icon icon-inline ${
+                                  node.comment.saved && 'text-warning'
+                                }`}
                               >
                                 <use xlinkHref="#icon-star"></use>
                               </svg>
-                            </span>
-                          </li>
-                          <li className="list-inline-item-action">
-                            <span
-                              className="pointer"
-                              onClick={linkEvent(this, this.handleViewSource)}
-                              data-tippy-content={i18n.t('view_source')}
+                            )}
+                          </button>
+                          <button
+                            className="btn btn-link btn-animate text-muted"
+                            onClick={linkEvent(this, this.handleViewSource)}
+                            data-tippy-content={i18n.t('view_source')}
+                          >
+                            <svg
+                              class={`icon icon-inline ${
+                                this.state.viewSource && 'text-success'
+                              }`}
                             >
-                              <svg
-                                class={`icon icon-inline ${this.state
-                                  .viewSource && 'text-success'}`}
-                              >
-                                <use xlinkHref="#icon-file-text"></use>
-                              </svg>
-                            </span>
-                          </li>
+                              <use xlinkHref="#icon-file-text"></use>
+                            </svg>
+                          </button>
                           {this.myComment && (
                             <>
-                              <li className="list-inline-item-action">•</li>
-                              <li className="list-inline-item-action">
-                                <span
-                                  class="pointer"
+                              <button
+                                class="btn btn-link btn-animate text-muted"
+                                onClick={linkEvent(this, this.handleEditClick)}
+                                data-tippy-content={i18n.t('edit')}
+                              >
+                                <svg class="icon icon-inline">
+                                  <use xlinkHref="#icon-edit"></use>
+                                </svg>
+                              </button>
+                              <button
+                                class="btn btn-link btn-animate text-muted"
+                                onClick={linkEvent(
+                                  this,
+                                  this.handleDeleteClick
+                                )}
+                                data-tippy-content={
+                                  !node.comment.deleted
+                                    ? i18n.t('delete')
+                                    : i18n.t('restore')
+                                }
+                              >
+                                <svg
+                                  class={`icon icon-inline ${
+                                    node.comment.deleted && 'text-danger'
+                                  }`}
+                                >
+                                  <use xlinkHref="#icon-trash"></use>
+                                </svg>
+                              </button>
+                            </>
+                          )}
+                          {/* Admins and mods can remove comments */}
+                          {(this.canMod || this.canAdmin) && (
+                            <>
+                              {!node.comment.removed ? (
+                                <button
+                                  class="btn btn-link btn-animate text-muted"
                                   onClick={linkEvent(
                                     this,
-                                    this.handleEditClick
+                                    this.handleModRemoveShow
                                   )}
-                                  data-tippy-content={i18n.t('edit')}
                                 >
-                                  <svg class="icon icon-inline">
-                                    <use xlinkHref="#icon-edit"></use>
-                                  </svg>
-                                </span>
-                              </li>
-                              <li className="list-inline-item-action">
-                                <span
-                                  class="pointer"
+                                  {i18n.t('remove')}
+                                </button>
+                              ) : (
+                                <button
+                                  class="btn btn-link btn-animate text-muted"
                                   onClick={linkEvent(
                                     this,
-                                    this.handleDeleteClick
+                                    this.handleModRemoveSubmit
                                   )}
-                                  data-tippy-content={
-                                    !node.comment.deleted
-                                      ? i18n.t('delete')
-                                      : i18n.t('restore')
-                                  }
                                 >
-                                  <svg
-                                    class={`icon icon-inline ${node.comment
-                                      .deleted && 'text-danger'}`}
-                                  >
-                                    <use xlinkHref="#icon-trash"></use>
-                                  </svg>
-                                </span>
-                              </li>
+                                  {i18n.t('restore')}
+                                </button>
+                              )}
                             </>
                           )}
-                          {/* Admins and mods can remove comments */}
-                          {(this.canMod || this.canAdmin) && (
+                          {/* Mods can ban from community, and appoint as mods to community */}
+                          {this.canMod && (
                             <>
-                              <li className="list-inline-item-action">
-                                {!node.comment.removed ? (
-                                  <span
-                                    class="pointer"
+                              {!this.isMod &&
+                                (!node.comment.banned_from_community ? (
+                                  <button
+                                    class="btn btn-link btn-animate text-muted"
                                     onClick={linkEvent(
                                       this,
-                                      this.handleModRemoveShow
+                                      this.handleModBanFromCommunityShow
                                     )}
                                   >
-                                    {i18n.t('remove')}
-                                  </span>
+                                    {i18n.t('ban')}
+                                  </button>
                                 ) : (
-                                  <span
-                                    class="pointer"
+                                  <button
+                                    class="btn btn-link btn-animate text-muted"
                                     onClick={linkEvent(
                                       this,
-                                      this.handleModRemoveSubmit
+                                      this.handleModBanFromCommunitySubmit
                                     )}
                                   >
-                                    {i18n.t('restore')}
-                                  </span>
-                                )}
-                              </li>
-                            </>
-                          )}
-                          {/* Mods can ban from community, and appoint as mods to community */}
-                          {this.canMod && (
-                            <>
-                              {!this.isMod && (
-                                <li className="list-inline-item-action">
-                                  {!node.comment.banned_from_community ? (
-                                    <span
-                                      class="pointer"
-                                      onClick={linkEvent(
-                                        this,
-                                        this.handleModBanFromCommunityShow
-                                      )}
-                                    >
-                                      {i18n.t('ban')}
-                                    </span>
-                                  ) : (
-                                    <span
-                                      class="pointer"
-                                      onClick={linkEvent(
-                                        this,
-                                        this.handleModBanFromCommunitySubmit
-                                      )}
-                                    >
-                                      {i18n.t('unban')}
-                                    </span>
-                                  )}
-                                </li>
-                              )}
-                              {!node.comment.banned_from_community && (
-                                <li className="list-inline-item-action">
-                                  {!this.state.showConfirmAppointAsMod ? (
-                                    <span
-                                      class="pointer"
-                                      onClick={linkEvent(
-                                        this,
-                                        this.handleShowConfirmAppointAsMod
-                                      )}
-                                    >
-                                      {this.isMod
-                                        ? i18n.t('remove_as_mod')
-                                        : i18n.t('appoint_as_mod')}
-                                    </span>
-                                  ) : (
-                                    <>
-                                      <span class="d-inline-block mr-1">
-                                        {i18n.t('are_you_sure')}
-                                      </span>
-                                      <span
-                                        class="pointer d-inline-block mr-1"
-                                        onClick={linkEvent(
-                                          this,
-                                          this.handleAddModToCommunity
-                                        )}
-                                      >
-                                        {i18n.t('yes')}
-                                      </span>
-                                      <span
-                                        class="pointer d-inline-block"
-                                        onClick={linkEvent(
-                                          this,
-                                          this.handleCancelConfirmAppointAsMod
-                                        )}
-                                      >
-                                        {i18n.t('no')}
-                                      </span>
-                                    </>
-                                  )}
-                                </li>
-                              )}
-                            </>
-                          )}
-                          {/* Community creators and admins can transfer community to another mod */}
-                          {(this.amCommunityCreator || this.canAdmin) &&
-                            this.isMod && (
-                              <li className="list-inline-item-action">
-                                {!this.state.showConfirmTransferCommunity ? (
-                                  <span
-                                    class="pointer"
+                                    {i18n.t('unban')}
+                                  </button>
+                                ))}
+                              {!node.comment.banned_from_community &&
+                                node.comment.creator_local &&
+                                (!this.state.showConfirmAppointAsMod ? (
+                                  <button
+                                    class="btn btn-link btn-animate text-muted"
                                     onClick={linkEvent(
                                       this,
-                                      this.handleShowConfirmTransferCommunity
+                                      this.handleShowConfirmAppointAsMod
                                     )}
                                   >
-                                    {i18n.t('transfer_community')}
-                                  </span>
+                                    {this.isMod
+                                      ? i18n.t('remove_as_mod')
+                                      : i18n.t('appoint_as_mod')}
+                                  </button>
                                 ) : (
                                   <>
-                                    <span class="d-inline-block mr-1">
+                                    <button class="btn btn-link btn-animate text-muted">
                                       {i18n.t('are_you_sure')}
-                                    </span>
-                                    <span
-                                      class="pointer d-inline-block mr-1"
+                                    </button>
+                                    <button
+                                      class="btn btn-link btn-animate text-muted"
                                       onClick={linkEvent(
                                         this,
-                                        this.handleTransferCommunity
+                                        this.handleAddModToCommunity
                                       )}
                                     >
                                       {i18n.t('yes')}
-                                    </span>
-                                    <span
-                                      class="pointer d-inline-block"
+                                    </button>
+                                    <button
+                                      class="btn btn-link btn-animate text-muted"
                                       onClick={linkEvent(
                                         this,
-                                        this
-                                          .handleCancelShowConfirmTransferCommunity
+                                        this.handleCancelConfirmAppointAsMod
                                       )}
                                     >
                                       {i18n.t('no')}
-                                    </span>
+                                    </button>
                                   </>
+                                ))}
+                            </>
+                          )}
+                          {/* Community creators and admins can transfer community to another mod */}
+                          {(this.amCommunityCreator || this.canAdmin) &&
+                            this.isMod &&
+                            node.comment.creator_local &&
+                            (!this.state.showConfirmTransferCommunity ? (
+                              <button
+                                class="btn btn-link btn-animate text-muted"
+                                onClick={linkEvent(
+                                  this,
+                                  this.handleShowConfirmTransferCommunity
                                 )}
-                              </li>
-                            )}
+                              >
+                                {i18n.t('transfer_community')}
+                              </button>
+                            ) : (
+                              <>
+                                <button class="btn btn-link btn-animate text-muted">
+                                  {i18n.t('are_you_sure')}
+                                </button>
+                                <button
+                                  class="btn btn-link btn-animate text-muted"
+                                  onClick={linkEvent(
+                                    this,
+                                    this.handleTransferCommunity
+                                  )}
+                                >
+                                  {i18n.t('yes')}
+                                </button>
+                                <button
+                                  class="btn btn-link btn-animate text-muted"
+                                  onClick={linkEvent(
+                                    this,
+                                    this
+                                      .handleCancelShowConfirmTransferCommunity
+                                  )}
+                                >
+                                  {i18n.t('no')}
+                                </button>
+                              </>
+                            ))}
                           {/* Admins can ban from all, and appoint other admins */}
                           {this.canAdmin && (
                             <>
-                              {!this.isAdmin && (
-                                <li className="list-inline-item-action">
-                                  {!node.comment.banned ? (
-                                    <span
-                                      class="pointer"
-                                      onClick={linkEvent(
-                                        this,
-                                        this.handleModBanShow
-                                      )}
-                                    >
-                                      {i18n.t('ban_from_site')}
-                                    </span>
-                                  ) : (
-                                    <span
-                                      class="pointer"
+                              {!this.isAdmin &&
+                                (!node.comment.banned ? (
+                                  <button
+                                    class="btn btn-link btn-animate text-muted"
+                                    onClick={linkEvent(
+                                      this,
+                                      this.handleModBanShow
+                                    )}
+                                  >
+                                    {i18n.t('ban_from_site')}
+                                  </button>
+                                ) : (
+                                  <button
+                                    class="btn btn-link btn-animate text-muted"
+                                    onClick={linkEvent(
+                                      this,
+                                      this.handleModBanSubmit
+                                    )}
+                                  >
+                                    {i18n.t('unban_from_site')}
+                                  </button>
+                                ))}
+                              {!node.comment.banned &&
+                                node.comment.creator_local &&
+                                (!this.state.showConfirmAppointAsAdmin ? (
+                                  <button
+                                    class="btn btn-link btn-animate text-muted"
+                                    onClick={linkEvent(
+                                      this,
+                                      this.handleShowConfirmAppointAsAdmin
+                                    )}
+                                  >
+                                    {this.isAdmin
+                                      ? i18n.t('remove_as_admin')
+                                      : i18n.t('appoint_as_admin')}
+                                  </button>
+                                ) : (
+                                  <>
+                                    <button class="btn btn-link btn-animate text-muted">
+                                      {i18n.t('are_you_sure')}
+                                    </button>
+                                    <button
+                                      class="btn btn-link btn-animate text-muted"
                                       onClick={linkEvent(
                                         this,
-                                        this.handleModBanSubmit
+                                        this.handleAddAdmin
                                       )}
                                     >
-                                      {i18n.t('unban_from_site')}
-                                    </span>
-                                  )}
-                                </li>
-                              )}
-                              {!node.comment.banned && (
-                                <li className="list-inline-item-action">
-                                  {!this.state.showConfirmAppointAsAdmin ? (
-                                    <span
-                                      class="pointer"
+                                      {i18n.t('yes')}
+                                    </button>
+                                    <button
+                                      class="btn btn-link btn-animate text-muted"
                                       onClick={linkEvent(
                                         this,
-                                        this.handleShowConfirmAppointAsAdmin
+                                        this.handleCancelConfirmAppointAsAdmin
                                       )}
                                     >
-                                      {this.isAdmin
-                                        ? i18n.t('remove_as_admin')
-                                        : i18n.t('appoint_as_admin')}
-                                    </span>
-                                  ) : (
-                                    <>
-                                      <span class="d-inline-block mr-1">
-                                        {i18n.t('are_you_sure')}
-                                      </span>
-                                      <span
-                                        class="pointer d-inline-block mr-1"
-                                        onClick={linkEvent(
-                                          this,
-                                          this.handleAddAdmin
-                                        )}
-                                      >
-                                        {i18n.t('yes')}
-                                      </span>
-                                      <span
-                                        class="pointer d-inline-block"
-                                        onClick={linkEvent(
-                                          this,
-                                          this.handleCancelConfirmAppointAsAdmin
-                                        )}
-                                      >
-                                        {i18n.t('no')}
-                                      </span>
-                                    </>
-                                  )}
-                                </li>
-                              )}
+                                      {i18n.t('no')}
+                                    </button>
+                                  </>
+                                ))}
                             </>
                           )}
                           {/* Site Creator can transfer to another admin */}
-                          {this.amSiteCreator && this.isAdmin && (
-                            <li className="list-inline-item-action">
-                              {!this.state.showConfirmTransferSite ? (
-                                <span
-                                  class="pointer"
+                          {this.amSiteCreator &&
+                            this.isAdmin &&
+                            node.comment.creator_local &&
+                            (!this.state.showConfirmTransferSite ? (
+                              <button
+                                class="btn btn-link btn-animate text-muted"
+                                onClick={linkEvent(
+                                  this,
+                                  this.handleShowConfirmTransferSite
+                                )}
+                              >
+                                {i18n.t('transfer_site')}
+                              </button>
+                            ) : (
+                              <>
+                                <button class="btn btn-link btn-animate text-muted">
+                                  {i18n.t('are_you_sure')}
+                                </button>
+                                <button
+                                  class="btn btn-link btn-animate text-muted"
                                   onClick={linkEvent(
                                     this,
-                                    this.handleShowConfirmTransferSite
+                                    this.handleTransferSite
                                   )}
                                 >
-                                  {i18n.t('transfer_site')}
-                                </span>
-                              ) : (
-                                <>
-                                  <span class="d-inline-block mr-1">
-                                    {i18n.t('are_you_sure')}
-                                  </span>
-                                  <span
-                                    class="pointer d-inline-block mr-1"
-                                    onClick={linkEvent(
-                                      this,
-                                      this.handleTransferSite
-                                    )}
-                                  >
-                                    {i18n.t('yes')}
-                                  </span>
-                                  <span
-                                    class="pointer d-inline-block"
-                                    onClick={linkEvent(
-                                      this,
-                                      this.handleCancelShowConfirmTransferSite
-                                    )}
-                                  >
-                                    {i18n.t('no')}
-                                  </span>
-                                </>
-                              )}
-                            </li>
-                          )}
+                                  {i18n.t('yes')}
+                                </button>
+                                <button
+                                  class="btn btn-link btn-animate text-muted"
+                                  onClick={linkEvent(
+                                    this,
+                                    this.handleCancelShowConfirmTransferSite
+                                  )}
+                                >
+                                  {i18n.t('no')}
+                                </button>
+                              </>
+                            ))}
                         </>
                       )}
                     </>
                   )}
-                </ul>
+                </div>
+                {/* end of button group */}
               </div>
             )}
           </div>
@@ -727,6 +700,20 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
                 value={this.state.banReason}
                 onInput={linkEvent(this, this.handleModBanReasonChange)}
               />
+              <div class="form-group">
+                <div class="form-check">
+                  <input
+                    class="form-check-input"
+                    id="mod-ban-remove-data"
+                    type="checkbox"
+                    checked={this.state.removeData}
+                    onChange={linkEvent(this, this.handleModRemoveDataChange)}
+                  />
+                  <label class="form-check-label" htmlFor="mod-ban-remove-data">
+                    {i18n.t('remove_posts_comments')}
+                  </label>
+                </div>
+              </div>
             </div>
             {/* TODO hold off on expires until later */}
             {/* <div class="form-group row"> */}
@@ -745,6 +732,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
             node={node}
             onReplyCancel={this.handleReplyCancel}
             disabled={this.props.locked}
+            focus
           />
         )}
         {node.children && !this.state.collapsed && (
@@ -756,6 +744,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
             postCreatorId={this.props.postCreatorId}
             sort={this.props.sort}
             sortType={this.props.sortType}
+            enableDownvotes={this.props.enableDownvotes}
           />
         )}
         {/* A collapsed clearfix */}
@@ -764,6 +753,29 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     );
   }
 
+  get linkBtn() {
+    let node = this.props.node;
+    return (
+      <Link
+        class="btn btn-link btn-animate text-muted"
+        to={`/post/${node.comment.post_id}/comment/${node.comment.id}`}
+        title={this.props.showContext ? i18n.t('show_context') : i18n.t('link')}
+      >
+        <svg class="icon icon-inline">
+          <use xlinkHref="#icon-link"></use>
+        </svg>
+      </Link>
+    );
+  }
+
+  get loadingIcon() {
+    return (
+      <svg class="icon icon-spinner spin">
+        <use xlinkHref="#icon-spinner"></use>
+      </svg>
+    );
+  }
+
   get myComment(): boolean {
     return (
       UserService.Instance.user &&
@@ -860,16 +872,12 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
   }
 
   handleDeleteClick(i: CommentNode) {
-    let deleteForm: CommentFormI = {
-      content: i.props.node.comment.content,
+    let deleteForm: DeleteCommentForm = {
       edit_id: i.props.node.comment.id,
-      creator_id: i.props.node.comment.creator_id,
-      post_id: i.props.node.comment.post_id,
-      parent_id: i.props.node.comment.parent_id,
       deleted: !i.props.node.comment.deleted,
       auth: null,
     };
-    WebSocketService.Instance.editComment(deleteForm);
+    WebSocketService.Instance.deleteComment(deleteForm);
   }
 
   handleSaveCommentClick(i: CommentNode) {
@@ -883,6 +891,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     };
 
     WebSocketService.Instance.saveComment(form);
+
+    i.state.saveLoading = true;
+    i.setState(this.state);
   }
 
   handleReplyCancel() {
@@ -910,12 +921,12 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
 
     let form: CommentLikeForm = {
       comment_id: i.comment.id,
-      post_id: i.comment.post_id,
       score: this.state.my_vote,
     };
 
     WebSocketService.Instance.likeComment(form);
     this.setState(this.state);
+    setupTippy();
   }
 
   handleCommentDownvote(i: CommentNodeI) {
@@ -937,12 +948,12 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
 
     let form: CommentLikeForm = {
       comment_id: i.comment.id,
-      post_id: i.comment.post_id,
       score: this.state.my_vote,
     };
 
     WebSocketService.Instance.likeComment(form);
     this.setState(this.state);
+    setupTippy();
   }
 
   handleModRemoveShow(i: CommentNode) {
@@ -955,19 +966,20 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     i.setState(i.state);
   }
 
+  handleModRemoveDataChange(i: CommentNode, event: any) {
+    i.state.removeData = event.target.checked;
+    i.setState(i.state);
+  }
+
   handleModRemoveSubmit(i: CommentNode) {
     event.preventDefault();
-    let form: CommentFormI = {
-      content: i.props.node.comment.content,
+    let form: RemoveCommentForm = {
       edit_id: i.props.node.comment.id,
-      creator_id: i.props.node.comment.creator_id,
-      post_id: i.props.node.comment.post_id,
-      parent_id: i.props.node.comment.parent_id,
       removed: !i.props.node.comment.removed,
       reason: i.state.removeReason,
       auth: null,
     };
-    WebSocketService.Instance.editComment(form);
+    WebSocketService.Instance.removeComment(form);
 
     i.state.showRemoveDialog = false;
     i.setState(i.state);
@@ -976,23 +988,22 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
   handleMarkRead(i: CommentNode) {
     // if it has a user_mention_id field, then its a mention
     if (i.props.node.comment.user_mention_id) {
-      let form: EditUserMentionForm = {
+      let form: MarkUserMentionAsReadForm = {
         user_mention_id: i.props.node.comment.user_mention_id,
         read: !i.props.node.comment.read,
       };
-      WebSocketService.Instance.editUserMention(form);
+      WebSocketService.Instance.markUserMentionAsRead(form);
     } else {
-      let form: CommentFormI = {
-        content: i.props.node.comment.content,
+      let form: MarkCommentAsReadForm = {
         edit_id: i.props.node.comment.id,
-        creator_id: i.props.node.comment.creator_id,
-        post_id: i.props.node.comment.post_id,
-        parent_id: i.props.node.comment.parent_id,
         read: !i.props.node.comment.read,
         auth: null,
       };
-      WebSocketService.Instance.editComment(form);
+      WebSocketService.Instance.markCommentAsRead(form);
     }
+
+    i.state.readLoading = true;
+    i.setState(this.state);
   }
 
   handleModBanFromCommunityShow(i: CommentNode) {
@@ -1033,18 +1044,30 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     event.preventDefault();
 
     if (i.state.banType == BanType.Community) {
+      // If its an unban, restore all their data
+      let ban = !i.props.node.comment.banned_from_community;
+      if (ban == false) {
+        i.state.removeData = false;
+      }
       let form: BanFromCommunityForm = {
         user_id: i.props.node.comment.creator_id,
         community_id: i.props.node.comment.community_id,
-        ban: !i.props.node.comment.banned_from_community,
+        ban,
+        remove_data: i.state.removeData,
         reason: i.state.banReason,
         expires: getUnixTime(i.state.banExpires),
       };
       WebSocketService.Instance.banFromCommunity(form);
     } else {
+      // If its an unban, restore all their data
+      let ban = !i.props.node.comment.banned;
+      if (ban == false) {
+        i.state.removeData = false;
+      }
       let form: BanUserForm = {
         user_id: i.props.node.comment.creator_id,
-        ban: !i.props.node.comment.banned,
+        ban,
+        remove_data: i.state.removeData,
         reason: i.state.banReason,
         expires: getUnixTime(i.state.banExpires),
       };
@@ -1166,4 +1189,20 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
       return 'text-muted';
     }
   }
+
+  get pointsTippy(): string {
+    let points = i18n.t('number_of_points', {
+      count: this.state.score,
+    });
+
+    let upvotes = i18n.t('number_of_upvotes', {
+      count: this.state.upvotes,
+    });
+
+    let downvotes = i18n.t('number_of_downvotes', {
+      count: this.state.downvotes,
+    });
+
+    return `${points} • ${upvotes} • ${downvotes}`;
+  }
 }