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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 6x 6x 3x 6x 6x 3x 6x 6x 6x 3x 3x 3x 2x 3x | /* * 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 { useHistory, useParams } from 'react-router-dom' import type { Column, CellProps, Renderer } from 'react-table' import { Layout, Text, TableV2 } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { formatDatetoLocale } from '@common/utils/dateUtils' import type { PagePMSPipelineSummaryResponse, PMSPipelineSummaryResponse } from 'services/pipeline-ng' import { String, useStrings } from 'framework/strings' import routes from '@common/RouteDefinitions' import type { PipelineType } from '@common/interfaces/RouteInterfaces' import GitDetailsColumn from '@common/components/Table/GitDetailsColumn/GitDetailsColumn' import RbacButton from '@rbac/components/Button/Button' import { PermissionIdentifier } from '@rbac/interfaces/PermissionIdentifier' import { ResourceType } from '@rbac/interfaces/ResourceType' import { useAppStore } from 'framework/AppStore/AppStoreContext' import css from './PipelineModalListView.module.scss' type CustomColumn<T extends Record<string, any>> = Column<T> & { reload?: () => Promise<void> } interface PipelineDTO extends PMSPipelineSummaryResponse { admin?: string collaborators?: string status?: string } interface PipelineListViewProps { data?: PagePMSPipelineSummaryResponse refetch?: () => void gotoPage: (pageNumber: number) => void } export default function RunPipelineListView({ data, refetch, gotoPage }: PipelineListViewProps): React.ReactElement { const { orgIdentifier, projectIdentifier, accountId, module } = useParams< PipelineType<{ projectIdentifier: string orgIdentifier: string accountId: string }> >() const history = useHistory() const { getString } = useStrings() const { isGitSyncEnabled } = useAppStore() const routeToPipelinesPage = (pipeline: PipelineDTO): void => { history.push( routes.toPipelineStudio({ accountId, orgIdentifier, projectIdentifier, pipelineIdentifier: pipeline.identifier || '', module, branch: pipeline.gitDetails?.branch, repoIdentifier: pipeline.gitDetails?.repoIdentifier, runPipeline: true }) ) } // eslint-disable-next-line react/function-component-definition const RenderColumnPipeline: Renderer<CellProps<PipelineDTO>> = ({ row }) => { const rowdata = row.original return ( <Layout.Vertical spacing="small" data-testid={rowdata.identifier}> <Text color={Color.GREY_800} iconProps={{ size: 16 }}> {rowdata.name} </Text> <Text color={Color.GREY_400}>{rowdata.description}</Text> </Layout.Vertical> ) } // eslint-disable-next-line react/function-component-definition const RenderLastRunDate: Renderer<CellProps<PipelineDTO>> = ({ row }) => { const rowdata = row.original return ( <Layout.Vertical spacing="xsmall"> <Text color={Color.GREY_400}> {rowdata.executionSummaryInfo?.lastExecutionTs ? formatDatetoLocale(rowdata.executionSummaryInfo?.lastExecutionTs) : getString('pipelineSteps.pullNeverLabel')} </Text> </Layout.Vertical> ) } // eslint-disable-next-line react/function-component-definition const RenderColumnMenu: Renderer<CellProps<PipelineDTO>> = ({ row }): JSX.Element => { const rowdata = row.original const isPipelineInvalid = rowdata?.entityValidityDetails?.valid === false return ( <RbacButton icon="run-pipeline" className={css.rbacButton} disabled={isPipelineInvalid} tooltip={isPipelineInvalid ? getString('pipeline.cannotRunInvalidPipeline') : ''} intent="primary" text={<String stringID="runPipeline" />} onClick={() => routeToPipelinesPage(rowdata)} permission={{ resource: { resourceType: ResourceType.PIPELINE, resourceIdentifier: rowdata.identifier as string }, permission: PermissionIdentifier.EXECUTE_PIPELINE }} /> ) } const columns: CustomColumn<PipelineDTO>[] = React.useMemo( () => [ { Header: getString('common.pipeline').toUpperCase(), accessor: 'name', width: isGitSyncEnabled ? '27.5%' : '50%', Cell: RenderColumnPipeline }, { Header: getString('common.gitSync.repoDetails').toUpperCase(), accessor: 'gitDetails', width: isGitSyncEnabled ? '27.5%' : 0, Cell: GitDetailsColumn }, { Header: getString('lastExecutionTs').toUpperCase(), accessor: 'executionSummaryInfo', width: isGitSyncEnabled ? '25%' : '30%', Cell: RenderLastRunDate }, { accessor: 'tags', width: '20%', Cell: RenderColumnMenu, disableSortBy: true } ], [refetch] ) if (!isGitSyncEnabled) { columns.splice(1, 1) } return ( <TableV2<PipelineDTO> className={css.table} columns={columns} data={data?.content || []} pagination={{ itemCount: data?.totalElements || 0, pageSize: data?.size || 10, pageCount: data?.totalPages ?? 1, pageIndex: data?.number ?? 0, gotoPage }} /> ) } |