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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 8x 7x 7x 7x 7x 7x 7x 7x 7x 6x 1x 2x 7x 1x 7x 7x 1x 6x 1x 5x 3x 2x 4x 7x | /*
* 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, { useCallback, useContext, useMemo, useState } from 'react'
import { useParams } from 'react-router-dom'
import { Card, Container, ExpandingSearchInput, Layout, Text, PageError, NoDataCard } from '@wings-software/uicore'
import { Color } from '@harness/design-system'
import { useGetDeploymentsByServiceId, GetDeploymentsByServiceIdQueryParams } from 'services/cd-ng'
import type { ProjectPathProps, ServicePathProps } from '@common/interfaces/RouteInterfaces'
import ExecutionCard from '@pipeline/components/ExecutionCard/ExecutionCard'
import { CardVariant } from '@pipeline/utils/constants'
import { executionStatusInfoToExecutionSummary } from '@cd/pages/dashboard/CDDashboardPage'
import { DeploymentsTimeRangeContext } from '@cd/components/Services/common'
import { useStrings } from 'framework/strings'
import { PageSpinner } from '@common/components'
import pipelineIllustration from '@pipeline/pages/pipelines/images/deploypipeline-illustration.svg'
import css from '@cd/components/ServiceDetails/PipelineExecutions/PipelineExecutions.module.scss'
export const PipelineExecutions: React.FC = () => {
const { getString } = useStrings()
const { timeRange } = useContext(DeploymentsTimeRangeContext)
const { accountId, orgIdentifier, projectIdentifier, serviceId } = useParams<ProjectPathProps & ServicePathProps>()
const queryParams: GetDeploymentsByServiceIdQueryParams = {
accountIdentifier: accountId,
orgIdentifier,
projectIdentifier,
serviceId,
startTime: timeRange?.range[0]?.getTime() || 0,
endTime: timeRange?.range[1]?.getTime() || 0
}
const { loading, data, error, refetch } = useGetDeploymentsByServiceId({ queryParams })
const [searchTerm, setSearchTerm] = useState('')
const deployments = data?.data?.deployments || []
const filteredDeployments = useMemo(() => {
if (!searchTerm) {
return deployments
}
return deployments.filter(
deployment =>
(deployment.pipelineIdentifier || '').toLocaleLowerCase().indexOf(searchTerm.toLocaleLowerCase()) !== -1 ||
(deployment.pipelineName || '').toLocaleLowerCase().indexOf(searchTerm.toLocaleLowerCase()) !== -1 ||
(deployment.author?.name || '').toLocaleLowerCase().indexOf(searchTerm.toLocaleLowerCase()) !== -1
)
}, [searchTerm, deployments])
const onSearch = useCallback((val: string) => {
setSearchTerm(val.trim())
}, [])
const getComponent = (): React.ReactElement => {
if (loading) {
return <PageSpinner />
}
if (error) {
return <PageError onClick={() => refetch()} />
}
if (!filteredDeployments.length) {
return (
<Card className={css.pipelineExecutionsEmptyStateContainer}>
<NoDataCard
image={pipelineIllustration}
imageClassName={css.pipelineExecutionsEmptyStateImage}
message={getString('cd.serviceDashboard.noPipelines', {
timeRange: timeRange?.label
})}
containerClassName={css.dataCard}
/>
</Card>
)
}
return (
<>
{filteredDeployments.map(d => (
<ExecutionCard
variant={CardVariant.Minimal}
key={d.pipelineIdentifier}
pipelineExecution={executionStatusInfoToExecutionSummary(d)}
/>
))}
</>
)
}
return (
<Container padding={{ top: 'medium' }} height="100%">
<Layout.Vertical height="100%">
<Layout.Horizontal padding={{ top: 'medium' }} flex={{ alignItems: 'center', justifyContent: 'space-between' }}>
<Text font={{ weight: 'bold' }} color={Color.GREY_600}>
{`${getString('cd.serviceDashboard.totalPipelines')}: ${deployments.length}`}
</Text>
<ExpandingSearchInput flip width={200} placeholder={getString('search')} throttle={200} onChange={onSearch} />
</Layout.Horizontal>
<Container className={css.executionCardContainer}>{getComponent()}</Container>
</Layout.Vertical>
</Container>
)
}
|