Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoPress: update UI/UX when the video block doesn't belong to site #30443

Merged
merged 7 commits into from
May 4, 2023
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: added

VideoPress: add a Notice when trying to edit a video that doesn't belong to the site
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { __ } from '@wordpress/i18n';
import ChaptersLearnMoreHelper from '../../../../../components/chapters-learn-more-helper';
import IncompleteChaptersNotice from '../../../../../components/incomplete-chapters-notice';
import useChaptersLiveParsing from '../../../../../hooks/use-chapters-live-parsing';
import { DetailsPanelProps } from '../../types';
import './styles.scss';
/**
* Types
*/
import type { DetailsPanelProps } from '../../types';
import type React from 'react';

const CHARACTERS_PER_LINE = 31;
Expand Down Expand Up @@ -62,6 +62,15 @@ export default function DetailsPanel( {

return (
<PanelBody title={ __( 'Details', 'jetpack-videopress-pkg' ) }>
{ ! videoBelongToSite && (
<Notice status="warning" isDismissible={ false } className="not-belong-to-site-notice">
{ __(
'This video is not owned by this site. You can still embed it and customize the player, but you won’t be able to edit the video.',
'jetpack-videopress-pkg'
) }
</Notice>
) }

<TextControl
label={ __( 'Title', 'jetpack-videopress-pkg' ) }
value={ title }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.details-panel__error,
.not-belong-to-site-notice,
.learn-how-notice {
margin: 0;

Expand All @@ -21,3 +22,8 @@
// Match helper text margin
margin-top: calc( -1 * calc( var( --spacing-base ) * 2 ) ); // -16px
}

.not-belong-to-site-notice {
--spacing-base: 8px;
margin-bottom: calc( var( --spacing-base ) * 2 );
}
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ export default function PosterPanel( {
attributes,
setAttributes,
isGeneratingPoster,
videoBelongToSite,
}: PosterPanelProps ): React.ReactElement {
const { poster, posterData } = attributes;

Expand Down Expand Up @@ -547,8 +548,9 @@ export default function PosterPanel( {
<PanelBody title={ panelTitle } className="poster-panel" initialOpen={ false }>
<ToggleControl
label={ __( 'Pick from video frame', 'jetpack-videopress-pkg' ) }
checked={ pickPosterFromFrame }
checked={ pickPosterFromFrame && videoBelongToSite }
onChange={ switchPosterSource }
disabled={ ! videoBelongToSite }
/>

<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import PrivacyAndRatingSettings from './privacy-and-rating-settings';
/**
* Types
*/
import type { VideoControlProps } from '../../types';
import type { PrivacyAndRatingPanelProps } from '../../types';
import type React from 'react';

/**
* React component that renders the main privacy and ratings panel.
*
* @param {VideoControlProps} props - Component props.
* @returns {React.ReactElement} - Panel to contain privacy and ratings settings.
* @param {PrivacyAndRatingPanelProps} props - Component props.
* @returns {React.ReactElement} Panel to contain privacy and ratings settings.
*/
export default function PrivacyAndRatingPanel( {
attributes,
setAttributes,
privateEnabledForSite,
}: VideoControlProps ): React.ReactElement {
}: PrivacyAndRatingPanelProps ): React.ReactElement {
return <PrivacyAndRatingSettings { ...{ attributes, setAttributes, privateEnabledForSite } } />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ import {
/**
* Types
*/
import type { VideoControlProps } from '../../types';
import type { PrivacyAndRatingPanelProps } from '../../types';
import type React from 'react';

/**
* React component that renders the settings within the privacy and ratings panel.
*
* @param {VideoControlProps} props - Component props.
* @returns {React.ReactElement} - Settings to change video's privacy and ratings.
* @param {PrivacyAndRatingPanelProps} props - Component props.
* @returns {React.ReactElement} Settings to change video's privacy and ratings.
*/
export default function PrivacyAndRatingSettings( {
attributes,
setAttributes,
privateEnabledForSite,
}: VideoControlProps ): React.ReactElement {
videoBelongToSite,
}: PrivacyAndRatingPanelProps ): React.ReactElement {
const { privacySetting, rating, allowDownload, displayEmbed } = attributes;

const privacyLabels = {
Expand Down Expand Up @@ -82,6 +83,7 @@ export default function PrivacyAndRatingSettings( {
onChange={ value => {
setAttributes( { rating: value } );
} }
disabled={ ! videoBelongToSite }
/>

<SelectControl
Expand All @@ -104,6 +106,7 @@ export default function PrivacyAndRatingSettings( {
} }
value={ String( privacySetting ) }
options={ [ privacyOptionSiteDefault, privacyOptionPublic, privacyOptionPrivate ] }
disabled={ ! videoBelongToSite }
/>

<ToggleControl
Expand All @@ -112,6 +115,7 @@ export default function PrivacyAndRatingSettings( {
onChange={ value => {
setAttributes( { allowDownload: value } );
} }
disabled={ ! videoBelongToSite }
/>

<ToggleControl
Expand All @@ -124,6 +128,7 @@ export default function PrivacyAndRatingSettings( {
'Gives viewers the option to share the video link and HTML embed code',
'jetpack-videopress-pkg'
) }
disabled={ ! videoBelongToSite }
/>
</PanelBody>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,17 @@ export default function VideoPressEdit( {
attributes={ attributes }
setAttributes={ setAttributes }
isGeneratingPoster={ isGeneratingPoster }
videoBelongToSite={ videoBelongToSite }
/>

<PrivacyAndRatingPanel
{ ...{ attributes, setAttributes, isRequestingVideoData, privateEnabledForSite } }
{ ...{
attributes,
setAttributes,
isRequestingVideoData,
privateEnabledForSite,
videoBelongToSite,
} }
/>
</InspectorControls>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ export type VideoControlProps = {

export type PosterPanelProps = VideoControlProps & {
isGeneratingPoster?: boolean;
videoBelongToSite?: boolean;
};

export type PrivacyAndRatingPanelProps = VideoControlProps & {
videoBelongToSite?: boolean;
};

export type VideoEditProps = VideoControlProps;
Expand Down