All files / publisher/shared/PageHeader PageHeader.tsx

100% Statements 2/2
62.5% Branches 5/8
100% Functions 1/1
100% Lines 2/2

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                      14x 14x                                                                                                                  
import { Strip, Tabs } from "@canonical/react-components";
 
type Props = {
  snapName: string | undefined;
  snapTitle?: string;
  activeTab: string;
  publisherName?: string;
};
 
function PageHeader({ snapName, snapTitle, activeTab, publisherName }: Props) {
  // Get the users display name from sessionStorage
  const accountName = window.sessionStorage.getItem("displayName") ?? undefined;
  return (
    <Strip shallow={true} className="u-no-padding--bottom">
      <div className="u-fixed-width">
        <a href="/snaps">&lsaquo;&nbsp;My snaps</a>
        <div className="u-flex" style={{ alignItems: "baseline" }}>
          <h1 className="p-heading--3">{snapTitle ? snapTitle : snapName}</h1>
          {publisherName && accountName && publisherName !== accountName && (
            <p
              className="u-text-muted u-no-margin--bottom"
              style={{ marginLeft: "0.5rem" }}
            >
              by {publisherName}
            </p>
          )}
        </div>
        <Tabs
          listClassName="u-no-margin--bottom"
          links={[
            {
              label: "Listing",
              active: activeTab === "listing",
              href: `/${snapName}/listing`,
              "data-tour": "listing-intro",
            },
            {
              label: "Builds",
              active: activeTab === "builds",
              href: `/${snapName}/builds`,
            },
            {
              label: "Releases",
              active: activeTab === "releases",
              href: `/${snapName}/releases`,
            },
            {
              label: "Metrics",
              active: activeTab === "metrics",
              href: `/${snapName}/metrics`,
            },
            {
              label: "Publicise",
              active: activeTab === "publicise",
              href: `/${snapName}/publicise`,
            },
            {
              label: "Settings",
              active: activeTab === "settings",
              href: `/${snapName}/settings`,
            },
          ]}
        />
      </div>
    </Strip>
  );
}
 
export default PageHeader;