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

collapse contracts by default

This commit is contained in:
Matthias Kretschmann 2019-06-18 14:35:18 +02:00
parent 15ebb34931
commit 838757f5e8
Signed by: m
GPG Key ID: 606EEEF3C479A91F
6 changed files with 120 additions and 53 deletions

View File

@ -12982,6 +12982,15 @@
} }
} }
}, },
"react-collapsed": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/react-collapsed/-/react-collapsed-2.0.1.tgz",
"integrity": "sha512-ullymRST/C5iy0szhxpYmIaLUhi+IC8EpFySmUjttoc+ErotaKAx+z1ff0d2PCJF7ksW8crTiOrIwGtFqYw3Tg==",
"requires": {
"@babel/runtime": "^7.3.1",
"raf": "^3.4.0"
}
},
"react-datepicker": { "react-datepicker": {
"version": "2.6.0", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-2.6.0.tgz", "resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-2.6.0.tgz",

View File

@ -25,6 +25,7 @@
"moment": "^2.24.0", "moment": "^2.24.0",
"query-string": "^6.5.0", "query-string": "^6.5.0",
"react": "^16.8.6", "react": "^16.8.6",
"react-collapsed": "^2.0.1",
"react-datepicker": "^2.5.0", "react-datepicker": "^2.5.0",
"react-dom": "^16.8.6", "react-dom": "^16.8.6",
"react-dotdotdot": "^1.3.0", "react-dotdotdot": "^1.3.0",

View File

@ -0,0 +1 @@
declare module 'react-collapsed'

View File

@ -10,6 +10,10 @@
display: table; display: table;
border-top: 1px solid $brand-grey-lighter; border-top: 1px solid $brand-grey-lighter;
tr {
position: relative;
}
table { table {
display: table; display: table;
margin-left: $spacer; margin-left: $spacer;
@ -57,3 +61,16 @@
composes: spinner, small from '../../atoms/Spinner.module.scss'; composes: spinner, small from '../../atoms/Spinner.module.scss';
margin-right: $spacer; 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;
}

View File

@ -1,8 +1,9 @@
import React, { Fragment } from 'react' import React, { Fragment, useState } from 'react'
import { OceanPlatformTechStatus } from '@oceanprotocol/squid' import { OceanPlatformTechStatus } from '@oceanprotocol/squid'
import slugify from '@sindresorhus/slugify'
import useCollapse from 'react-collapsed'
import { VersionNumbersState } from '.' import { VersionNumbersState } from '.'
import styles from './VersionTable.module.scss' import styles from './VersionTable.module.scss'
import slugify from '@sindresorhus/slugify'
const VersionTableContracts = ({ const VersionTableContracts = ({
contracts, contracts,
@ -71,48 +72,78 @@ const VersionNumber = ({
<span>{status || 'Could not get version'}</span> <span>{status || 'Could not get version'}</span>
) )
const VersionTable = ({ data }: { data: VersionNumbersState }) => ( const VersionRow = ({ value }: { value: any }) => {
<div className={styles.tableWrap}> const collapseStyles = {
<table className={styles.table}> transitionDuration: '0.1s'
<tbody> }
{Object.entries(data)
.filter(([key, value]) => key !== 'status') const expandStyles = {
.map(([key, value]) => ( transitionDuration: '0.1s'
<Fragment key={key}> }
<tr>
<td> const { getCollapseProps, getToggleProps, isOpen } = useCollapse({
<a collapseStyles,
href={`https://github.com/oceanprotocol/${slugify( expandStyles
value.name || value.software })
)}`}
> return (
<strong>{value.name}</strong> <>
</a> <tr>
</td> <td>
<td> {value.contracts && (
<VersionNumber <button className={styles.handle} {...getToggleProps()}>
name={value.name || value.software} {isOpen ? (
version={value.version} <span>&#9660;</span>
status={value.status} ) : (
network={value.network} <span>&#9658;</span>
/>
</td>
</tr>
{value.contracts && (
<tr>
<td colSpan={2}>
<VersionTableContracts
contracts={value.contracts}
network={value.network || ''}
/>
</td>
</tr>
)} )}
</Fragment> </button>
))} )}
</tbody> <a
</table> href={`https://github.com/oceanprotocol/${slugify(
</div> value.name || value.software
) )}`}
>
<strong>{value.name}</strong>
</a>
</td>
<td>
<VersionNumber
name={value.name || value.software}
version={value.version}
status={value.status}
network={value.network}
/>
</td>
</tr>
{value.contracts && (
<tr {...getCollapseProps()}>
<td colSpan={2}>
<VersionTableContracts
contracts={value.contracts}
network={value.network || ''}
/>
</td>
</tr>
)}
</>
)
}
const VersionTable = ({ data }: { data: VersionNumbersState }) => {
return (
<div className={styles.tableWrap}>
<table className={styles.table}>
<tbody>
{Object.entries(data)
.filter(([key, value]) => key !== 'status')
.map(([key, value]) => (
<VersionRow key={key} value={value} />
))}
</tbody>
</table>
</div>
)
}
export default VersionTable export default VersionTable

View File

@ -120,20 +120,28 @@ export default class VersionNumbers extends PureComponent<
} }
} }
public render() { private MinimalOutput = () => {
const { minimal } = this.props
const { commons, squid, brizo, aquarius } = this.state const { commons, squid, brizo, aquarius } = this.state
const mimimalOutput = `${squid.name} v${squid.version}\n${ return (
brizo.name
} v${brizo.version}\n${aquarius.name} v${aquarius.version}`
return minimal ? (
<p className={styles.versionsMinimal}> <p className={styles.versionsMinimal}>
<a title={mimimalOutput} href={'/about'}> <a
v{commons.version} {brizo.network && `(${brizo.network})`} title={`${squid.name} v${squid.version}\n${brizo.name} v${
brizo.version
}\n${aquarius.name} v${aquarius.version}`}
href={'/about'}
>
v{commons.version} {squid.network && `(${squid.network})`}
</a> </a>
</p> </p>
)
}
public render() {
const { minimal } = this.props
return minimal ? (
<this.MinimalOutput />
) : ( ) : (
<div className={styles.versions} id="#oceanversions"> <div className={styles.versions} id="#oceanversions">
<h2 className={styles.versionsTitle}> <h2 className={styles.versionsTitle}>