Code coverage report for js/sidebar/AttachmentActions.tsx

# All files / js/sidebar AttachmentActions.tsx

45.45% Statements 5/11
0% Branches 0/2
0% Functions 0/2
50% Lines 5/10

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
    441x
    1x

    1x

    1x

    1x
     import React, { memo } from "react";
    import {
      getUrlRecordPath,
      RecordPathDetails,
    } from "../components/RecordComponent";
    import Link from "../components/Link";
    import { RecordInfo } from "../components/types";
    import { trans } from "../i18n";

    function AttachmentActions({
      recordInfo,
      record,
    }: {
      record: RecordPathDetails;
      recordInfo: RecordInfo;
    }) {
      const attachments = recordInfo.attachments;
      return (
        <div className="section">
          <h3>{trans("ATTACHMENTS")}</h3>
          <ul className="nav record-attachments">
            {attachments.length > 0 ? (
              attachments.map((atch) => {
                const urlPath = getUrlRecordPath(atch.path, record.alt);
                return (
                  <li key={atch.id}>
                    <Link to={`${urlPath}/edit`}>
                      {atch.id} ({atch.type})
                    </Link>
                  </li>
                );
              })
            ) : (
              <li key="_missing">
                <em>{trans("NO_ATTACHMENTS")}</em>
              </li>
            )}
          </ul>
        </div>
      );
    }

    export default memo(AttachmentActions);