Fix bug where upload tools may remain visible upon switching upload type, even when no option to upload is available.

This commit is contained in:
Dan Peterson 2021-12-22 16:47:51 -06:00 committed by Thomas Zarebczan
parent 7671d12e42
commit 6da73f6bc4

View file

@ -142,12 +142,12 @@ function PublishFile(props: Props) {
} }
}, [currentFileType, mode, isStillEditing, updatePublishForm]); }, [currentFileType, mode, isStillEditing, updatePublishForm]);
// set default file source to select if necessary // set default file source to none if editing a livestream.
useEffect(() => { useEffect(() => {
if (isLivestreamClaim) { if (isLivestreamClaim) {
setFileSelectSource(SOURCE_NONE); setFileSelectSource(SOURCE_NONE);
} }
}, [hasLivestreamData, isLivestreamClaim, setFileSelectSource]); }, [isLivestreamClaim, setFileSelectSource]);
const normalizeUrlForProtocol = (url) => { const normalizeUrlForProtocol = (url) => {
if (url.startsWith('https://')) { if (url.startsWith('https://')) {
@ -511,7 +511,7 @@ function PublishFile(props: Props) {
</fieldset-section> </fieldset-section>
)} )}
{fileSelectSource === SOURCE_UPLOAD && showFileUpload && ( {showSourceSelector && fileSelectSource === SOURCE_UPLOAD && showFileUpload && (
<> <>
<FileSelector <FileSelector
label={__('File')} label={__('File')}
@ -525,19 +525,26 @@ function PublishFile(props: Props) {
{getUploadMessage()} {getUploadMessage()}
</> </>
)} )}
{fileSelectSource === SOURCE_SELECT && showFileUpload && hasLivestreamData && !isCheckingLivestreams && ( {showSourceSelector &&
fileSelectSource === SOURCE_SELECT &&
showFileUpload &&
hasLivestreamData &&
!isCheckingLivestreams && (
<> <>
<fieldset-section> <fieldset-section>
<label>{__('Select Replay')}</label> <label>{__('Select Replay')}</label>
<div className="table__wrapper"> <div className="table__wrapper">
<table className="table table--livestream-data"> <table className="table table--livestream-data">
<tbody> <tbody>
{livestreamData.slice((currentPage - 1) * PAGE_SIZE, currentPage * PAGE_SIZE).map((item, i) => ( {livestreamData
.slice((currentPage - 1) * PAGE_SIZE, currentPage * PAGE_SIZE)
.map((item, i) => (
<tr <tr
onClick={() => setSelectedFileIndex((currentPage - 1) * PAGE_SIZE + i)} onClick={() => setSelectedFileIndex((currentPage - 1) * PAGE_SIZE + i)}
key={item.id} key={item.id}
className={classnames('livestream__data-row', { className={classnames('livestream__data-row', {
'livestream__data-row--selected': selectedFileIndex === (currentPage - 1) * PAGE_SIZE + i, 'livestream__data-row--selected':
selectedFileIndex === (currentPage - 1) * PAGE_SIZE + i,
})} })}
> >
<td> <td>
@ -599,12 +606,16 @@ function PublishFile(props: Props) {
</fieldset-group> </fieldset-group>
</> </>
)} )}
{fileSelectSource === SOURCE_SELECT && showFileUpload && !hasLivestreamData && !isCheckingLivestreams && ( {showSourceSelector &&
fileSelectSource === SOURCE_SELECT &&
showFileUpload &&
!hasLivestreamData &&
!isCheckingLivestreams && (
<div className="main--empty empty"> <div className="main--empty empty">
<Empty text={__('No replays found.')} /> <Empty text={__('No replays found.')} />
</div> </div>
)} )}
{fileSelectSource === SOURCE_SELECT && showFileUpload && isCheckingLivestreams && ( {showSourceSelector && fileSelectSource === SOURCE_SELECT && showFileUpload && isCheckingLivestreams && (
<div className="main--empty empty"> <div className="main--empty empty">
<Spinner small /> <Spinner small />
</div> </div>