import React from 'react' import { Button, Container, Color, Layout, FlexExpander, Text, FontVariation, Avatar, ButtonVariation, ButtonSize } from '@harness/uicore' import { Link } from 'react-router-dom' import ReactTimeago from 'react-timeago' import cx from 'classnames' import type { RepoCommit } from 'services/code' import { CommitActions } from 'components/CommitActions/CommitActions' import { useAppContext } from 'AppContext' import { formatDate } from 'utils/Utils' import { CodeIcon, GitInfoProps } from 'utils/GitUtils' import { useStrings } from 'framework/strings' import css from './LatestCommit.module.scss' interface LatestCommitProps extends Pick { latestCommit?: RepoCommit standaloneStyle?: boolean } export function LatestCommitForFolder({ repoMetadata, latestCommit, standaloneStyle }: LatestCommitProps): JSX.Element | null { const { routes } = useAppContext() const commitURL = routes.toCODERepositoryCommits({ repoPath: repoMetadata.path as string, commitRef: latestCommit?.sha as string }) return latestCommit ? ( {latestCommit.author?.identity?.name || latestCommit.author?.identity?.email} {latestCommit.title} ) : null } export function LatestCommitForFile({ repoMetadata, latestCommit, standaloneStyle }: LatestCommitProps): JSX.Element | null { const { routes } = useAppContext() const { getString } = useStrings() const commitURL = routes.toCODERepositoryCommits({ repoPath: repoMetadata.path as string, commitRef: latestCommit?.sha as string }) return latestCommit ? ( {latestCommit.author?.identity?.name || latestCommit.author?.identity?.email} {latestCommit.title} {getString('onDate', { date: formatDate(latestCommit.author?.when as string) })}