All files / publisher/pages/RegisterSnap RegistrationError.tsx

90.9% Statements 10/11
90% Branches 9/10
100% Functions 1/1
90.9% Lines 10/11

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                      5x 1x                           4x 1x                     3x 1x                         2x 1x               1x 1x                      
import { Link } from "react-router-dom";
import { Notification } from "@canonical/react-components";
 
type Props = {
  errorCode: string;
  snapName: string;
  isPrivate: string;
  store: string;
};
 
function RegistrationError({ snapName, errorCode, isPrivate, store }: Props) {
  if (errorCode === "name-review-required") {
    return (
      <Notification severity="caution">
        All snap names are currently subject to a review. Please see{" "}
        <a href="https://forum.snapcraft.io/t/manual-review-of-all-new-snap-name-registrations/39440">
          https://forum.snapcraft.io/t/manual-review-of-all-new-snap-name-registrations/39440
        </a>{" "}
        for details. Follow this link to submit a name request for your snap:
        <a href="https://dashboard.snapcraft.io/register-snap">
          https://dashboard.snapcraft.io/register-snap
        </a>
      </Notification>
    );
  }
 
  if (errorCode === "already_owned") {
    return (
      <Notification severity="information">
        You already own '
        <Link to={`/${snapName}/listing`}>
          <strong>{snapName}</strong>
        </Link>
        '.
      </Notification>
    );
  }
 
  if (errorCode === "reserved_name") {
    return (
      <Notification severity="information">
        '<strong>{snapName}</strong>' is reserved. You can{" "}
        <Link
          to={`/request-reserved-name?snap_name=${snapName}&store=${store}&is_isPrivate=${isPrivate}`}
        >
          request a reserved name
        </Link>{" "}
        or register a new name below.
      </Notification>
    );
  }
 
  if (errorCode === "no-permission") {
    return (
      <Notification severity="information">
        You do not have permission to register snaps to this store. Contact the
        store administrator.
      </Notification>
    );
  }
 
  Eif (errorCode !== "already_registered") {
    return (
      <Notification severity="information">
        Before you can push your snap to the store, its name must be registered
      </Notification>
    );
  }
 
  return null;
}
 
export default RegistrationError;