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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion apps/studio/src/lib/site-runtime-copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,36 @@ import {
type SiteFileAccess,
} from '@studio/common/lib/site-file-access';
import { SITE_RUNTIME_PLAYGROUND, type SiteRuntime } from '@studio/common/lib/site-runtime';
import { createInterpolateElement } from '@wordpress/element';
import { useI18n } from '@wordpress/react-i18n';
import { LearnMoreLink } from 'src/components/learn-more';

// Explainer copy shown under the PHP runtime control in the create/edit site
// forms and in the read-only site settings.
export function RuntimeDescription( { runtime }: { runtime: SiteRuntime } ) {
export function RuntimeDescription( {
runtime,
learnMoreLink,
}: {
runtime: SiteRuntime;
learnMoreLink?: boolean;
} ) {
const { __ } = useI18n();

if ( learnMoreLink ) {
return (
<>
{ createInterpolateElement(
runtime === SITE_RUNTIME_PLAYGROUND
? __( 'Runs the site in an isolated WordPress Playground sandbox. <learn_more_link />' )
: __( 'Runs the site with native PHP for the best performance. <learn_more_link />' ),
{
learn_more_link: <LearnMoreLink docsLinksKey="docsPhpRuntimes" />,
}
) }
</>
);
}

return (
<>
{ runtime === SITE_RUNTIME_PLAYGROUND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { SiteFormError } from 'src/components/site-form-error';
import TextControlComponent from 'src/components/text-control';
import { WPVersionSelector } from 'src/components/wp-version-selector';
import { cx } from 'src/lib/cx';
import { FileAccessDescription } from 'src/lib/site-runtime-copy';
import { FileAccessDescription, RuntimeDescription } from 'src/lib/site-runtime-copy';
import { useCheckCertificateTrustQuery } from 'src/stores/certificate-trust-api';
import type { BlueprintPreferredVersions } from '@studio/common/lib/blueprint-validation';
import type { CreateSiteFormValues, PathValidationResult } from 'src/hooks/use-add-site';
Expand Down Expand Up @@ -543,9 +543,7 @@ export const CreateSiteForm = ( {
__nextHasNoMarginBottom
/>
<span className="text-frame-text-secondary text-xs">
{ selectedRuntime === SITE_RUNTIME_NATIVE_PHP
? __( 'Runs the site with native PHP for the best performance.' )
: __( 'Runs the site in an isolated WordPress Playground sandbox.' ) }
<RuntimeDescription runtime={ selectedRuntime } learnMoreLink />
</span>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ const EditSiteDetails = ( { currentWpVersion, onSave }: EditSiteDetailsProps ) =
__nextHasNoMarginBottom
/>
<span className="text-frame-text-secondary text-xs">
<RuntimeDescription runtime={ selectedRuntime } />
<RuntimeDescription runtime={ selectedRuntime } learnMoreLink />
</span>
</label>

Expand Down