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 75 76 77 | 2x 2x 2x 2x 2x 2x 13x 13x 13x 7x 13x 13x 3x 1x 2x 1x 1x 3x 3x 13x | /* * 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, { Dispatch, SetStateAction } from 'react' import { Container, DropDown, Layout, SelectOption, Text } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { Sort, SortFields } from '@templates-library/pages/TemplatesPage/TemplatesPageUtils' import { useStrings } from 'framework/strings' import type { PageTemplateSummaryResponse } from 'services/template-ng' export interface ResultsViewHeaderProps { templateData: PageTemplateSummaryResponse setSort: Dispatch<SetStateAction<string[]>> setPage: Dispatch<SetStateAction<number>> } export default function ResultsViewHeader(props: ResultsViewHeaderProps): React.ReactElement { const { templateData, setSort, setPage } = props const { getString } = useStrings() const sortOptions = React.useMemo(() => { return [ { label: getString('lastUpdatedSort'), value: SortFields.LastUpdatedAt }, { label: getString('AZ09'), value: SortFields.AZ09 }, { label: getString('ZA90'), value: SortFields.ZA90 } ] }, []) const [selectedSort, setSelectedSort] = React.useState<SelectOption>(sortOptions[0]) const onDropDownChange = React.useCallback( item => { if (item.value === SortFields.AZ09) { setSort([SortFields.Name, Sort.ASC]) } else if (item.value === SortFields.ZA90) { setSort([SortFields.Name, Sort.DESC]) } else { setSort([SortFields.LastUpdatedAt, Sort.DESC]) } setPage(0) setSelectedSort(item) }, [setSort, setPage] ) return ( <Container> <Layout.Horizontal spacing="large" padding={{ top: 'large', bottom: 'large' }} flex={{ alignItems: 'center' }}> <Text color={Color.GREY_800} iconProps={{ size: 14 }}> {getString('total')}: {templateData.totalElements} </Text> <DropDown items={sortOptions} value={selectedSort.value.toString()} filterable={false} width={180} icon={'main-sort'} iconProps={{ size: 16, color: Color.GREY_400 }} onChange={onDropDownChange} /> </Layout.Horizontal> </Container> ) } |