All files / modules/45-dashboards/pages DashboardsCommonHeaderPage.tsx

95.24% Statements 20/21
100% Branches 2/2
66.67% Functions 2/3
95.24% Lines 20/21

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              2x   2x 2x 2x 2x 2x 2x 2x 2x 2x 2x   2x 7x 7x 7x 7x   7x   7x                                               1x                   2x  
/*
 * Copyright 2022 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import React, { useState } from 'react'
 
import { Layout, Button } from '@wings-software/uicore'
import { Color } from '@harness/design-system'
import { NavLink, useParams } from 'react-router-dom'
import { Page } from '@common/exports'
import { NGBreadcrumbs } from '@common/components/NGBreadcrumbs/NGBreadcrumbs'
import routes from '@common/RouteDefinitions'
import { useStrings } from 'framework/strings'
import { GetStarted } from './home/GetStarted'
import { useDashboardsContext } from './DashboardsContext'
import css from './home/HomePage.module.scss'
 
const DashboardsHeader: React.FC = () => {
  const { getString } = useStrings()
  const { breadcrumbs } = useDashboardsContext()
  const { accountId, folderId } = useParams<{ accountId: string; folderId: string }>()
  const [isOpen, setDrawerOpen] = useState(false)
 
  const title = breadcrumbs.length ? breadcrumbs[breadcrumbs.length - 1].label : getString('common.dashboards')
 
  return (
    <Page.Header
      title={title}
      breadcrumbs={<NGBreadcrumbs links={breadcrumbs} />}
      content={
        <Layout.Horizontal spacing="medium">
          <NavLink
            className={css.tags}
            activeClassName={css.activeTag}
            to={routes.toCustomDashboardHome({ accountId, folderId })}
          >
            {getString('common.dashboards')}
          </NavLink>
          <NavLink className={css.tags} activeClassName={css.activeTag} to={routes.toCustomFolderHome({ accountId })}>
            {getString('dashboards.homePage.folders')}
          </NavLink>
        </Layout.Horizontal>
      }
      toolbar={
        <>
          <Button
            minimal
            color={Color.PRIMARY_6}
            icon="question"
            onClick={() => setDrawerOpen(true)}
            text={getString('getStarted')}
          />
          <GetStarted isOpen={isOpen} setDrawerOpen={(val: boolean) => setDrawerOpen(val)} />
        </>
      }
    />
  )
}
 
export default DashboardsHeader