mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
parent
3bcc65f430
commit
5efbf8354d
2 changed files with 18 additions and 9 deletions
|
|
@ -2,8 +2,7 @@ import { BranchName, Breadcrumb, Flex, Text } from '@primer/components'
|
|||
import { GitBranchIcon } from '@primer/octicons-react'
|
||||
import { platform } from 'platforms'
|
||||
import * as React from 'react'
|
||||
import { isOpenInNewWindowClick } from 'utils/general'
|
||||
import { loadWithPJAX } from 'utils/hooks/usePJAX'
|
||||
import { createAnchorClickHandler } from 'utils/general'
|
||||
|
||||
type Props = {
|
||||
metaData: MetaData
|
||||
|
|
@ -18,7 +17,12 @@ export function MetaBar({ metaData }: Props) {
|
|||
<Breadcrumb.Item className={'user-name'} href={userUrl}>
|
||||
{userName}
|
||||
</Breadcrumb.Item>
|
||||
<Breadcrumb.Item className={'repo-name'} href={repoUrl}>
|
||||
<Breadcrumb.Item
|
||||
className={'repo-name'}
|
||||
href={repoUrl}
|
||||
onClick={createAnchorClickHandler(repoUrl)}
|
||||
{...platform.delegatePJAXProps?.()}
|
||||
>
|
||||
<Text fontWeight="bolder">{repoName}</Text>
|
||||
</Breadcrumb.Item>
|
||||
</Breadcrumb>
|
||||
|
|
@ -30,12 +34,7 @@ export function MetaBar({ metaData }: Props) {
|
|||
href={branchUrl}
|
||||
as="a"
|
||||
className={'branch-name'}
|
||||
onClick={e => {
|
||||
if (isOpenInNewWindowClick(e)) return
|
||||
|
||||
e.preventDefault()
|
||||
loadWithPJAX(branchUrl, e.currentTarget)
|
||||
}}
|
||||
onClick={createAnchorClickHandler(branchUrl)}
|
||||
{...platform.delegatePJAXProps?.()}
|
||||
>
|
||||
{branchName || '...'}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { ReactElement } from 'react'
|
||||
import * as ReactDOM from 'react-dom'
|
||||
import { loadWithPJAX } from './hooks/usePJAX'
|
||||
|
||||
export function pick<T>(source: T, keys: string[]): Partial<T> {
|
||||
if (keys && typeof keys === 'object') {
|
||||
|
|
@ -219,3 +220,12 @@ export function resolveDiffGraphMeta(additions: number, deletions: number, chang
|
|||
w = 5 - g - r
|
||||
return { g, r, w }
|
||||
}
|
||||
|
||||
export function createAnchorClickHandler(url: string) {
|
||||
return (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||
if (isOpenInNewWindowClick(e)) return
|
||||
|
||||
e.preventDefault()
|
||||
loadWithPJAX(url, e.currentTarget)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue