All files / modules/72-templates-library/components/TemplateStudio/TemplateStudioHeader TemplateStudioHeader.tsx

100% Statements 17/17
93.75% Branches 15/16
100% Functions 1/1
100% Lines 16/16

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              10x 10x 10x   10x 10x 10x   10x 10x 10x           10x 21x 21x 21x   21x 21x   21x                                                      
/*
 * Copyright 2021 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 from 'react'
import { Container, Layout, Text } from '@wings-software/uicore'
import { useParams } from 'react-router-dom'
import type { TemplateType } from '@templates-library/utils/templatesUtils'
import { NGBreadcrumbs } from '@common/components/NGBreadcrumbs/NGBreadcrumbs'
import routes from '@common/RouteDefinitions'
import templateFactory from '@templates-library/components/Templates/TemplatesFactory'
import type { ProjectPathProps, ModulePathParams } from '@common/interfaces/RouteInterfaces'
import { useStrings } from 'framework/strings'
import { templateStudioColorStyleMap } from '@templates-library/pages/TemplatesPage/TemplatesPageUtils'
import css from './TemplateStudioHeader.module.scss'
 
export interface TemplateStudioHeaderProps {
  templateType: TemplateType
}
 
export const TemplateStudioHeader: React.FC<TemplateStudioHeaderProps> = props => {
  const { templateType } = props
  const { getString } = useStrings()
  const { accountId, orgIdentifier, projectIdentifier, module } = useParams<ProjectPathProps & ModulePathParams>()
 
  const studioTitle = templateFactory.getTemplateName(templateType) || 'Studio'
  const style = templateStudioColorStyleMap[templateType || 'Step']
 
  return (
    <Container>
      <Layout.Horizontal>
        <NGBreadcrumbs
          links={[
            {
              url: routes.toTemplates({ orgIdentifier, projectIdentifier, accountId, module }),
              label: getString('common.templates')
            }
          ]}
        />
      </Layout.Horizontal>
      <Container className={css.templateStudioTitle}>
        <svg width="210" height="26" viewBox="0 0 210 26" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path
            d="M20.3896 22.2945L1.10987 0.5H208.932L190.926 22.0853C189.121 24.2491 186.449 25.5 183.631 25.5H27.505C24.7836 25.5 22.1928 24.3328 20.3896 22.2945Z"
            fill={style?.fill}
            stroke={style?.stroke}
          />
        </svg>
        <Text font={{ size: 'xsmall', weight: 'bold' }} style={{ color: style?.color }} className={css.title}>
          {studioTitle}
        </Text>
      </Container>
    </Container>
  )
}