2018-12-07 11:29:20 +03:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2019-01-17 09:50:10 +03:00
|
|
|
import {Comment, Info, FileCode, Alert} from '@githubprimer/octicons-react'
|
|
|
|
import {Box, Flex, Link, StyledOcticon as Octicon, Text} from '@primer/components'
|
2019-01-08 22:55:58 +03:00
|
|
|
import StatusLabel from './StatusLabel'
|
2018-12-07 11:29:20 +03:00
|
|
|
|
|
|
|
export default function PackageHeader(props) {
|
2018-12-18 01:43:56 +03:00
|
|
|
const {description, internal = false, package: pkg, source = '', status, status_issue: issue, ...rest} = props
|
2018-12-07 11:29:20 +03:00
|
|
|
|
2018-12-07 22:09:29 +03:00
|
|
|
const isPackage = pkg && source.indexOf('/modules/') > -1
|
2018-12-18 01:43:56 +03:00
|
|
|
const isInternal = internal || source.indexOf('https://github.com/github/github') === 0
|
2018-12-07 22:09:29 +03:00
|
|
|
|
|
|
|
let info
|
2018-12-18 01:43:56 +03:00
|
|
|
if (isInternal) {
|
|
|
|
info = (
|
2018-12-18 02:05:00 +03:00
|
|
|
<Text fontWeight="bold" color="orange.5">
|
2018-12-18 01:43:56 +03:00
|
|
|
<Octicon icon={Alert} mr={1} />
|
|
|
|
For GitHub internal use only
|
|
|
|
</Text>
|
|
|
|
)
|
2018-12-07 22:09:29 +03:00
|
|
|
} else if (isPackage) {
|
|
|
|
info = (
|
|
|
|
<>
|
|
|
|
<Text fontWeight="bold" mr={2}>
|
|
|
|
Package:
|
|
|
|
</Text>
|
|
|
|
<Link href={`https://npm.im/${pkg.name}`}>{pkg.name}</Link>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
} else if (description) {
|
|
|
|
info = (
|
|
|
|
<Text color="gray.5">
|
|
|
|
<Octicon icon={Info} mr={2} />
|
|
|
|
{description}
|
|
|
|
</Text>
|
|
|
|
)
|
|
|
|
}
|
2018-12-07 12:31:33 +03:00
|
|
|
|
2018-12-07 11:29:20 +03:00
|
|
|
return (
|
2018-12-07 12:31:33 +03:00
|
|
|
<Flex justifyContent="space-between" mb={4} {...rest}>
|
2019-01-26 01:38:34 +03:00
|
|
|
<Text is="div" fontSize={1}>
|
|
|
|
{status ? <StatusLabel status={status} is="a" href="/css/status-key" mr={2} /> : null}
|
2018-12-08 03:06:00 +03:00
|
|
|
{info}
|
|
|
|
</Text>
|
2018-12-07 12:31:33 +03:00
|
|
|
<Box>
|
2018-12-07 22:09:29 +03:00
|
|
|
{issue ? (
|
|
|
|
<Link href={issue} ml={2}>
|
|
|
|
<Octicon icon={Comment} />
|
|
|
|
</Link>
|
|
|
|
) : null}
|
|
|
|
{source ? (
|
|
|
|
<Link href={source} ml={2}>
|
|
|
|
<Octicon icon={FileCode} />
|
|
|
|
</Link>
|
|
|
|
) : null}
|
2018-12-07 11:29:20 +03:00
|
|
|
</Box>
|
|
|
|
</Flex>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageHeader.propTypes = {
|
|
|
|
package: PropTypes.shape({
|
|
|
|
name: PropTypes.string.isRequired
|
2018-12-08 02:19:56 +03:00
|
|
|
}),
|
|
|
|
source: PropTypes.string,
|
2018-12-07 11:29:20 +03:00
|
|
|
status: PropTypes.string
|
|
|
|
}
|