Add loading state functionality to Schedule button in the calendar (#45645)

* Add loading state functionality to Schedule button in the calendar

* Add changelog

* Updated changelog file
This commit is contained in:
Mahesh Bohara 2024-03-20 00:30:27 +05:45 committed by GitHub
parent b88821f685
commit 6ce72a25ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Product Editor: Add loading state functionality to Schedule Product modal

View File

@ -26,7 +26,7 @@ export function PublishButtonMenu( {
postType, postType,
...props ...props
}: PublishButtonMenuProps ) { }: PublishButtonMenuProps ) {
const { isScheduled, schedule, date, formattedDate } = const { isScheduling, isScheduled, schedule, date, formattedDate } =
useProductScheduled( postType ); useProductScheduled( postType );
const [ showScheduleModal, setShowScheduleModal ] = useState< const [ showScheduleModal, setShowScheduleModal ] = useState<
'schedule' | 'edit' | undefined 'schedule' | 'edit' | undefined
@ -62,6 +62,7 @@ export function PublishButtonMenu( {
<SchedulePublishModal <SchedulePublishModal
postType={ postType } postType={ postType }
value={ showScheduleModal === 'edit' ? date : undefined } value={ showScheduleModal === 'edit' ? date : undefined }
isScheduling={ isScheduling }
onCancel={ () => setShowScheduleModal( undefined ) } onCancel={ () => setShowScheduleModal( undefined ) }
onSchedule={ scheduleProduct } onSchedule={ scheduleProduct }
/> />

View File

@ -26,6 +26,7 @@ export function SchedulePublishModal( {
className, className,
onCancel, onCancel,
onSchedule, onSchedule,
isScheduling,
...props ...props
}: SchedulePublishModalProps ) { }: SchedulePublishModalProps ) {
const [ date, setDate ] = useState< string | undefined >( const [ date, setDate ] = useState< string | undefined >(
@ -77,6 +78,8 @@ export function SchedulePublishModal( {
</Button> </Button>
<Button <Button
variant="primary" variant="primary"
isBusy={ isScheduling }
disabled={ isScheduling }
onClick={ () => onSchedule?.( date ) } onClick={ () => onSchedule?.( date ) }
> >
{ __( 'Schedule', 'woocommerce' ) } { __( 'Schedule', 'woocommerce' ) }

View File

@ -13,4 +13,5 @@ export type SchedulePublishModalProps = Omit<
value?: string; value?: string;
onCancel?(): void; onCancel?(): void;
onSchedule?( value?: string ): void; onSchedule?( value?: string ): void;
isScheduling?: boolean;
}; };