All files / client/components/PageList Page.tsx

0% Statements 0/5
0% Branches 0/4
0% Functions 0/1
0% Lines 0/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                                                                                       
import React from 'react'
import UserPicture from 'components/User/UserPicture'
import PageListMeta from './PageListMeta'
import PagePath from './PagePath'
import { Page as PageType } from 'client/types/crowi'
 
interface Props {
  page: PageType
  linkTo: string
  excludePathString: string
  isActive: boolean
  children?: React.ReactChild
  onClick?: () => void
}
 
export default class Page extends React.Component<Props> {
  static defaultProps = {
    page: {},
    linkTo: '',
    excludePathString: '',
    isActive: false,
  }
 
  render() {
    const { page, linkTo, excludePathString, isActive, children, ...props } = this.props
    const link = linkTo === '' ? page.path : linkTo
    const active = this.props.isActive ? 'active' : ''
    return (
      <li className={`d-flex flex-row page-list-li ${active}`} {...props}>
        <div className="page-user-picture">
          <UserPicture user={page.revision.author} />
        </div>
        <div className="page-list-link-outer">
          <a className="page-list-link" href={link}>
            <PagePath page={page} excludePathString={excludePathString} />
            <PageListMeta page={page} />
          </a>
        </div>
        {children}
      </li>
    )
  }
}