diff --git a/client/src/components/molecules/VersionNumbers/VersionStatus.module.scss b/client/src/components/molecules/VersionNumbers/VersionStatus.module.scss new file mode 100644 index 0000000..18ef84f --- /dev/null +++ b/client/src/components/molecules/VersionNumbers/VersionStatus.module.scss @@ -0,0 +1,36 @@ +@import '../../../styles/variables'; + +.status { + text-align: center; + padding-top: $spacer / 2; + padding-bottom: $spacer; + display: flex; + justify-content: space-between; +} + +.element { + display: inline-block; + margin-left: $spacer / 2; + margin-right: $spacer / 2; + text-align: center; +} + +.indicator, +.indicatorActive { + display: inline-block; + margin-right: $spacer / 4; + margin-bottom: -.1rem; +} + +.indicator { + composes: statusIndicator from '../AccountStatus/Indicator.module.scss'; +} + +.indicatorActive { + composes: statusIndicatorActive from '../AccountStatus/Indicator.module.scss'; +} + +.indicatorLabel { + font-family: $font-family-title; + color: $brand-grey; +} diff --git a/client/src/components/molecules/VersionNumbers/VersionStatus.tsx b/client/src/components/molecules/VersionNumbers/VersionStatus.tsx new file mode 100644 index 0000000..4cdc632 --- /dev/null +++ b/client/src/components/molecules/VersionNumbers/VersionStatus.tsx @@ -0,0 +1,29 @@ +import React from 'react' +import styles from './VersionStatus.module.scss' + +const VersionStatus = ({ + status +}: { + status: { ok: boolean; contracts: boolean; network: boolean } +}) => { + return ( +
+ {Object.entries(status).map(([key, value]) => ( +
+ + {value} + + {key} +
+ ))} +
+ ) +} + +export default VersionStatus diff --git a/client/src/components/molecules/VersionNumbers/VersionTable.module.scss b/client/src/components/molecules/VersionNumbers/VersionTable.module.scss index bbdb0c3..a300bd9 100644 --- a/client/src/components/molecules/VersionNumbers/VersionTable.module.scss +++ b/client/src/components/molecules/VersionNumbers/VersionTable.module.scss @@ -56,21 +56,3 @@ } } } - -.spinner { - composes: spinner, small from '../../atoms/Spinner.module.scss'; - margin-right: $spacer; -} - -.handle { - display: inline-block; - border: 0; - background: none; - box-shadow: none; - padding: 0; - margin: 0; - margin-left: -1rem; - padding-right: .5rem; - cursor: pointer; - color: $brand-grey-light; -} diff --git a/client/src/components/molecules/VersionNumbers/VersionTable.tsx b/client/src/components/molecules/VersionNumbers/VersionTable.tsx index 9124a37..be5d003 100644 --- a/client/src/components/molecules/VersionNumbers/VersionTable.tsx +++ b/client/src/components/molecules/VersionNumbers/VersionTable.tsx @@ -1,11 +1,9 @@ -import React, { Fragment, useState } from 'react' -import { OceanPlatformTechStatus } from '@oceanprotocol/squid' -import slugify from '@sindresorhus/slugify' -import useCollapse from 'react-collapsed' +import React from 'react' import { VersionNumbersState } from '.' +import VersionTableRow from './VersionTableRow' import styles from './VersionTable.module.scss' -const VersionTableContracts = ({ +export const VersionTableContracts = ({ contracts, network }: { @@ -46,99 +44,15 @@ const VersionTableContracts = ({ ) -const VersionNumber = ({ - name, - version, - network, - status -}: { - name: string - version?: string - network?: string - status: OceanPlatformTechStatus -}) => - version ? ( - <> - - v{version} - - {network && `(${network})`} - - ) : ( - {status || 'Could not get version'} - ) - -const VersionRow = ({ value }: { value: any }) => { - const collapseStyles = { - transitionDuration: '0.1s' - } - - const expandStyles = { - transitionDuration: '0.1s' - } - - const { getCollapseProps, getToggleProps, isOpen } = useCollapse({ - collapseStyles, - expandStyles - }) - - return ( - <> - - - {value.contracts && ( - - )} - - {value.name} - - - - - - - {value.contracts && ( - - - - - - )} - - ) -} - const VersionTable = ({ data }: { data: VersionNumbersState }) => { return (
{Object.entries(data) - .filter(([key, value]) => key !== 'status') + .filter(([key]) => key !== 'status') .map(([key, value]) => ( - + ))}
diff --git a/client/src/components/molecules/VersionNumbers/VersionTableRow.module.scss b/client/src/components/molecules/VersionNumbers/VersionTableRow.module.scss new file mode 100644 index 0000000..22c9340 --- /dev/null +++ b/client/src/components/molecules/VersionNumbers/VersionTableRow.module.scss @@ -0,0 +1,19 @@ +@import '../../../styles/variables'; + +.handle { + display: inline-block; + border: 0; + background: none; + box-shadow: none; + padding: 0; + margin: 0; + margin-left: -1rem; + padding-right: .5rem; + cursor: pointer; + color: $brand-grey-light; +} + +.spinner { + composes: spinner, small from '../../atoms/Spinner.module.scss'; + margin-right: $spacer; +} diff --git a/client/src/components/molecules/VersionNumbers/VersionTableRow.tsx b/client/src/components/molecules/VersionNumbers/VersionTableRow.tsx new file mode 100644 index 0000000..a2c5cf0 --- /dev/null +++ b/client/src/components/molecules/VersionNumbers/VersionTableRow.tsx @@ -0,0 +1,99 @@ +import React from 'react' +import useCollapse from 'react-collapsed' +import { OceanPlatformTechStatus } from '@oceanprotocol/squid' +import slugify from '@sindresorhus/slugify' +import Spinner from '../../atoms/Spinner' +import styles from './VersionTableRow.module.scss' +import { VersionTableContracts } from './VersionTable' + +const VersionNumber = ({ + name, + version, + network, + status +}: { + name: string + version?: string + network?: string + status: OceanPlatformTechStatus +}) => + version ? ( + <> + + v{version} + + {network && `(${network})`} + + ) : ( + + {status === OceanPlatformTechStatus.Loading ? ( + + ) : ( + status || 'Could not get version' + )} + + ) + +const VersionTableRow = ({ value }: { value: any }) => { + const collapseStyles = { + transition: '0.01s' + } + + const expandStyles = { + transition: '0.01s' + } + + const { getCollapseProps, getToggleProps, isOpen } = useCollapse({ + collapseStyles, + expandStyles + }) + + return ( + <> + + + {value.contracts && ( + + )} + + {value.name} + + + + + + + {value.contracts && ( + + + + + + )} + + ) +} + +export default VersionTableRow diff --git a/client/src/components/molecules/VersionNumbers/index.tsx b/client/src/components/molecules/VersionNumbers/index.tsx index 6f48074..a0bd001 100644 --- a/client/src/components/molecules/VersionNumbers/index.tsx +++ b/client/src/components/molecules/VersionNumbers/index.tsx @@ -12,6 +12,7 @@ import { faucetUri } from '../../../config' import { User } from '../../../context' import VersionTable from './VersionTable' +import VersionStatus from './VersionStatus' export const commonsVersion = process.env.NODE_ENV === 'production' ? version : `${version}-dev` @@ -63,15 +64,15 @@ export default class VersionNumbers extends PureComponent< }, status: { ok: false, - contracts: false, - network: false + network: false, + contracts: false } } // for canceling axios requests public signal = axios.CancelToken.source() - public componentDidMount() { + public async componentDidMount() { this.getOceanVersions() this.getFaucetVersion() } @@ -145,8 +146,9 @@ export default class VersionNumbers extends PureComponent< ) : (

- Ocean Components in use + Ocean Components Status

+
) diff --git a/client/src/components/molecules/VersionNumbers/utils.test.ts b/client/src/components/molecules/VersionNumbers/utils.test.ts deleted file mode 100644 index 0fa7677..0000000 --- a/client/src/components/molecules/VersionNumbers/utils.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { isJsonString } from './utils' - -describe('isJsonString', () => { - it('detects json correctly', () => { - const testJson = isJsonString('{ "hello": "squid" }') - expect(testJson).toBeTruthy() - - const testNonJson = isJsonString('') - expect(testNonJson).toBeFalsy() - }) -}) diff --git a/client/src/components/molecules/VersionNumbers/utils.ts b/client/src/components/molecules/VersionNumbers/utils.ts deleted file mode 100644 index 0b12378..0000000 --- a/client/src/components/molecules/VersionNumbers/utils.ts +++ /dev/null @@ -1,8 +0,0 @@ -export function isJsonString(str: string) { - try { - JSON.parse(str) - } catch (e) { - return false - } - return true -}