Sha256: 3c9b879b05a5fca4b5adca5a3c9ed2191267d9bd05d7150dae2fb926a9dae9fb

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

import * as React from "react";

import Comment from "./comment.component";

import {
  AddCommentFormCommentableFragment,
  AddCommentFormSessionFragment,
  CommentFragment
} from "../support/schema";

const { I18n } = require("react-i18nify");

interface CommentThreadProps {
  comment: CommentFragment;
  session: AddCommentFormSessionFragment & {
    user: any;
  } | null;
  votable?: boolean;
  rootCommentable: AddCommentFormCommentableFragment;
  orderBy: string;
  commentsMaxLength: number;
}

/**
 * Define a collection of comments. It represents a conversation with multiple users.
 * @class
 * @augments Component
 * @todo It doesn't handle multiple comments yet
 */
class CommentThread extends React.Component<CommentThreadProps> {
  public static defaultProps: any = {
    session: null,
    votable: false
  };

  public render() {
    const { comment, session, votable, rootCommentable, orderBy, commentsMaxLength } = this.props;

    return (
      <div>
        {this._renderTitle()}
        <div className="comment-thread">
          <Comment
            comment={comment}
            session={session}
            votable={votable}
            isRootComment={true}
            rootCommentable={rootCommentable}
            orderBy={orderBy}
            commentsMaxLength={commentsMaxLength}
          />
        </div>
      </div>
    );
  }

  /**
   * Render conversation title if comment has commments
   * @private
   * @returns {Void|DOMElement} - The conversation's title
   */
  private _renderTitle() {
    const { comment: { author, hasComments } } = this.props;

    if (hasComments) {
      return (
        <h6 className="comment-thread__title">
          {
            author.deleted ?
              I18n.t("components.comment_thread.title", { authorName: I18n.t("components.comment.deleted_user") }) :
              I18n.t("components.comment_thread.title", { authorName: author.name })
          }
        </h6>
      );
    }

    return null;
  }
}

export default CommentThread;

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-comments-0.23.6 app/frontend/comments/comment_thread.component.tsx
decidim-comments-0.23.5 app/frontend/comments/comment_thread.component.tsx
decidim-comments-0.23.4 app/frontend/comments/comment_thread.component.tsx
decidim-comments-0.23.3 app/frontend/comments/comment_thread.component.tsx
decidim-comments-0.23.2 app/frontend/comments/comment_thread.component.tsx
decidim-comments-0.23.1 app/frontend/comments/comment_thread.component.tsx
decidim-comments-0.23.1.rc1 app/frontend/comments/comment_thread.component.tsx
decidim-comments-0.23.0 app/frontend/comments/comment_thread.component.tsx