Skip to content

Commit

Permalink
Merge branch 'trunk' into renovate/pnpm-9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftbj authored Jan 30, 2025
2 parents e8b4408 + 42477b9 commit 708c2a4
Show file tree
Hide file tree
Showing 54 changed files with 1,497 additions and 262 deletions.
743 changes: 738 additions & 5 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions projects/packages/account-protection/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
node_modules/
wordpress/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Ignoring test files from git only


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: No functional changes.


1 change: 1 addition & 0 deletions projects/packages/blocks/src/class-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public static function is_gutenberg_version_available( $version_requirements, $s
! $version_available
&& ! self::is_standalone_block() // This is only useful in Jetpack.
) {
$slug = Jetpack_Gutenberg::remove_extension_prefix( $slug );
Jetpack_Gutenberg::set_extension_unavailable(
$slug,
'incorrect_gutenberg_version',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Forms: Hide empty radio fields.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Minor fix


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Forms: rename contact form block placeholder to just "Forms".
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ContactFormPlaceholder = ( { changeStatus, isLoading, isModuleActiv
<Placeholder
icon={ settings.icon.src }
instructions={ __(
'You’ll need to activate the Contact Form feature to use this block.',
'You’ll need to activate the Forms feature to use this block.',
'jetpack-forms'
) }
label={ settings.title }
Expand All @@ -23,8 +23,8 @@ export const ContactFormPlaceholder = ( { changeStatus, isLoading, isModuleActiv
variant="secondary"
>
{ isLoading
? __( 'Activating Contact Form', 'jetpack-forms' )
: __( 'Activate Contact Form', 'jetpack-forms', 0 ) }
? __( 'Activating Forms', 'jetpack-forms' )
: __( 'Activate Forms', 'jetpack-forms', 0 ) }
</Button>
</Placeholder>
);
Expand Down
12 changes: 11 additions & 1 deletion projects/packages/forms/src/blocks/contact-form/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@
}
}

.block-editor-block-list__layout.wp-block-jetpack-field-option-radio,
.block-editor-block-list__layout.wp-block-jetpack-field-option-checkbox {
gap: 0;
align-items: center;

> .wp-block {
flex: initial;
}
}

.block-list-appender {
flex: 0 0 100%;
}
Expand Down Expand Up @@ -468,7 +478,7 @@
.jetpack-field-option.field-option-radio,
.wp-block-jetpack-field-option-radio {
.jetpack-option__type {
transform: translateY(15%); /* Small offset to compensate the slightly odd perceived alignment that's due to the circular shape */
transform: translateY(5%); /* Small offset to compensate the slightly odd perceived alignment that's due to the circular shape */
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,10 @@ class="below-label__label ' . ( $this->is_error() ? ' form-error' : '' ) . '"
* @return string HTML
*/
public function render_field( $type, $id, $label, $value, $class, $placeholder, $required, $required_field_text ) {
if ( ! $this->is_field_renderable( $type ) ) {
return null;
}

$class .= ' grunion-field';

$form_style = $this->get_form_style();
Expand Down Expand Up @@ -1141,6 +1145,33 @@ private function maybe_override_type() {
return $type;
}

/**
* Determines if a form field is valid.
*
* Add checks here to confirm if any given form field
* is configured correctly and thus should be rendered
* on the frontend.
*
* @param string $type - the field type.
*
* @return bool
*/
public function is_field_renderable( $type ) {
// Check for valid radio field.
if ( $type === 'radio' ) {
$options = (array) $this->get_attribute( 'options' );
$non_empty_options = array_filter(
$options,
function ( $option ) {
return $option !== '';
}
);
return count( $non_empty_options ) > 0;
}

return true;
}

/**
* Gets the form style based on its CSS class.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Dashboard: add launchpad
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: No functional changes.


5 changes: 5 additions & 0 deletions projects/packages/jetpack-mu-wpcom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@babel/core": "7.26.0",
"@babel/plugin-transform-react-jsx": "7.25.9",
"@babel/preset-react": "7.26.3",
"@babel/runtime": "7.24.7",
"@playwright/test": "1.48.2",
"@types/node": "^20.4.2",
"@types/react": "^18.2.28",
Expand All @@ -48,9 +49,11 @@
"dependencies": {
"@automattic/calypso-color-schemes": "3.1.3",
"@automattic/color-studio": "4.0.0",
"@automattic/components": "2.2.0",
"@automattic/i18n-utils": "1.2.3",
"@automattic/jetpack-base-styles": "workspace:*",
"@automattic/jetpack-shared-extension-utils": "workspace:*",
"@automattic/launchpad": "1.1.0",
"@automattic/page-pattern-modal": "1.1.5",
"@automattic/typography": "1.0.0",
"@popperjs/core": "^2.11.8",
Expand All @@ -73,6 +76,8 @@
"@wordpress/url": "4.16.0",
"clsx": "2.1.1",
"debug": "4.4.0",
"events": "^3.3.0",
"i18n-calypso": "7.0.0",
"preact": "^10.13.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ public static function disable_jetpack_donate() {

// Tell Jetpack to mark the donations feature as unavailable.
Jetpack_Gutenberg::set_extension_unavailable(
'jetpack/donations',
'donations',
esc_html__( 'Jetpack donations is disabled in favour of Newspack donations.', 'jetpack-mu-wpcom' )
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { Gridicon, ConfettiAnimation } from '@automattic/components';
import { Button, Modal, Tooltip } from '@wordpress/components';
import { useCopyToClipboard } from '@wordpress/compose';
import { useState, useEffect } from '@wordpress/element';
import { Icon, copy } from '@wordpress/icons';
import { useTranslate } from 'i18n-calypso';
import { wpcomTrackEvent } from '../../../common/tracks';

import './celebrate-launch-modal.scss';

/**
* CelebrateLaunchModal component
*
* @param {object} props - Props.
* @param {Function} props.onRequestClose - Callback on modal close.
* @param {object} props.sitePlan - The site plan.
* @param {string} props.siteDomain - The site domain.
* @param {string} props.siteUrl - The site URL.
* @param {boolean} props.hasCustomDomain - Whether the site has a custom domain.
*
* @return {JSX.Element} The CelebrateLaunchModal component.
*/
export default function CelebrateLaunchModal( {
onRequestClose,
sitePlan,
siteDomain: siteSlug,
siteUrl,
hasCustomDomain,
} ) {
const translate = useTranslate();
const isPaidPlan = !! sitePlan;
const isBilledMonthly = sitePlan?.product_slug?.includes( 'monthly' );
const [ clipboardCopied, setClipboardCopied ] = useState( false );

useEffect( () => {
wpcomTrackEvent( `calypso_launchpad_celebration_modal_view`, {
product_slug: sitePlan?.product_slug,
} );
}, [ sitePlan?.product_slug ] );

/**
* Render the upsell content.
*
* @return {JSX.Element} The upsell content.
*/
function renderUpsellContent() {
let contentElement;
let buttonText;
let buttonHref;

if ( ! isPaidPlan && ! hasCustomDomain ) {
contentElement = (
<p>
{ translate(
'Supercharge your website with a {{strong}}custom address{{/strong}} that matches your blog, brand, or business.',
{ components: { strong: <strong /> } }
) }
</p>
);
buttonText = translate( 'Claim your domain' );
buttonHref = `https://wordpress.com/domains/add/${ siteSlug }`;
} else if ( isPaidPlan && isBilledMonthly && ! hasCustomDomain ) {
contentElement = (
<p>
{ translate(
'Interested in a custom domain? It’s free for the first year when you switch to annual billing.'
) }
</p>
);
buttonText = translate( 'Claim your domain' );
buttonHref = `https://wordpress.com/domains/add/${ siteSlug }`;
} else if ( isPaidPlan && ! hasCustomDomain ) {
contentElement = (
<p>
{ translate(
'Your paid plan includes a domain name {{strong}}free for one year{{/strong}}. Choose one that’s easy to remember and even easier to share.',
{ components: { strong: <strong /> } }
) }
</p>
);
buttonText = translate( 'Claim your free domain' );
buttonHref = `https://wordpress.com/domains/add/${ siteSlug }`;
} else if ( hasCustomDomain ) {
return null;
}

return (
<div className="launched__modal-upsell">
<div className="launched__modal-upsell-content">{ contentElement }</div>
<Button
variant="primary"
href={ buttonHref }
onClick={ () =>
wpcomTrackEvent( `calypso_launchpad_celebration_modal_upsell_clicked`, {
product_slug: sitePlan?.product_slug,
} )
}
>
<span>{ buttonText }</span>
</Button>
</div>
);
}

const ref = useCopyToClipboard( siteSlug, () => setClipboardCopied( true ) );

return (
<Modal onRequestClose={ onRequestClose } className="launched__modal">
<ConfettiAnimation />
<div className="launched__modal-content">
<div className="launched__modal-text">
<h1 className="launched__modal-heading">
{ translate( 'Congrats, your site is live!' ) }
</h1>
<p className="launched__modal-body">
{ translate( 'Now you can head over to your site and share it with the world.' ) }
</p>
</div>
<div className="launched__modal-actions">
<div className="launched__modal-site">
<div className="launched__modal-domain">
<p className="launched__modal-domain-text">{ siteSlug }</p>
<Tooltip
text={ clipboardCopied ? translate( 'Copied to clipboard!' ) : '' }
delay={ 0 }
hideOnClick={ false }
>
<Button
label={ translate( 'Copy URL' ) }
className="launchpad__clipboard-button"
borderless
size="compact"
ref={ ref }
onMouseLeave={ () => setClipboardCopied( false ) }
>
<Icon icon={ copy } size={ 18 } />
</Button>
</Tooltip>
</div>

<Button href={ siteUrl } target="_blank" className="launched__modal-view-site">
<Gridicon icon="domains" size={ 18 } />
<span className="launched__modal-view-site-text">{ translate( 'View site' ) }</span>
</Button>
</div>
</div>
</div>
{ renderUpsellContent() }
</Modal>
);
}
Loading

0 comments on commit 708c2a4

Please sign in to comment.