Skip to content

Commit 4d7f397

Browse files
authored
Add LearnHow link (#2353)
1 parent 849442d commit 4d7f397

File tree

5 files changed

+26
-42
lines changed

5 files changed

+26
-42
lines changed

src/components/content-tab-settings.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { PropsWithChildren } from 'react';
55
import { decodePassword } from 'common/lib/passwords';
66
import { CopyTextButton } from 'src/components/copy-text-button';
77
import DeleteSite from 'src/components/delete-site';
8+
import { LearnHowLink } from 'src/components/learn-more';
89
import { useGetWpVersion } from 'src/hooks/use-get-wp-version';
910
import { getIpcApi } from 'src/lib/get-ipc-api';
1011
import EditSiteDetails from 'src/modules/site-settings/edit-site-details';
@@ -105,17 +106,7 @@ export function ContentTabSettings( { selectedSite }: ContentTabSettingsProps )
105106
'You need to trust this certificate to prevent your browser from showing a secure connection warning.'
106107
) }
107108
</span>{ ' ' }
108-
<Button
109-
variant="link"
110-
onClick={ () => {
111-
getIpcApi().openURL(
112-
'https://developer.wordpress.com/docs/developer-tools/studio/ssl-in-studio/'
113-
);
114-
} }
115-
>
116-
{ __( 'Learn how' ) }
117-
<span aria-label={ __( '(opens in a web browser)' ) }>&#8599;</span>
118-
</Button>
109+
<LearnHowLink docsLinksKey="docsSslInStudio" />
119110
</div>
120111
) }
121112
</SettingsRow>

src/components/learn-more.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import { getIpcApi } from 'src/lib/get-ipc-api';
44
import { getLocalizedLink, type DocsLinkKey } from 'src/lib/get-localized-link';
55
import { useI18nLocale } from 'src/stores';
66

7-
export function LearnMoreLink( {
8-
docsLinksKey,
9-
className,
10-
}: {
7+
interface LinkProps {
118
docsLinksKey: DocsLinkKey;
129
className?: string;
13-
} ) {
10+
}
11+
12+
function MoreLink( { docsLinksKey, className, label }: LinkProps & { label: string } ) {
1413
const { __ } = useI18n();
1514
const locale = useI18nLocale();
1615

@@ -24,7 +23,19 @@ export function LearnMoreLink( {
2423
} }
2524
variant="link"
2625
>
27-
{ __( 'Learn more' ) }
26+
{ label }
2827
</Button>
2928
);
3029
}
30+
31+
export function LearnMoreLink( props: LinkProps ) {
32+
const { __ } = useI18n();
33+
34+
return <MoreLink { ...props } label={ __( 'Learn more' ) } />;
35+
}
36+
37+
export function LearnHowLink( props: LinkProps ) {
38+
const { __ } = useI18n();
39+
40+
return <MoreLink { ...props } label={ __( 'Learn how' ) } />;
41+
}

src/lib/get-localized-link.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const DOCS_LINKS = {
3434
docsXdebug: {
3535
en: 'https://developer.wordpress.com/docs/developer-tools/studio/xdebug/',
3636
},
37+
docsSslInStudio: {
38+
en: 'https://developer.wordpress.com/docs/developer-tools/studio/ssl-in-studio/',
39+
},
3740
} satisfies Record< `docs${ string }`, TranslatedLink >;
3841

3942
const BLOG_LINKS = {

src/modules/add-site/components/create-site-form.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import { FormEvent, useState, useEffect } from 'react';
77
import { generateCustomDomainFromSiteName } from 'common/lib/domains';
88
import Button from 'src/components/button';
99
import FolderIcon from 'src/components/folder-icon';
10-
import { LearnMoreLink } from 'src/components/learn-more';
10+
import { LearnMoreLink, LearnHowLink } from 'src/components/learn-more';
1111
import TextControlComponent from 'src/components/text-control';
1212
import { WPVersionSelector } from 'src/components/wp-version-selector';
1313
import { cx } from 'src/lib/cx';
14-
import { getIpcApi } from 'src/lib/get-ipc-api';
1514
import { AllowedPHPVersion } from 'src/lib/wordpress-provider/constants';
1615
import { useRootSelector } from 'src/stores';
1716
import { useCheckCertificateTrustQuery } from 'src/stores/certificate-trust-api';
@@ -380,17 +379,7 @@ export const CreateSiteForm = ( {
380379
{ __(
381380
'You need to manually add the Studio root certificate authority to your keychain and trust it to enable HTTPS.'
382381
) }{ ' ' }
383-
<Button
384-
variant="link"
385-
onClick={ () => {
386-
getIpcApi().openURL(
387-
'https://developer.wordpress.com/docs/developer-tools/studio/ssl-in-studio/'
388-
);
389-
} }
390-
>
391-
{ __( 'Learn how' ) }
392-
<span aria-label={ __( '(opens in a web browser)' ) }>&#8599;</span>
393-
</Button>
382+
<LearnHowLink docsLinksKey="docsSslInStudio" />
394383
</div>
395384
) }
396385
</div>

src/modules/site-settings/edit-site-details.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { generateCustomDomainFromSiteName, getDomainNameValidationError } from '
88
import { getWordPressVersionUrl } from 'common/lib/wordpress-version-utils';
99
import Button from 'src/components/button';
1010
import { ErrorInformation } from 'src/components/error-information';
11-
import { LearnMoreLink } from 'src/components/learn-more';
11+
import { LearnMoreLink, LearnHowLink } from 'src/components/learn-more';
1212
import Modal from 'src/components/modal';
1313
import TextControlComponent from 'src/components/text-control';
1414
import { Tooltip } from 'src/components/tooltip';
@@ -328,17 +328,7 @@ const EditSiteDetails = ( { currentWpVersion, onSave }: EditSiteDetailsProps ) =
328328
{ __(
329329
'You need to manually add the Studio certificate authority to your keychain and trust it.'
330330
) }{ ' ' }
331-
<Button
332-
variant="link"
333-
onClick={ () => {
334-
getIpcApi().openURL(
335-
'https://developer.wordpress.com/docs/developer-tools/studio/ssl-in-studio/'
336-
);
337-
} }
338-
>
339-
{ __( 'Learn how' ) }
340-
<span aria-label={ __( '(opens in a web browser)' ) }>&#8599;</span>
341-
</Button>
331+
<LearnHowLink docsLinksKey="docsSslInStudio" />
342332
</div>
343333
) }
344334
</div>

0 commit comments

Comments
 (0)