All files / src/emptystate/CommonEmptyState CommonEmptyState.js

100% Statements 5/5
53.84% Branches 14/26
100% Functions 1/1
100% Lines 5/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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84                                              7x 7x 7x                                                                                                 15x   15x              
import React, { Component } from 'react';
import { defaultProps } from './props/defaultProps';
import { propTypes } from './props/propTypes';
import Link from '../../Link/Link';
import style from './CommonEmptyState.module.css';
export default class CommonEmptyState extends Component {
  render() {
    let {
      title,
      description,
      linkDescription,
      linkUrl,
      linkText,
      linkTarget,
      onUrlClick,
      getEmptyState,
      className,
      dataId,
      isFluid,
      children,
      size,
      palette,
      customClass
    } = this.props;
    let { titleClass = '', descriptionClass = '' } = customClass;
    return (
      <div
        className={`${style.container} ${style[size]} ${className} ${!isFluid ? style.fluid : ''} ${style[palette]}`}
        data-id={dataId}
        data-test-id={dataId}
      >
        {getEmptyState ? getEmptyState() : null}
 
        {title ? <div tabIndex='0' className={`${style.title} ${titleClass}`}>{title}</div> : null}
 
        {description ? (
          <div className={style.linkWrapper}>
            <span className={`${style.desc} ${descriptionClass}`}>{description}</span>
            {!linkDescription && linkText ? (
              <Link
                href={linkUrl}
                className={style.link}
                target={linkTarget}
                onClick={onUrlClick}
                dataId={`${dataId}_primarylink`}
              >
                {linkText}
              </Link>
            ) : null}
          </div>
        ) : null}
 
        {linkDescription || (!description && !linkDescription && linkText) ? (
          <div className={style.linkDescWrapper}>
            {linkDescription ? <span className={`${style.linkDesc}`}>{linkDescription}</span> : null}
            {linkText ? (
              <Link
                href={linkUrl}
                className={style.link}
                target={linkTarget}
                onClick={onUrlClick}
                dataId={`${dataId}_secondarylink`}
              >
                {linkText}
              </Link>
            ) : null}
          </div>
        ) : null}
        {children ? <div className={style.children}>{children}</div> : null}
      </div>
    );
  }
}
 
CommonEmptyState.propTypes = propTypes;
 
CommonEmptyState.defaultProps = defaultProps;
 
// if (__DOCS__) {
//   CommonEmptyState.docs = {
//     componentGroup: 'EmptyState'
//   };
// }