mirror of
https://github.com/harness/drone.git
synced 2025-05-10 15:32:51 +08:00
[UI] Ensure consistency of Commit
element across screens (#392)
This commit is contained in:
parent
f09ce8987a
commit
914a50b9a2
@ -4,7 +4,6 @@ import {
|
|||||||
FlexExpander,
|
FlexExpander,
|
||||||
Layout,
|
Layout,
|
||||||
Text,
|
Text,
|
||||||
StringSubstitute,
|
|
||||||
ButtonSize,
|
ButtonSize,
|
||||||
ButtonVariation,
|
ButtonVariation,
|
||||||
Avatar
|
Avatar
|
||||||
@ -16,6 +15,7 @@ import { useGet } from 'restful-react'
|
|||||||
import { useAppContext } from 'AppContext'
|
import { useAppContext } from 'AppContext'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
import type { TypesCommit, TypesRepository, TypesSignature } from 'services/code'
|
import type { TypesCommit, TypesRepository, TypesSignature } from 'services/code'
|
||||||
|
import { CommitActions } from 'components/CommitActions/CommitActions'
|
||||||
import { LIST_FETCHING_LIMIT, formatDate } from 'utils/Utils'
|
import { LIST_FETCHING_LIMIT, formatDate } from 'utils/Utils'
|
||||||
import css from './CommitInfo.module.scss'
|
import css from './CommitInfo.module.scss'
|
||||||
|
|
||||||
@ -33,6 +33,11 @@ const CommitInfo = (props: { repoMetadata: TypesRepository; commitRef: string })
|
|||||||
lazy: !repoMetadata
|
lazy: !repoMetadata
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const commitURL = routes.toCODECommit({
|
||||||
|
repoPath: repoMetadata.path as string,
|
||||||
|
commitRef: commitRef
|
||||||
|
})
|
||||||
|
|
||||||
const commitData = useMemo(() => {
|
const commitData = useMemo(() => {
|
||||||
return commits?.commits?.filter(commit => commit.sha === commitRef)
|
return commits?.commits?.filter(commit => commit.sha === commitRef)
|
||||||
}, [commitRef, commits?.commits])
|
}, [commitRef, commits?.commits])
|
||||||
@ -81,19 +86,7 @@ const CommitInfo = (props: { repoMetadata: TypesRepository; commitRef: string })
|
|||||||
})}
|
})}
|
||||||
</Text>
|
</Text>
|
||||||
<FlexExpander />
|
<FlexExpander />
|
||||||
<Text className={css.infoText} flex>
|
<CommitActions sha={commitRef} href={commitURL} enableCopy />
|
||||||
<StringSubstitute
|
|
||||||
str={getString('commitString')}
|
|
||||||
vars={{
|
|
||||||
commit: (
|
|
||||||
<Text
|
|
||||||
className={css.infoText}
|
|
||||||
padding={{ left: 'small' }}
|
|
||||||
color={'black'}>{` ${commitRef.substring(0, 6)}`}</Text>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Text>
|
|
||||||
</Layout.Horizontal>
|
</Layout.Horizontal>
|
||||||
</Container>
|
</Container>
|
||||||
</Container>
|
</Container>
|
||||||
|
@ -40,7 +40,7 @@ export function LatestCommitForFolder({ repoMetadata, latestCommit, standaloneSt
|
|||||||
</Text>
|
</Text>
|
||||||
</Link>
|
</Link>
|
||||||
<FlexExpander />
|
<FlexExpander />
|
||||||
<CommitActions sha={latestCommit?.sha as string} href={commitURL} />
|
<CommitActions sha={latestCommit?.sha as string} href={commitURL} enableCopy />
|
||||||
<Text font={{ variation: FontVariation.SMALL }} color={Color.GREY_400} className={css.time}>
|
<Text font={{ variation: FontVariation.SMALL }} color={Color.GREY_400} className={css.time}>
|
||||||
<ReactTimeago date={latestCommit?.author?.when as string} />
|
<ReactTimeago date={latestCommit?.author?.when as string} />
|
||||||
</Text>
|
</Text>
|
||||||
@ -86,7 +86,7 @@ export function LatestCommitForFile({ repoMetadata, latestCommit, standaloneStyl
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<FlexExpander />
|
<FlexExpander />
|
||||||
<CommitActions sha={latestCommit?.sha as string} href={commitURL} />
|
<CommitActions sha={latestCommit?.sha as string} href={commitURL} enableCopy />
|
||||||
</Layout.Horizontal>
|
</Layout.Horizontal>
|
||||||
</Container>
|
</Container>
|
||||||
</Render>
|
</Render>
|
||||||
|
@ -14,6 +14,7 @@ import type {
|
|||||||
RepoCommitDivergence,
|
RepoCommitDivergence,
|
||||||
TypesRepository
|
TypesRepository
|
||||||
} from 'services/code'
|
} from 'services/code'
|
||||||
|
import { CommitActions } from 'components/CommitActions/CommitActions'
|
||||||
import { formatDate, getErrorMessage } from 'utils/Utils'
|
import { formatDate, getErrorMessage } from 'utils/Utils'
|
||||||
import { useConfirmAction } from 'hooks/useConfirmAction'
|
import { useConfirmAction } from 'hooks/useConfirmAction'
|
||||||
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
||||||
@ -98,6 +99,23 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Header: getString('commit'),
|
||||||
|
Id: 'commit',
|
||||||
|
width: '15%',
|
||||||
|
Cell: ({ row }: CellProps<RepoBranch>) => {
|
||||||
|
return (
|
||||||
|
<CommitActions
|
||||||
|
sha={row.original.commit?.sha as string}
|
||||||
|
href={routes.toCODECommit({
|
||||||
|
repoPath: repoMetadata.path as string,
|
||||||
|
commitRef: row.original.commit?.sha as string
|
||||||
|
})}
|
||||||
|
enableCopy
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Header: getString('updated'),
|
Header: getString('updated'),
|
||||||
width: '200px',
|
width: '200px',
|
||||||
|
Loading…
Reference in New Issue
Block a user