lbry-desktop/ui/page/fileListPublished/view.jsx

79 lines
2.5 KiB
React
Raw Normal View History

// @flow
2019-06-11 20:10:58 +02:00
import React, { useEffect } from 'react';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
2019-06-19 07:05:43 +02:00
import ClaimList from 'component/claimList';
2018-03-26 23:32:43 +02:00
import Page from 'component/page';
2019-09-23 19:32:38 +02:00
import Paginate from 'component/common/paginate';
import { PAGE_SIZE } from 'constants/claim';
import WebUploadList from 'component/webUploadList';
import Spinner from 'component/spinner';
type Props = {
2018-10-26 06:20:18 +02:00
checkPendingPublishes: () => void,
clearPublish: () => void,
fetchClaimListMine: () => void,
fetching: boolean,
2019-09-25 23:37:01 +02:00
urls: Array<string>,
urlTotal: ?number,
2019-09-23 19:32:38 +02:00
history: { replace: string => void },
page: number,
};
2019-06-11 20:10:58 +02:00
function FileListPublished(props: Props) {
const { checkPendingPublishes, clearPublish, fetchClaimListMine, fetching, urls, urlTotal } = props;
2019-06-11 20:10:58 +02:00
useEffect(() => {
2018-10-26 06:20:18 +02:00
checkPendingPublishes();
fetchClaimListMine();
}, [checkPendingPublishes, fetchClaimListMine]);
2019-06-11 20:10:58 +02:00
return (
2020-01-02 21:36:03 +01:00
<Page>
<WebUploadList />
{urls && Boolean(urls.length) && (
2020-01-02 21:36:03 +01:00
<React.Fragment>
2019-06-28 09:33:07 +02:00
<ClaimList
2019-07-21 23:31:22 +02:00
header={__('Your Publishes')}
2019-06-28 09:33:07 +02:00
loading={fetching}
persistedStorageKey="claim-list-published"
2019-09-25 23:37:01 +02:00
uris={urls}
headerAltControls={
<Button button="link" label={__('New Publish')} navigate="/$/publish" onClick={() => clearPublish()} />
}
2019-06-28 09:33:07 +02:00
/>
2019-09-25 23:37:01 +02:00
<Paginate totalPages={Math.ceil(Number(urlTotal) / Number(PAGE_SIZE))} loading={fetching} />
2020-01-02 21:36:03 +01:00
</React.Fragment>
)}
{!(urls && urls.length) && (
<React.Fragment>
{!fetching ? (
<section className="main--empty">
<div className=" section--small">
<h2 className="section__title--large">{__('Nothing published to LBRY yet.')}</h2>
<div className="section__actions">
<Button
button="primary"
navigate="/$/publish"
label={__('Publish something new')}
onClick={() => clearPublish()}
/>
</div>
</div>
</section>
) : (
<section className="main--empty">
<div className=" section--small">
<h2 className="section__title--small">
{__('Checking your publishes')}
<Spinner type="small" />
</h2>
</div>
</section>
)}
</React.Fragment>
2019-06-11 20:10:58 +02:00
)}
</Page>
);
2017-05-01 08:26:09 +02:00
}
2017-06-06 06:21:55 +02:00
export default FileListPublished;