commons/client/src/components/molecules/VersionNumbers/VersionTable.tsx

117 lines
3.7 KiB
TypeScript
Raw Normal View History

import React, { Fragment } from 'react'
import { OceanPlatformTechStatus } from '@oceanprotocol/squid'
import { VersionNumbersState } from '.'
import styles from './VersionTable.module.scss'
import slugify from '@sindresorhus/slugify'
const VersionTableContracts = ({
contracts,
network
}: {
contracts: {
[contractName: string]: string
}
network: string
}) => (
<table>
<tbody>
{contracts &&
Object.keys(contracts).map(key => {
const submarineLink = `https://submarine${
network === 'duero'
? '.duero'
: network === 'pacific'
? '.pacific'
: ''
}.dev-ocean.com/address/${contracts[key]}`
return (
<tr key={key}>
<td>
<span className={styles.label}>{key}</span>
</td>
<td>
<a href={submarineLink}>
<code>{contracts[key]}</code>
</a>
</td>
</tr>
)
})}
</tbody>
</table>
)
2019-06-14 12:31:29 +02:00
const VersionNumber = ({
name,
2019-06-14 12:31:29 +02:00
version,
network,
status
2019-06-14 12:31:29 +02:00
}: {
name: string
version?: string
network?: string
status: OceanPlatformTechStatus
2019-06-14 12:31:29 +02:00
}) =>
version ? (
2019-06-14 12:31:29 +02:00
<>
<a
href={`https://github.com/oceanprotocol/${slugify(
name
2019-06-14 12:31:29 +02:00
)}/releases/tag/v${version}`}
>
<code>v{version}</code>
</a>
{network && `(${network})`}
</>
) : (
<span>{status || 'Could not get version'}</span>
2019-06-14 12:31:29 +02:00
)
const VersionTable = ({ data }: { data: VersionNumbersState }) => (
<div className={styles.tableWrap}>
<table className={styles.table}>
<tbody>
{Object.entries(data).map(([key, value]) => (
<Fragment key={key}>
<tr>
<td>
<a
href={
value.name &&
`https://github.com/oceanprotocol/${slugify(
value.name
)}`
}
>
<strong>{value.name}</strong>
</a>
</td>
<td>
2019-06-14 12:31:29 +02:00
<VersionNumber
name={value.name}
2019-06-14 12:31:29 +02:00
version={value.version}
status={value.status}
// network={value.network}
2019-06-14 12:31:29 +02:00
/>
</td>
</tr>
{/* {value.contracts && (
<tr>
<td colSpan={2}>
<VersionTableContracts
contracts={value.contracts}
network={value.network || ''}
/>
</td>
</tr>
)} */}
</Fragment>
))}
</tbody>
</table>
</div>
)
export default VersionTable