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

make amount of recent history items configurable

This commit is contained in:
Matthias Kretschmann 2019-03-26 16:28:08 +01:00
parent 6eda278f1b
commit 9cc5fb3a79
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 41 additions and 33 deletions

View File

@ -7,7 +7,7 @@ import Asset from '../molecules/Asset'
import styles from './AssetsUser.module.scss'
export default class AssetsUser extends PureComponent<
{ list?: boolean; recent?: boolean },
{ list?: boolean; recent?: number },
{ results: any[]; isLoading: boolean }
> {
public state = { results: [], isLoading: true }
@ -61,28 +61,34 @@ export default class AssetsUser extends PureComponent<
) : this.state.results.length ? (
<>
{this.state.results
.slice(0, this.props.recent ? 5 : undefined)
.filter(asset => !!asset)
.map((asset: any) => (
<Asset
list={this.props.list}
key={asset.id}
asset={asset}
/>
))}
{this.props.recent && (
<Link className={styles.link} to={'/history'}>
All Data Sets
</Link>
)}
</>
) : (
<div>
<p>No Data Sets Yet.</p>
<Link to="/publish">+ Publish A Data Set</Link>
</div>
)}
</div>
.slice(
0,
this.props.recent
? this.props.recent
: undefined
)
.filter(asset => !!asset)
.map((asset: any) => (
<Asset
list={this.props.list}
key={asset.id}
asset={asset}
/>
))}
{this.props.recent && (
<Link className={styles.link} to={'/history'}>
All Data Sets
</Link>
)}
</>
) : (
<div className={styles.empty}>
<p>No Data Sets Yet.</p>
<Link to="/publish">+ Publish A Data Set</Link>
</div>
)}
</div>
)
)
}
}

View File

@ -25,13 +25,6 @@ export default class AssetDetails extends PureComponent<AssetDetailsProps> {
{base.copyrightHolder}
</h2>
<div className={styles.metaPrimaryData}>
<span title="Date published">
<Moment
date={base.dateCreated}
format="L"
interval={0}
/>
</span>
{base.categories ? (
// TODO: Make this link to search for respective category
<Link to={`/search?q=${base.categories[0]}`}>
@ -40,9 +33,18 @@ export default class AssetDetails extends PureComponent<AssetDetailsProps> {
) : (
<Link to={'/search?q='}>Fake Category</Link>
)}
<span>
{base.files ? base.files.length : 0} data files
<span title="Date published">
<Moment
date={base.dateCreated}
format="L"
interval={0}
/>
</span>
{base.files && (
<span>{base.files.length} data files</span>
)}
</div>
</aside>

View File

@ -41,7 +41,7 @@ class Home extends Component<HomeProps, HomeState> {
}
/>
</Form>
<AssetsUser recent list />
<AssetsUser recent={5} list />
</Route>
)
}