2018-04-04 18:08:27 +02:00
|
|
|
// @flow
|
2020-07-23 19:02:07 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
|
|
|
import * as ICONS from 'constants/icons';
|
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';
|
2020-04-24 15:51:00 +02:00
|
|
|
import { PAGE_PARAM, PAGE_SIZE_PARAM } from 'constants/claim';
|
2019-10-11 02:37:18 +02:00
|
|
|
import WebUploadList from 'component/webUploadList';
|
2019-11-15 21:48:57 +01:00
|
|
|
import Spinner from 'component/spinner';
|
2020-04-24 15:51:00 +02:00
|
|
|
import Card from 'component/common/card';
|
2017-04-23 18:10:45 +02:00
|
|
|
|
2018-04-04 18:08:27 +02:00
|
|
|
type Props = {
|
2020-04-24 15:51:00 +02:00
|
|
|
uploadCount: number,
|
2018-10-26 06:20:18 +02:00
|
|
|
checkPendingPublishes: () => void,
|
2020-01-08 06:29:01 +01:00
|
|
|
clearPublish: () => void,
|
2020-04-24 15:51:00 +02:00
|
|
|
fetchClaimListMine: (number, number) => void,
|
2018-06-13 23:07:06 +02:00
|
|
|
fetching: boolean,
|
2019-09-25 23:37:01 +02:00
|
|
|
urls: Array<string>,
|
2020-04-24 15:51:00 +02:00
|
|
|
urlTotal: number,
|
|
|
|
history: { replace: string => void, push: string => void },
|
2019-09-23 19:32:38 +02:00
|
|
|
page: number,
|
2020-04-24 15:51:00 +02:00
|
|
|
pageSize: number,
|
2018-04-04 18:08:27 +02:00
|
|
|
};
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
function FileListPublished(props: Props) {
|
2020-04-24 15:51:00 +02:00
|
|
|
const {
|
|
|
|
uploadCount,
|
|
|
|
checkPendingPublishes,
|
|
|
|
clearPublish,
|
|
|
|
fetchClaimListMine,
|
|
|
|
fetching,
|
|
|
|
urls,
|
|
|
|
urlTotal,
|
|
|
|
page,
|
|
|
|
pageSize,
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const params = {};
|
|
|
|
|
|
|
|
params[PAGE_PARAM] = Number(page);
|
|
|
|
params[PAGE_SIZE_PARAM] = Number(pageSize);
|
|
|
|
|
|
|
|
const paramsString = JSON.stringify(params);
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
useEffect(() => {
|
2018-10-26 06:20:18 +02:00
|
|
|
checkPendingPublishes();
|
2020-04-24 15:51:00 +02:00
|
|
|
}, [checkPendingPublishes]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (paramsString && fetchClaimListMine) {
|
|
|
|
const params = JSON.parse(paramsString);
|
|
|
|
fetchClaimListMine(params.page, params.page_size);
|
|
|
|
}
|
|
|
|
}, [uploadCount, paramsString, fetchClaimListMine]);
|
2017-04-23 18:10:45 +02:00
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
return (
|
2020-01-02 21:36:03 +01:00
|
|
|
<Page>
|
2020-05-28 16:45:56 +02:00
|
|
|
<div className="card-stack">
|
|
|
|
<WebUploadList />
|
2020-06-02 18:32:58 +02:00
|
|
|
{!!(urls && urls.length) && (
|
|
|
|
<Card
|
|
|
|
title={__('Publishes')}
|
|
|
|
titleActions={
|
|
|
|
<div className="card__actions--inline">
|
2020-06-30 12:14:18 +02:00
|
|
|
{fetching && <Spinner type="small" />}
|
|
|
|
{!fetching && (
|
|
|
|
<Button
|
|
|
|
button="alt"
|
|
|
|
label={__('Refresh')}
|
|
|
|
icon={ICONS.REFRESH}
|
|
|
|
onClick={() => fetchClaimListMine(params.page, params.page_size)}
|
|
|
|
/>
|
|
|
|
)}
|
2020-06-02 18:32:58 +02:00
|
|
|
<Button
|
|
|
|
icon={ICONS.PUBLISH}
|
|
|
|
button="secondary"
|
2020-07-23 19:02:07 +02:00
|
|
|
label={__('Upload')}
|
|
|
|
navigate={`/$/${PAGES.UPLOAD}`}
|
2020-06-02 18:32:58 +02:00
|
|
|
onClick={() => clearPublish()}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
isBodyList
|
|
|
|
body={
|
|
|
|
<div>
|
|
|
|
<ClaimList isCardBody loading={fetching} persistedStorageKey="claim-list-published" uris={urls} />
|
|
|
|
<Paginate totalPages={urlTotal > 0 ? Math.ceil(urlTotal / Number(pageSize)) : 1} />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
2020-05-28 16:45:56 +02:00
|
|
|
</div>
|
2019-11-15 21:48:57 +01:00
|
|
|
{!(urls && urls.length) && (
|
|
|
|
<React.Fragment>
|
|
|
|
{!fetching ? (
|
|
|
|
<section className="main--empty">
|
|
|
|
<div className=" section--small">
|
2020-07-23 19:02:07 +02:00
|
|
|
<h2 className="section__title--large">{__('Nothing uploaded to LBRY yet.')}</h2>
|
2019-11-15 21:48:57 +01:00
|
|
|
<div className="section__actions">
|
2020-01-08 06:29:01 +01:00
|
|
|
<Button
|
|
|
|
button="primary"
|
2020-07-23 19:02:07 +02:00
|
|
|
navigate={`/$/${PAGES.UPLOAD}`}
|
|
|
|
label={__('Upload something new')}
|
2020-01-08 06:29:01 +01:00
|
|
|
onClick={() => clearPublish()}
|
|
|
|
/>
|
2019-11-15 21:48:57 +01:00
|
|
|
</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-04-23 18:10:45 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default FileListPublished;
|