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,7 +16,10 @@ const VersionTableContracts = ({
<table> <table>
<tbody> <tbody>
{contracts && {contracts &&
Object.keys(contracts).map(key => { Object.keys(contracts)
// sort alphabetically
.sort((a, b) => a.localeCompare(b))
.map(key => {
const submarineLink = `https://submarine${ const submarineLink = `https://submarine${
network === 'duero' network === 'duero'
? '.duero' ? '.duero'
@ -72,7 +75,9 @@ 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)
.filter(([key, value]) => key !== 'status')
.map(([key, value]) => (
<Fragment key={key}> <Fragment key={key}>
<tr> <tr>
<td> <td>
@ -92,11 +97,11 @@ const VersionTable = ({ data }: { data: VersionNumbersState }) => (
name={value.name} name={value.name}
version={value.version} version={value.version}
status={value.status} status={value.status}
// network={value.network} network={value.network}
/> />
</td> </td>
</tr> </tr>
{/* {value.contracts && ( {value.contracts && (
<tr> <tr>
<td colSpan={2}> <td colSpan={2}>
<VersionTableContracts <VersionTableContracts
@ -105,7 +110,7 @@ const VersionTable = ({ data }: { data: VersionNumbersState }) => (
/> />
</td> </td>
</tr> </tr>
)} */} )}
</Fragment> </Fragment>
))} ))}
</tbody> </tbody>

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) {