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

code fixes

This commit is contained in:
Matthias Kretschmann 2019-09-10 00:15:13 +02:00
parent 73c7624873
commit 1f7845aa22
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 57 additions and 59 deletions

View File

@ -10,6 +10,8 @@ export default class AssetsUser extends PureComponent<
{ list?: boolean; recent?: number }, { list?: boolean; recent?: number },
{ results: any[]; isLoading: boolean } { results: any[]; isLoading: boolean }
> { > {
public static contextType = User
public state = { results: [], isLoading: true } public state = { results: [], isLoading: true }
public _isMounted = false public _isMounted = false
@ -58,51 +60,46 @@ export default class AssetsUser extends PureComponent<
public render() { public render() {
const { account } = this.context const { account } = this.context
const { recent, list } = this.props
const { isLoading, results } = this.state
if (!account) return null
return ( return (
account && ( <div className={styles.assetsUser}>
<div className={styles.assetsUser}> {this.props.recent && (
{this.props.recent && ( <h2 className={styles.subTitle}>
<h2 className={styles.subTitle}> Your Latest Published Data Sets
Your Latest Published Data Sets </h2>
</h2> )}
)}
{this.state.isLoading ? ( {isLoading ? (
<Spinner /> <Spinner />
) : this.state.results.length ? ( ) : results.length ? (
<> <>
{this.state.results {results
.slice( .slice(0, recent ? recent : undefined)
0, .filter(asset => !!asset)
this.props.recent .map((asset: any) => (
? this.props.recent <AssetTeaser
: undefined list={list}
) key={asset.id}
.filter(asset => !!asset) asset={asset}
.map((asset: any) => ( />
<AssetTeaser ))}
list={this.props.list} {recent && (
key={asset.id} <Link className={styles.link} to="/history">
asset={asset} All Data Sets
/> </Link>
))} )}
{this.props.recent && ( </>
<Link className={styles.link} to="/history"> ) : (
All Data Sets <div className={styles.empty}>
</Link> <p>No Data Sets Yet.</p>
)} <Link to="/publish">+ Publish A Data Set</Link>
</> </div>
) : ( )}
<div className={styles.empty}> </div>
<p>No Data Sets Yet.</p>
<Link to="/publish">+ Publish A Data Set</Link>
</div>
)}
</div>
)
) )
} }
} }
AssetsUser.contextType = User

View File

@ -7,23 +7,24 @@ const cleanupContentType = (contentType: string) => {
let contentTypeCleaned let contentTypeCleaned
// TODO: add all the possible archive & compression MIME types // TODO: add all the possible archive & compression MIME types
if ( switch (contentType) {
contentType === 'application/x-lzma' || case 'application/x-lzma':
contentType === 'application/x-xz' || case 'application/x-xz':
contentType === 'application/x-tar' || case 'application/x-tar':
contentType === 'application/x-gtar' || case 'application/x-gtar':
contentType === 'application/x-bzip2' || case 'application/x-bzip2':
contentType === 'application/x-gzip' || case 'application/x-gzip':
contentType === 'application/x-7z-compressed' || case 'application/x-7z-compressed':
contentType === 'application/x-rar-compressed' || case 'application/x-rar-compressed':
contentType === 'application/x-zip-compressed' || case 'application/x-zip-compressed':
contentType === 'application/x-apple-diskimage' case 'application/x-apple-diskimage':
) { contentTypeCleaned = contentTypeSplit
contentTypeCleaned = contentTypeSplit .replace('x-', '')
.replace('x-', '') .replace('-compressed', '')
.replace('-compressed', '') break
} else { default:
contentTypeCleaned = contentTypeSplit contentTypeCleaned = contentTypeSplit
break
} }
// Manual replacements // Manual replacements