fix: [code-1668]: hide commit selector on commit page (#1144)

This commit is contained in:
Calvin Lee 2024-04-19 05:08:19 +00:00 committed by Harness
parent a690fa4ebc
commit 83aa52c65e
3 changed files with 12 additions and 8 deletions

View File

@ -83,6 +83,7 @@ interface ChangesProps extends Pick<GitInfoProps, 'repoMetadata'> {
refetchActivities?: UseGetPullRequestInfoResult['refetchActivities'] refetchActivities?: UseGetPullRequestInfoResult['refetchActivities']
refetchCommits?: UseGetPullRequestInfoResult['refetchCommits'] refetchCommits?: UseGetPullRequestInfoResult['refetchCommits']
setPullReqChangesCount?: React.Dispatch<React.SetStateAction<number>> setPullReqChangesCount?: React.Dispatch<React.SetStateAction<number>>
showCommitsDropdown?: boolean
} }
const ChangesInternal: React.FC<ChangesProps> = ({ const ChangesInternal: React.FC<ChangesProps> = ({
@ -100,7 +101,8 @@ const ChangesInternal: React.FC<ChangesProps> = ({
scrollElement, scrollElement,
refetchActivities, refetchActivities,
refetchCommits, refetchCommits,
setPullReqChangesCount setPullReqChangesCount,
showCommitsDropdown = true
}) => { }) => {
const { getString } = useStrings() const { getString } = useStrings()
const [viewStyle, setViewStyle] = useUserPreference(UserPreference.DIFF_VIEW_STYLE, ViewStyle.SIDE_BY_SIDE) const [viewStyle, setViewStyle] = useUserPreference(UserPreference.DIFF_VIEW_STYLE, ViewStyle.SIDE_BY_SIDE)
@ -428,7 +430,6 @@ const ChangesInternal: React.FC<ChangesProps> = ({
}, [diffs, setPullReqChangesCount]) }, [diffs, setPullReqChangesCount])
useShowRequestError(errorFileViews, 0) useShowRequestError(errorFileViews, 0)
return ( return (
<Container className={cx(css.container, className)} {...(!!loadingRawDiff || !!error ? { flex: true } : {})}> <Container className={cx(css.container, className)} {...(!!loadingRawDiff || !!error ? { flex: true } : {})}>
<LoadingSpinner visible={loading} withBorder={true} /> <LoadingSpinner visible={loading} withBorder={true} />
@ -439,12 +440,13 @@ const ChangesInternal: React.FC<ChangesProps> = ({
<Container className={css.header} ref={headerRef}> <Container className={css.header} ref={headerRef}>
<Layout.Horizontal> <Layout.Horizontal>
<Container flex={{ alignItems: 'center' }} style={{ visibility: diffs ? 'visible' : 'hidden' }}> <Container flex={{ alignItems: 'center' }} style={{ visibility: diffs ? 'visible' : 'hidden' }}>
<CommitRangeDropdown {showCommitsDropdown && (
allCommits={pullReqCommits?.commits || []} <CommitRangeDropdown
selectedCommits={commitRange} allCommits={pullReqCommits?.commits || []}
setSelectedCommits={setCommitRange} selectedCommits={commitRange}
/> setSelectedCommits={setCommitRange}
/>
)}
{/* Files Changed stats */} {/* Files Changed stats */}
<Text flex className={css.diffStatsLabel}> <Text flex className={css.diffStatsLabel}>
<StringSubstitute <StringSubstitute

View File

@ -414,6 +414,7 @@ export default function Compare() {
panel: ( panel: (
<TabContentWrapper loading={loading} error={error} onRetry={noop} className={css.changesContainer}> <TabContentWrapper loading={loading} error={error} onRetry={noop} className={css.changesContainer}>
<Changes <Changes
showCommitsDropdown={false}
readOnly={true} readOnly={true}
repoMetadata={repoMetadata} repoMetadata={repoMetadata}
targetRef={targetGitRef} targetRef={targetGitRef}

View File

@ -53,6 +53,7 @@ export default function RepositoryCommits() {
return ( return (
<Container className={css.changesContainer}> <Container className={css.changesContainer}>
<Changes <Changes
showCommitsDropdown={false}
readOnly={true} readOnly={true}
repoMetadata={repoMetadata} repoMetadata={repoMetadata}
commitSHA={commitRef} commitSHA={commitRef}