Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit c326671

Browse files
authored
Add link to all commits from tree page (#60909)
* add newline * prettier * trim newlines * run prettier * remove buttongroup * prettier * add revision to url
1 parent 5d4bd4e commit c326671

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

client/web/src/repo/tree/TreePageContent.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useMemo } from 'react'
22

3-
import { mdiCog, mdiFileOutline, mdiGlasses, mdiInformationOutline } from '@mdi/js'
3+
import { mdiCog, mdiFileOutline, mdiSourceCommit, mdiGlasses, mdiInformationOutline } from '@mdi/js'
44
import classNames from 'classnames'
55
import { escapeRegExp } from 'lodash'
66

@@ -14,7 +14,7 @@ import { SearchPatternType, type TreeFields } from '@sourcegraph/shared/src/grap
1414
import type { PlatformContextProps } from '@sourcegraph/shared/src/platform/context'
1515
import type { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService'
1616
import { buildSearchURLQuery } from '@sourcegraph/shared/src/util/url'
17-
import { Badge, ButtonLink, Card, CardHeader, Icon, Link, Text, Tooltip } from '@sourcegraph/wildcard'
17+
import { Badge, Button, ButtonLink, Card, CardHeader, Icon, Link, Text, Tooltip } from '@sourcegraph/wildcard'
1818

1919
import type { AuthenticatedUser } from '../../auth'
2020
import {
@@ -45,6 +45,7 @@ import { getRefType } from '../utils'
4545

4646
import { FilesCard, ReadmePreviewCard } from './TreePagePanels'
4747

48+
import menuStyles from './TreePage.module.scss'
4849
import styles from './TreePageContent.module.scss'
4950
import contributorsStyles from './TreePageContentContributors.module.scss'
5051
import panelStyles from './TreePagePanels.module.scss'
@@ -177,6 +178,25 @@ export const TreePageContent: React.FunctionComponent<React.PropsWithChildren<Tr
177178

178179
return (
179180
<>
181+
{!isRoot && (
182+
<div className={menuStyles.menu}>
183+
<Tooltip content="Git commits">
184+
<Button
185+
className="flex-shrink-0"
186+
to={`/${encodeURIPathComponent(repo.name)}${
187+
revision && `@${encodeURIPathComponent(revision)}`
188+
}/-/commits/${encodeURIPathComponent(filePath)}`}
189+
variant="secondary"
190+
outline={true}
191+
as={Link}
192+
>
193+
<Icon aria-hidden={true} svgPath={mdiSourceCommit} />{' '}
194+
<span className={menuStyles.text}>Commits</span>
195+
</Button>
196+
</Tooltip>
197+
</div>
198+
)}
199+
180200
{(readmeEntry || isRoot) && (
181201
<section className={classNames('container mb-3 px-0', styles.section)}>
182202
{readmeEntry && (
@@ -196,7 +216,14 @@ export const TreePageContent: React.FunctionComponent<React.PropsWithChildren<Tr
196216
)}
197217
</section>
198218
)}
199-
<section className={classNames('test-tree-entries container mb-3 px-0', styles.section)}>
219+
220+
<section
221+
className={classNames(
222+
'test-tree-entries container mb-3 px-0',
223+
styles.section,
224+
!readmeEntry ? 'mt-3' : undefined
225+
)}
226+
>
200227
<FilesCard historyEntries={treeWithHistory} entries={tree.entries} className={styles.files} />
201228

202229
{!isPackage && (

0 commit comments

Comments
 (0)