mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
code fixes
This commit is contained in:
parent
73c7624873
commit
1f7845aa22
@ -10,6 +10,8 @@ export default class AssetsUser extends PureComponent<
|
||||
{ list?: boolean; recent?: number },
|
||||
{ results: any[]; isLoading: boolean }
|
||||
> {
|
||||
public static contextType = User
|
||||
|
||||
public state = { results: [], isLoading: true }
|
||||
|
||||
public _isMounted = false
|
||||
@ -58,51 +60,46 @@ export default class AssetsUser extends PureComponent<
|
||||
|
||||
public render() {
|
||||
const { account } = this.context
|
||||
const { recent, list } = this.props
|
||||
const { isLoading, results } = this.state
|
||||
|
||||
if (!account) return null
|
||||
|
||||
return (
|
||||
account && (
|
||||
<div className={styles.assetsUser}>
|
||||
{this.props.recent && (
|
||||
<h2 className={styles.subTitle}>
|
||||
Your Latest Published Data Sets
|
||||
</h2>
|
||||
)}
|
||||
<div className={styles.assetsUser}>
|
||||
{this.props.recent && (
|
||||
<h2 className={styles.subTitle}>
|
||||
Your Latest Published Data Sets
|
||||
</h2>
|
||||
)}
|
||||
|
||||
{this.state.isLoading ? (
|
||||
<Spinner />
|
||||
) : this.state.results.length ? (
|
||||
<>
|
||||
{this.state.results
|
||||
.slice(
|
||||
0,
|
||||
this.props.recent
|
||||
? this.props.recent
|
||||
: undefined
|
||||
)
|
||||
.filter(asset => !!asset)
|
||||
.map((asset: any) => (
|
||||
<AssetTeaser
|
||||
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>
|
||||
)
|
||||
{isLoading ? (
|
||||
<Spinner />
|
||||
) : results.length ? (
|
||||
<>
|
||||
{results
|
||||
.slice(0, recent ? recent : undefined)
|
||||
.filter(asset => !!asset)
|
||||
.map((asset: any) => (
|
||||
<AssetTeaser
|
||||
list={list}
|
||||
key={asset.id}
|
||||
asset={asset}
|
||||
/>
|
||||
))}
|
||||
{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>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
AssetsUser.contextType = User
|
||||
|
@ -7,23 +7,24 @@ const cleanupContentType = (contentType: string) => {
|
||||
let contentTypeCleaned
|
||||
|
||||
// TODO: add all the possible archive & compression MIME types
|
||||
if (
|
||||
contentType === 'application/x-lzma' ||
|
||||
contentType === 'application/x-xz' ||
|
||||
contentType === 'application/x-tar' ||
|
||||
contentType === 'application/x-gtar' ||
|
||||
contentType === 'application/x-bzip2' ||
|
||||
contentType === 'application/x-gzip' ||
|
||||
contentType === 'application/x-7z-compressed' ||
|
||||
contentType === 'application/x-rar-compressed' ||
|
||||
contentType === 'application/x-zip-compressed' ||
|
||||
contentType === 'application/x-apple-diskimage'
|
||||
) {
|
||||
contentTypeCleaned = contentTypeSplit
|
||||
.replace('x-', '')
|
||||
.replace('-compressed', '')
|
||||
} else {
|
||||
contentTypeCleaned = contentTypeSplit
|
||||
switch (contentType) {
|
||||
case 'application/x-lzma':
|
||||
case 'application/x-xz':
|
||||
case 'application/x-tar':
|
||||
case 'application/x-gtar':
|
||||
case 'application/x-bzip2':
|
||||
case 'application/x-gzip':
|
||||
case 'application/x-7z-compressed':
|
||||
case 'application/x-rar-compressed':
|
||||
case 'application/x-zip-compressed':
|
||||
case 'application/x-apple-diskimage':
|
||||
contentTypeCleaned = contentTypeSplit
|
||||
.replace('x-', '')
|
||||
.replace('-compressed', '')
|
||||
break
|
||||
default:
|
||||
contentTypeCleaned = contentTypeSplit
|
||||
break
|
||||
}
|
||||
|
||||
// Manual replacements
|
||||
|
Loading…
Reference in New Issue
Block a user