diff --git a/client/src/components/molecules/VersionNumbers/VersionTable.tsx b/client/src/components/molecules/VersionNumbers/VersionTable.tsx
index b9c05be..5dd9913 100644
--- a/client/src/components/molecules/VersionNumbers/VersionTable.tsx
+++ b/client/src/components/molecules/VersionNumbers/VersionTable.tsx
@@ -1,14 +1,16 @@
import React, { Fragment } from 'react'
-import { VersionNumbersState as VersionTableProps } from '.'
+import { OceanPlatformTechStatus } from '@oceanprotocol/squid'
+import { VersionNumbersState } from '.'
import styles from './VersionTable.module.scss'
import slugify from '@sindresorhus/slugify'
-import Spinner from '../../atoms/Spinner'
const VersionTableContracts = ({
contracts,
network
}: {
- contracts: any
+ contracts: {
+ [contractName: string]: string
+ }
network: string
}) => (
@@ -41,23 +43,21 @@ const VersionTableContracts = ({
)
const VersionNumber = ({
- isLoading,
- software,
+ name,
version,
- network
+ network,
+ status
}: {
- isLoading: boolean
- software: string
- version: string
- network: string
+ name: string
+ version?: string
+ network?: string
+ status: OceanPlatformTechStatus
}) =>
- isLoading ? (
-
- ) : version ? (
+ version ? (
<>
v{version}
@@ -65,47 +65,47 @@ const VersionNumber = ({
{network && `(${network})`}
>
) : (
- Could not get version
+ {status || 'Could not get version'}
)
-const VersionTable = ({ data }: { data: VersionTableProps }) => (
+const VersionTable = ({ data }: { data: VersionNumbersState }) => (
{Object.entries(data).map(([key, value]) => (
-
+
- {value.software}
+ {value.name}
|
|
- {key === 'keeperContracts' && data.brizo.contracts && (
+ {/* {value.contracts && (
|
- )}
+ )} */}
))}
diff --git a/client/src/components/molecules/VersionNumbers/index.tsx b/client/src/components/molecules/VersionNumbers/index.tsx
index fb34a23..b1e27b2 100644
--- a/client/src/components/molecules/VersionNumbers/index.tsx
+++ b/client/src/components/molecules/VersionNumbers/index.tsx
@@ -1,14 +1,17 @@
import React, { PureComponent } from 'react'
-import { Logger } from '@oceanprotocol/squid'
+import {
+ OceanPlatformVersions,
+ OceanPlatformTechStatus,
+ Logger
+} from '@oceanprotocol/squid'
import axios from 'axios'
import { version } from '../../../../package.json'
-import { version as versionSquid } from '@oceanprotocol/squid/package.json'
import styles from './index.module.scss'
-import { aquariusUri, brizoUri, faucetUri } from '../../../config'
+import { faucetUri } from '../../../config'
+import { User } from '../../../context'
import VersionTable from './VersionTable'
-import { isJsonString } from './utils'
export const commonsVersion =
process.env.NODE_ENV === 'production' ? version : `${version}-dev`
@@ -17,40 +20,15 @@ interface VersionNumbersProps {
minimal?: boolean
}
-export interface VersionNumbersState {
+export interface VersionNumbersState extends OceanPlatformVersions {
commons: {
- software: string
+ name: string
version: string
}
- squidJs: {
- software: string
- version: string
- }
- aquarius: {
- isLoading: boolean
- software: string
- version: string
- }
- brizo: {
- isLoading: boolean
- software: string
- version: string
- network: string
- 'keeper-version': string
- 'keeper-url': string
- contracts: any
- }
- keeperContracts: {
- isLoading: boolean
- software: string
- version: string
- network: string
- contracts: any
- }
faucet: {
- isLoading: boolean
- software?: string
- version?: string
+ name: string
+ version: string
+ status: OceanPlatformTechStatus
}
}
@@ -58,99 +36,60 @@ export default class VersionNumbers extends PureComponent<
VersionNumbersProps,
VersionNumbersState
> {
- public state = {
- commons: { software: 'Commons', version: commonsVersion },
- squidJs: {
- software: 'Squid-js',
- version: versionSquid
- },
- aquarius: {
- isLoading: true,
- software: 'Aquarius',
- version: ''
- },
- brizo: {
- isLoading: true,
- software: 'Brizo',
- version: '',
- contracts: {} as any,
- network: '',
- 'keeper-version': '0.0.0',
- 'keeper-url': ''
- },
- keeperContracts: {
- isLoading: true,
- software: 'Keeper Contracts',
- version: '',
- contracts: {} as any,
- network: ''
+ public static contextType = User
+
+ public state: VersionNumbersState = {
+ commons: {
+ name: 'Commons',
+ version: commonsVersion
},
faucet: {
- isLoading: true,
- software: 'Faucet',
- version: ''
+ name: 'Faucet',
+ version: '',
+ status: OceanPlatformTechStatus.Loading
+ },
+ squid: {
+ name: 'Squid-js',
+ status: OceanPlatformTechStatus.Loading
+ },
+ aquarius: {
+ name: 'Aquarius',
+ status: OceanPlatformTechStatus.Loading
+ },
+ brizo: {
+ name: 'Brizo',
+ status: OceanPlatformTechStatus.Loading
}
}
// for canceling axios requests
public signal = axios.CancelToken.source()
- public componentWillMount() {
- this.setAquarius()
- this.setBrizoAndKeeper()
- this.setFaucet()
+ public componentDidMount() {
+ this.getOceanVersions()
}
public componentWillUnmount() {
this.signal.cancel()
}
- private async setAquarius() {
- const aquarius = await this.getData(aquariusUri)
- aquarius &&
- aquarius.version !== undefined &&
- this.setState({ aquarius: { isLoading: false, ...aquarius } })
- }
+ private async getOceanVersions() {
+ const { ocean } = this.context
+ const { versions } = ocean
+ const componentVersions = versions && (await versions.get())
+ const { squid, brizo, aquarius } = componentVersions
+ console.log(componentVersions)
- private async setBrizoAndKeeper() {
- const brizo = await this.getData(brizoUri)
+ // const faucet = await this.getData(faucetUri)
- const keeperVersion =
- brizo['keeper-version'] && brizo['keeper-version'].replace('v', '')
- const keeperNetwork =
- brizo['keeper-url'] &&
- new URL(brizo['keeper-url']).hostname.split('.')[0]
-
- brizo &&
- brizo.version !== undefined &&
- this.setState({
- brizo: {
- isLoading: false,
- ...brizo
- },
- keeperContracts: {
- ...this.state.keeperContracts,
- isLoading: false,
- version: keeperVersion,
- contracts: brizo.contracts,
- network: keeperNetwork
- }
- })
- }
-
- private async setFaucet() {
- const faucet = await this.getData(faucetUri)
-
- // backwards compatibility
- isJsonString(faucet) === false &&
- this.setState({
- faucet: { ...this.state.faucet, isLoading: false }
- })
-
- // the new thing
- faucet &&
- faucet.version !== undefined &&
- this.setState({ faucet: { isLoading: false, ...faucet } })
+ this.setState({
+ commons: { ...this.state.commons },
+ squid,
+ brizo,
+ aquarius
+ // faucet
+ })
+ console.log(this.state)
}
private async getData(uri: string) {
@@ -171,15 +110,11 @@ export default class VersionNumbers extends PureComponent<
public render() {
const { minimal } = this.props
- const { commons, squidJs, brizo, aquarius, faucet } = this.state
+ const { commons, squid, brizo, aquarius } = this.state
- const mimimalOutput = `${squidJs.software} v${squidJs.version} \n${
- brizo.software
- } v${brizo.version} \n${aquarius.software} v${
- aquarius.version
- } \nKeeper Contracts ${brizo['keeper-version']} \n${faucet.software} v${
- faucet.version
- }`
+ const mimimalOutput = `${squid.name} v${squid.version}\n${
+ brizo.name
+ } v${brizo.version}\n${aquarius.name} v${aquarius.version}`
return minimal ? (