Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

VideoPress: tweak the footer of the uploader component
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
align-items: center;
justify-content: space-between;
border-top: 1px solid $gray-200;
padding: 1em;
margin: 0 -1em -1em;
min-height: 27px;
gap: 16px;

&__file-info {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* External dependencies
*/
import apiFetch from '@wordpress/api-fetch';
import { Button, Spinner, TextControl } from '@wordpress/components';
import { Button, TextControl } from '@wordpress/components';
import { useDebounce } from '@wordpress/compose';
import { useState, useEffect } from '@wordpress/element';
import { escapeHTML } from '@wordpress/escape-html';
import { __, sprintf } from '@wordpress/i18n';
Expand Down Expand Up @@ -80,6 +81,10 @@ const usePosterAndTitleUpdate = ( { setAttributes, videoData, onDone } ) => {
} );
};

const debouncedSsendUpdatePoster = useDebounce( posterData => {
sendUpdatePoster( posterData );
}, 1000 );

const sendUpdateTitleRequest = () => {
return updateMeta( { title } );
};
Expand Down Expand Up @@ -119,12 +124,12 @@ const usePosterAndTitleUpdate = ( { setAttributes, videoData, onDone } ) => {
}

if ( videoPosterImageData ) {
return sendUpdatePoster( { poster_attachment_id: videoPosterImageData?.id } );
return debouncedSsendUpdatePoster( { poster_attachment_id: videoPosterImageData?.id } );
}

// Check if videoFrameMs is not undefined or null instead of bool check to allow 0ms. selection
if ( 'undefined' !== typeof videoFrameMs && null !== videoFrameMs ) {
sendUpdatePoster( { at_time: videoFrameMs, is_millisec: true } );
debouncedSsendUpdatePoster( { at_time: videoFrameMs, is_millisec: true } );
}
}, [ videoPosterImageData, videoFrameMs, guid ] );

Expand Down Expand Up @@ -194,64 +199,56 @@ const UploaderProgress = ( {
/>

<div className="videopress-uploader-progress">
{ uploadedVideoData ? (
{ roundedProgress < 100 ? (
<>
<span>{ __( 'Upload Complete!', 'jetpack-videopress-pkg' ) } 🎉</span>
<div className="videopress-uploader-progress__file-info">
<div className="videopress-uploader-progress__progress">
<div className="videopress-uploader-progress__progress-loaded" style={ cssWidth } />
</div>
<div className="videopress-upload__percent-complete">
{ sprintf(
/* translators: Placeholder is an upload progress percenatage number, from 0-100. */
__( 'Uploading (%1$s%%)', 'jetpack-videopress-pkg' ),
roundedProgress
) }
</div>
<div className="videopress-uploader-progress__file-size">{ fileSizeLabel }</div>
</div>
{ isReplacing && (
<div className="videopress-uploader-progress__actions">
<Button onClick={ onReplaceCancel } variant="tertiary" isDestructive>
{ __( 'Cancel', 'jetpack-videopress-pkg' ) }
</Button>
</div>
) }
<div className="videopress-uploader-progress__actions">
{ roundedProgress < 100 && (
<Button
variant="tertiary"
onClick={ onPauseOrResume }
disabled={ ! supportPauseOrResume }
>
{ paused ? resumeText : pauseText }
</Button>
) }
</div>
</>
) : (
<>
{ uploadedVideoData ? (
<span>{ __( 'Upload Complete!', 'jetpack-videopress-pkg' ) } 🎉</span>
) : (
<span>{ __( 'Finishing up …', 'jetpack-videopress-pkg' ) } 🎬</span>
) }
<Button
variant="primary"
onClick={ handleDoneUpload }
disabled={ isFinishingUpdate }
isBusy={ isFinishingUpdate }
disabled={ ! uploadedVideoData || isFinishingUpdate }
isBusy={ ! uploadedVideoData || isFinishingUpdate }
>
{ __( 'Done', 'jetpack-videopress-pkg' ) }
</Button>
</>
) : (
<>
{ roundedProgress < 100 ? (
<>
<div className="videopress-uploader-progress__file-info">
<div className="videopress-uploader-progress__progress">
<div
className="videopress-uploader-progress__progress-loaded"
style={ cssWidth }
/>
</div>
<div className="videopress-upload__percent-complete">
{ sprintf(
/* translators: Placeholder is an upload progress percenatage number, from 0-100. */
__( 'Uploading (%1$s%%)', 'jetpack-videopress-pkg' ),
roundedProgress
) }
</div>
<div className="videopress-uploader-progress__file-size">{ fileSizeLabel }</div>
</div>
{ isReplacing && (
<div className="videopress-uploader-progress__actions">
<Button variant="link" onClick={ onReplaceCancel } isDestructive>
{ __( 'Cancel', 'jetpack-videopress-pkg' ) }
</Button>
</div>
) }
<div className="videopress-uploader-progress__actions">
{ roundedProgress < 100 && (
<Button
variant="link"
onClick={ onPauseOrResume }
disabled={ ! supportPauseOrResume }
>
{ paused ? resumeText : pauseText }
</Button>
) }
</div>
</>
) : (
<>
<span>{ __( 'Finishing up …', 'jetpack-videopress-pkg' ) } 🎬</span>
<Spinner />
</>
) }
</>
) }
</div>
</PlaceholderWrapper>
Expand Down