import React from 'react' import { Container, Layout, FlexExpander, Text, Avatar } from '@harnessio/uicore' import { Color, FontVariation } from '@harnessio/design-system' import { Link } from 'react-router-dom' import { Render } from 'react-jsx-match' import ReactTimeago from 'react-timeago' import cx from 'classnames' import type { TypesCommit } from 'services/code' import { CommitActions } from 'components/CommitActions/CommitActions' import { useAppContext } from 'AppContext' import { formatBytes, formatDate } from 'utils/Utils' import type { GitInfoProps } from 'utils/GitUtils' import { PipeSeparator } from 'components/PipeSeparator/PipeSeparator' import css from './LatestCommit.module.scss' interface LatestCommitProps extends Pick { latestCommit?: TypesCommit standaloneStyle?: boolean size?: number } export function LatestCommitForFolder({ repoMetadata, latestCommit, standaloneStyle }: LatestCommitProps) { const { routes } = useAppContext() const commitURL = routes.toCODECommit({ repoPath: repoMetadata.path as string, commitRef: latestCommit?.sha as string }) return ( {latestCommit?.author?.identity?.name || latestCommit?.author?.identity?.email} {latestCommit?.title} ) } export function LatestCommitForFile({ repoMetadata, latestCommit, standaloneStyle, size }: LatestCommitProps) { const { routes } = useAppContext() const commitURL = routes.toCODECommit({ repoPath: repoMetadata.path as string, commitRef: latestCommit?.sha as string }) return ( {latestCommit?.author?.identity?.name || latestCommit?.author?.identity?.email} {latestCommit?.title} {formatDate(latestCommit?.author?.when as string)} {size && size > 0 && ( <> {formatBytes(size)} )} ) }