1
/* eslint-disable react/prop-types */
2

3 1
import React from 'react';
4 1
import { ADMIN_URLS, STRINGS, LOCALE_NAMES } from '../../config/wagtailConfig';
5

6 1
import Button from '../../components/Button/Button';
7 1
import Icon from '../../components/Icon/Icon';
8
import { PageState } from './reducers/nodes';
9

10
interface ExplorerHeaderProps {
11
  page: PageState;
12
  depth: number;
13
  onClick(eL: any): void
14
}
15

16
/**
17
 * The bar at the top of the explorer, displaying the current level
18
 * and allowing access back to the parent level.
19
 */
20 1
const ExplorerHeader: React.FunctionComponent<ExplorerHeaderProps> = ({ page, depth, onClick }) => {
21 1
  const isRoot = depth === 0;
22 1
  const isSiteRoot = page.id === 0;
23

24 1
  return (
25
    <div className="c-explorer__header">
26
      <Button
27 1
        href={!isSiteRoot ? `${ADMIN_URLS.PAGES}${page.id}/` : ADMIN_URLS.PAGES}
28
        className="c-explorer__header__title "
29
        onClick={onClick}
30
      >
31
        <div className="c-explorer__header__title__inner ">
32
          <Icon
33 1
            name={isRoot ? 'home' : 'arrow-left'}
34
            className="icon--explorer-header"
35
          />
36 1
          <span>{page.admin_display_title || STRINGS.PAGES}</span>
37
        </div>
38
      </Button>
39 1
      {!isSiteRoot && page.meta.locale &&
40 0
        <div className="c-explorer__header__select">
41 1
          <span>{(LOCALE_NAMES.get(page.meta.locale) || page.meta.locale)}</span>
42
        </div>
43
      }
44
    </div>
45
  );
46
};
47

48 1
export default ExplorerHeader;

Read our documentation on viewing source code .

Loading