Plugin Directory

source: jetpack/trunk/jetpack_vendor/automattic/jetpack-videopress/src/client/admin/components/publish-first-video-popover/index.tsx @ 2832426

Last change on this file since 2832426 was 2832426, checked in by wpkaren, 20 months ago

Updating trunk to version 11.7-a.3

File size: 2.1 KB
Line 
1/**
2 * External dependencies
3 */
4import { ActionPopover, Text } from '@automattic/jetpack-components';
5import { useDispatch } from '@wordpress/data';
6import { __ } from '@wordpress/i18n';
7import { addQueryArgs } from '@wordpress/url';
8/**
9 * Internal dependencies
10 */
11import { STORE_ID } from '../../../state';
12import useVideo from '../../hooks/use-video';
13import useVideos from '../../hooks/use-videos';
14import styles from './styles.module.scss';
15/**
16 * Types
17 */
18import { PublishFirstVideoPopoverProps } from './types';
19import type React from 'react';
20
21/**
22 * Publish First Video Popover component
23 *
24 * @param {PublishFirstVideoPopoverProps} props - Component props.
25 * @returns {React.ReactNode} - PublishFirstVideoPopover react component.
26 */
27const PublishFirstVideoPopover = ( {
28        id,
29        position = null,
30        anchor = null,
31}: PublishFirstVideoPopoverProps ) => {
32        const dispatch = useDispatch( STORE_ID );
33        const { data } = useVideo( Number( id ) );
34        const { firstUploadedVideoId, firstVideoProcessed, dismissedFirstVideoPopover } = useVideos();
35        const showAddToPostPopover =
36                Number( firstUploadedVideoId ) === Number( id ) &&
37                firstVideoProcessed &&
38                ! dismissedFirstVideoPopover;
39
40        const closePopover = () => dispatch.dismissFirstVideoPopover();
41
42        const nonce = window.jetpackVideoPressInitialState?.contentNonce ?? '';
43        const newPostURL = addQueryArgs( 'post-new.php', {
44                videopress_guid: data.guid,
45                _wpnonce: nonce,
46        } );
47
48        return (
49                showAddToPostPopover && (
50                        <ActionPopover
51                                title={ __( 'Publish your new video', 'jetpack-videopress-pkg' ) }
52                                buttonContent={ __( 'Add video to post', 'jetpack-videopress-pkg' ) }
53                                buttonHref={ newPostURL }
54                                buttonExternalLink
55                                anchor={ anchor }
56                                onClose={ closePopover }
57                                onClick={ closePopover }
58                                noArrow={ false }
59                                className={ styles[ 'action-popover' ] }
60                                position={ position }
61                        >
62                                <Text>
63                                        { __(
64                                                "Now that your video has been uploaded to VideoPress, it's time to show it to the world.",
65                                                'jetpack-videopress-pkg'
66                                        ) }
67                                </Text>
68                        </ActionPopover>
69                )
70        );
71};
72
73export default PublishFirstVideoPopover;
Note: See TracBrowser for help on using the repository browser.