1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

wait for ocean object, sort contracts

This commit is contained in:
Matthias Kretschmann 2019-06-18 13:28:35 +02:00
parent c4f862baa5
commit d92c3e92f4
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 78 additions and 65 deletions

View File

@ -16,28 +16,31 @@ const VersionTableContracts = ({
<table> <table>
<tbody> <tbody>
{contracts && {contracts &&
Object.keys(contracts).map(key => { Object.keys(contracts)
const submarineLink = `https://submarine${ // sort alphabetically
network === 'duero' .sort((a, b) => a.localeCompare(b))
? '.duero' .map(key => {
: network === 'pacific' const submarineLink = `https://submarine${
? '.pacific' network === 'duero'
: '' ? '.duero'
}.dev-ocean.com/address/${contracts[key]}` : network === 'pacific'
? '.pacific'
: ''
}.dev-ocean.com/address/${contracts[key]}`
return ( return (
<tr key={key}> <tr key={key}>
<td> <td>
<span className={styles.label}>{key}</span> <span className={styles.label}>{key}</span>
</td> </td>
<td> <td>
<a href={submarineLink}> <a href={submarineLink}>
<code>{contracts[key]}</code> <code>{contracts[key]}</code>
</a> </a>
</td> </td>
</tr> </tr>
) )
})} })}
</tbody> </tbody>
</table> </table>
) )
@ -72,42 +75,44 @@ const VersionTable = ({ data }: { data: VersionNumbersState }) => (
<div className={styles.tableWrap}> <div className={styles.tableWrap}>
<table className={styles.table}> <table className={styles.table}>
<tbody> <tbody>
{Object.entries(data).map(([key, value]) => ( {Object.entries(data)
<Fragment key={key}> .filter(([key, value]) => key !== 'status')
<tr> .map(([key, value]) => (
<td> <Fragment key={key}>
<a
href={
value.name &&
`https://github.com/oceanprotocol/${slugify(
value.name
)}`
}
>
<strong>{value.name}</strong>
</a>
</td>
<td>
<VersionNumber
name={value.name}
version={value.version}
status={value.status}
// network={value.network}
/>
</td>
</tr>
{/* {value.contracts && (
<tr> <tr>
<td colSpan={2}> <td>
<VersionTableContracts <a
contracts={value.contracts} href={
network={value.network || ''} value.name &&
`https://github.com/oceanprotocol/${slugify(
value.name
)}`
}
>
<strong>{value.name}</strong>
</a>
</td>
<td>
<VersionNumber
name={value.name}
version={value.version}
status={value.status}
network={value.network}
/> />
</td> </td>
</tr> </tr>
)} */} {value.contracts && (
</Fragment> <tr>
))} <td colSpan={2}>
<VersionTableContracts
contracts={value.contracts}
network={value.network || ''}
/>
</td>
</tr>
)}
</Fragment>
))}
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -8,7 +8,7 @@ import axios from 'axios'
import { version } from '../../../../package.json' import { version } from '../../../../package.json'
import styles from './index.module.scss' import styles from './index.module.scss'
import { faucetUri } from '../../../config' // import { faucetUri } from '../../../config'
import { User } from '../../../context' import { User } from '../../../context'
import VersionTable from './VersionTable' import VersionTable from './VersionTable'
@ -43,11 +43,6 @@ export default class VersionNumbers extends PureComponent<
name: 'Commons', name: 'Commons',
version: commonsVersion version: commonsVersion
}, },
faucet: {
name: 'Faucet',
version: '',
status: OceanPlatformTechStatus.Loading
},
squid: { squid: {
name: 'Squid-js', name: 'Squid-js',
status: OceanPlatformTechStatus.Loading status: OceanPlatformTechStatus.Loading
@ -58,7 +53,18 @@ export default class VersionNumbers extends PureComponent<
}, },
brizo: { brizo: {
name: 'Brizo', name: 'Brizo',
network: 'Nile',
status: OceanPlatformTechStatus.Loading status: OceanPlatformTechStatus.Loading
},
faucet: {
name: 'Faucet',
version: '',
status: OceanPlatformTechStatus.Loading
},
status: {
ok: false,
contracts: false,
network: false
} }
} }
@ -75,10 +81,12 @@ export default class VersionNumbers extends PureComponent<
private async getOceanVersions() { private async getOceanVersions() {
const { ocean } = this.context const { ocean } = this.context
const { versions } = ocean
const componentVersions = versions && (await versions.get()) // wait until ocean object is properly populated
const { squid, brizo, aquarius } = componentVersions if (ocean.versions === undefined) return
console.log(componentVersions)
const response = await ocean.versions.get()
const { squid, brizo, aquarius, status } = response
// const faucet = await this.getData(faucetUri) // const faucet = await this.getData(faucetUri)
@ -86,10 +94,10 @@ export default class VersionNumbers extends PureComponent<
commons: { ...this.state.commons }, commons: { ...this.state.commons },
squid, squid,
brizo, brizo,
aquarius aquarius,
status
// faucet // faucet
}) })
console.log(this.state)
} }
private async getData(uri: string) { private async getData(uri: string) {