Skip to content

Commit dbf79b4

Browse files
committed
Print service name based on the instance type
1 parent 166f58a commit dbf79b4

File tree

7 files changed

+25
-9
lines changed

7 files changed

+25
-9
lines changed

client/dashboard/app-a4a/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Logo, LoadingLogo } from './logo';
33
import './style.scss';
44

55
boot( {
6+
instanceType: 'a4a',
67
basePath: '/v2-a4a',
78
mainRoute: '/overview',
89
LoadingLogo,

client/dashboard/app-dotcom/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Logo from './logo';
33
import './style.scss';
44

55
boot( {
6+
instanceType: 'dotcom',
67
basePath: '/v2',
78
mainRoute: '/sites',
89
Logo,

client/dashboard/app/context.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createContext, useContext } from 'react';
22

3+
export type InstanceType = 'dotcom' | 'a4a';
34
export type SiteFeatureSupports = {
45
deployments: boolean;
56
performance: boolean;
@@ -11,6 +12,7 @@ export type SiteFeatureSupports = {
1112
};
1213

1314
export type AppConfig = {
15+
instanceType: InstanceType;
1416
basePath: string;
1517
mainRoute: string;
1618
Logo: React.FC | null;
@@ -28,6 +30,7 @@ export type AppConfig = {
2830
};
2931

3032
const AppContext = createContext< AppConfig >( {
33+
instanceType: 'dotcom',
3134
basePath: '',
3235
mainRoute: '',
3336
Logo: null,

client/dashboard/domains/name-servers/form.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ import { createInterpolateElement } from '@wordpress/element';
1111
import { __, sprintf } from '@wordpress/i18n';
1212
import { useCallback, useMemo, useState } from 'react';
1313
import Notice from '../../components/notice';
14+
import { getServiceName } from '../../utils/service-name';
1415
import { NameServerInput, validateField } from './form-input';
1516
import {
1617
NameServerField,
1718
MIN_NAMESERVER_LENGTH,
1819
MAX_NAMESERVER_LENGTH,
1920
WPCOM_DEFAULT_NAMESERVERS,
20-
ServiceName,
2121
} from './types';
2222
import UpsellNudge from './upsell-nudge';
2323
import { areAllWpcomNameServers } from './utils';
24+
import type { InstanceType } from '../../app/context';
2425

2526
interface Props {
2627
domainName: string;
27-
serviceName: ServiceName;
28+
instanceType: InstanceType;
2829
showUpsellNudge?: boolean;
2930
nameservers?: string[];
3031
isBusy?: boolean;
@@ -34,7 +35,7 @@ interface Props {
3435

3536
export default function NameServersForm( {
3637
domainName,
37-
serviceName,
38+
instanceType,
3839
showUpsellNudge,
3940
nameservers = [],
4041
isBusy,
@@ -136,9 +137,9 @@ export default function NameServersForm( {
136137
<VStack spacing={ 4 }>
137138
<ToggleControl
138139
label={ sprintf(
139-
/* translators: %s is the name of the service */
140+
/* translators: %s is the name of the service like: WordPress.com */
140141
__( 'Use %s name servers' ),
141-
serviceName
142+
getServiceName( instanceType )
142143
) }
143144
checked={ useWpcomNameservers }
144145
disabled={ isBusy }
@@ -190,7 +191,7 @@ export default function NameServersForm( {
190191
key={ index }
191192
index={ index }
192193
field={ nameServerFields[ index ] }
193-
disabled={ useWpcomNameservers || isBusy }
194+
disabled={ useWpcomNameservers || !! isBusy }
194195
onChange={ handleNameServerChange }
195196
onBlur={ handleNameServerBlur }
196197
/>

client/dashboard/domains/name-servers/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Card, CardBody } from '@wordpress/components';
22
import { useDispatch } from '@wordpress/data';
33
import { __ } from '@wordpress/i18n';
44
import { store as noticesStore } from '@wordpress/notices';
5+
import { useAppContext } from '../../app/context';
56
import {
67
useDomainNameserversQuery,
78
useUpdateNameserversMutation,
@@ -13,6 +14,7 @@ import NameServersForm from './form';
1314
import './styles.scss';
1415

1516
export default function NameServers() {
17+
const { instanceType } = useAppContext();
1618
const { domainName } = domainRoute.useParams();
1719
const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore );
1820
const { data: nameservers, error: queryError } = useDomainNameserversQuery( domainName );
@@ -31,7 +33,7 @@ export default function NameServers() {
3133
<CardBody className="domains-management__name-servers">
3234
<NameServersForm
3335
domainName={ domainName }
34-
serviceName="WordPress.com"
36+
instanceType={ instanceType }
3537
queryError={ queryError?.message }
3638
isBusy={ isUpdatingNameservers }
3739
nameservers={ nameservers }

client/dashboard/domains/name-servers/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ export interface NameServerField {
1212
error: string;
1313
touched: boolean;
1414
}
15-
16-
export type ServiceName = 'WordPress.com' | string;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { InstanceType } from '../app/context';
2+
3+
export function getServiceName( type: InstanceType ) {
4+
switch ( type ) {
5+
case 'dotcom':
6+
return 'WordPress.com';
7+
case 'a4a':
8+
return 'A4A';
9+
}
10+
}

0 commit comments

Comments
 (0)