166 lines
5.4 KiB
React
166 lines
5.4 KiB
React
import { useState, Fragment, useEffect } from 'react'
|
|
|
|
import Dropdown from 'components/downloader/dropdown'
|
|
import {
|
|
prettyArch,
|
|
prettyOs,
|
|
trackDownload,
|
|
sortPlatforms,
|
|
getVersionLabel,
|
|
sortAndFilterReleases,
|
|
} from 'components/downloader/utils/downloader'
|
|
import styles from './style.module.css'
|
|
|
|
export default function ReleaseInformation({
|
|
productId,
|
|
productName,
|
|
latestVersion,
|
|
packageManagers,
|
|
containers,
|
|
tutorials,
|
|
changelog,
|
|
brand,
|
|
}) {
|
|
const [selectedVersionId, setSelectedVersionId] = useState(latestVersion)
|
|
const [releases, setReleases] = useState([])
|
|
const { version, ...selectedVersion } =
|
|
releases.find((release) => release.version === selectedVersionId) || {}
|
|
|
|
useEffect(() => {
|
|
// lazy load all release versions to populate dropdown & releases section
|
|
fetch(`https://releases.hashicorp.com/${productId}/index.json`)
|
|
.then((res) => res.json())
|
|
.then((data) => {
|
|
const latestReleases = sortAndFilterReleases(Object.keys(data.versions))
|
|
|
|
const releases = latestReleases.map((releaseVersion) => ({
|
|
...sortPlatforms(data.versions[releaseVersion]),
|
|
version: releaseVersion,
|
|
}))
|
|
setReleases(releases)
|
|
})
|
|
}, [])
|
|
|
|
return (
|
|
<div className={styles.root}>
|
|
<div className="g-container">
|
|
<h2>Release Information</h2>
|
|
<div className={styles.grid}>
|
|
{releases.length > 0 && (
|
|
<>
|
|
<div className={styles.releases}>Releases:</div>
|
|
<div>
|
|
<Dropdown
|
|
title={`${productName} ${getVersionLabel(
|
|
version,
|
|
latestVersion
|
|
)}`}
|
|
brand={brand}
|
|
options={releases.map((releaseData) => ({
|
|
label: `${productName} ${getVersionLabel(
|
|
releaseData.version,
|
|
latestVersion
|
|
)}`,
|
|
value: releaseData.version,
|
|
}))}
|
|
onChange={(release) => setSelectedVersionId(release)}
|
|
/>
|
|
<a
|
|
href={
|
|
changelog ||
|
|
`https://github.com/hashicorp/${productId}/blob/v${version}/CHANGELOG.md`
|
|
}
|
|
className={styles.changelog}
|
|
>
|
|
Changelog
|
|
</a>
|
|
</div>
|
|
</>
|
|
)}
|
|
<div className={styles.latestDownloads}>Latest Downloads:</div>
|
|
<div>
|
|
Package downloads for {productName} {version}
|
|
<div className={styles.downloads}>
|
|
{Object.entries(selectedVersion).map(([os, release]) => (
|
|
<Fragment key={os}>
|
|
<div className={styles.os}>{prettyOs(os)}</div>
|
|
<div>
|
|
{Object.entries(release).map(([arch, file]) => (
|
|
<a
|
|
href={file}
|
|
key={arch}
|
|
onClick={() =>
|
|
trackDownload('boundary', version, os, arch)
|
|
}
|
|
>
|
|
{prettyArch(arch)}
|
|
</a>
|
|
))}
|
|
</div>
|
|
</Fragment>
|
|
))}
|
|
</div>
|
|
<p>
|
|
You can find the{' '}
|
|
<a
|
|
href={`https://releases.hashicorp.com/${productId}/${version}/${productId}_${version}_SHA256SUMS`}
|
|
>
|
|
SHA256 checksums for {productName} {version}
|
|
</a>{' '}
|
|
online and you can{' '}
|
|
<a
|
|
href={`https://releases.hashicorp.com/${productId}/${version}/${productId}_${version}_SHA256SUMS.sig`}
|
|
>
|
|
verify the checksums signature file
|
|
</a>{' '}
|
|
which has been signed using{' '}
|
|
<a href="https://hashicorp.com/security">
|
|
HashiCorp's GPG key.
|
|
</a>
|
|
</p>
|
|
</div>
|
|
|
|
{packageManagers?.length > 0 && (
|
|
<>
|
|
<div className={styles.heading}>Package Managers</div>
|
|
<div className={styles.links}>
|
|
{packageManagers.map((packageManager) => (
|
|
<div key={packageManager.label}>
|
|
Install with{' '}
|
|
<a href={packageManager.url}>{packageManager.label}</a>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</>
|
|
)}
|
|
{containers?.length > 0 && (
|
|
<>
|
|
<div className={styles.heading}>Containers</div>
|
|
<div className={styles.links}>
|
|
{containers.map((container) => (
|
|
<div key={container.label}>
|
|
Run with <a href={container.url}>{container.label}</a>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{containers?.length > 0 && (
|
|
<>
|
|
<div className={styles.heading}>Tutorials</div>
|
|
<div className={styles.links}>
|
|
{tutorials.map((tutorial) => (
|
|
<div key={tutorial.label}>
|
|
<a href={tutorial.url}>{tutorial.label}</a>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|