-
Notifications
You must be signed in to change notification settings - Fork 2k
/
availability-messages.js
387 lines (358 loc) · 11.6 KB
/
availability-messages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/* eslint-disable no-case-declarations */
/**
* External dependencies
*/
import React from 'react';
import { translate } from 'i18n-calypso';
import moment from 'moment';
/**
* Internal dependencies
*/
import { getTld } from 'lib/domains';
import {
CALYPSO_CONTACT,
INCOMING_DOMAIN_TRANSFER_STATUSES_IN_PROGRESS,
MAP_EXISTING_DOMAIN,
} from 'lib/url/support';
import { domainAvailability } from 'lib/domains/constants';
import {
domainManagementTransferToOtherSite,
domainManagementTransferIn,
domainMapping,
domainTransferIn,
} from 'my-sites/domains/paths';
function getAvailabilityNotice( domain, error, errorData ) {
const tld = domain ? getTld( domain ) : null;
const { site, maintenanceEndTime, availabilityPreCheck } = errorData || {};
// The message is set only when there is a valid error
// and the conditions of the corresponding switch block are met.
// Consumers should check for the message prop in order
// to determine whether to display the notice
// See for e.g., client/components/domains/register-domain-step/index.jsx
let message,
severity = 'error';
switch ( error ) {
case domainAvailability.REGISTERED:
message = translate(
'{{strong}}%(domain)s{{/strong}} is already connected to a WordPress.com site.',
{
args: { domain },
components: {
strong: <strong />,
},
}
);
break;
case domainAvailability.REGISTERED_SAME_SITE:
message = translate( '{{strong}}%(domain)s{{/strong}} is already registered on this site.', {
args: { domain },
components: {
strong: <strong />,
},
} );
break;
case domainAvailability.REGISTERED_OTHER_SITE_SAME_USER:
message = translate(
'{{strong}}%(domain)s{{/strong}} is already registered on your site %(site)s. Do you want to move it to this site? ' +
'{{a}}Yes, move it to this site.{{/a}}',
{
args: { domain, site },
components: {
strong: <strong />,
a: (
<a
rel="noopener noreferrer"
href={ domainManagementTransferToOtherSite( site, domain ) }
/>
),
},
}
);
break;
case domainAvailability.IN_REDEMPTION:
message = translate(
'{{strong}}%(domain)s{{/strong}} is not eligible to register or transfer since it is in {{redemptionLink}}redemption{{/redemptionLink}}. If you own this domain, please contact your current registrar to {{aboutRenewingLink}}redeem the domain{{/aboutRenewingLink}}.',
{
args: { domain },
components: {
strong: <strong />,
redemptionLink: (
<a
rel="noopener noreferrer"
href="https://www.icann.org/resources/pages/grace-2013-05-03-en"
/>
),
aboutRenewingLink: (
<a
rel="noopener noreferrer"
href="https://www.icann.org/news/blog/do-you-have-a-domain-name-here-s-what-you-need-to-know-part-5"
/>
),
},
}
);
break;
case domainAvailability.MAPPED_SAME_SITE_TRANSFERRABLE:
message = translate(
'{{strong}}%(domain)s{{/strong}} is already connected to this site, but registered somewhere else. Do you want to move ' +
'it from your current domain provider to WordPress.com so you can manage the domain and the site ' +
'together? {{a}}Yes, transfer it to WordPress.com.{{/a}}',
{
args: { domain },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ domainTransferIn( site, domain ) } />,
},
}
);
break;
case domainAvailability.MAPPED_SAME_SITE_NOT_TRANSFERRABLE:
message = translate( '{{strong}}%(domain)s{{/strong}} is already connected to this site.', {
args: { domain },
components: {
strong: <strong />,
},
} );
break;
case domainAvailability.MAPPED_OTHER_SITE_SAME_USER:
message = translate(
'{{strong}}%(domain)s{{/strong}} is already connected to your site %(site)s. If you want to connect it to this site ' +
'instead, we will be happy to help you do that. {{a}}Contact us.{{/a}}',
{
args: { domain, site },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ CALYPSO_CONTACT } />,
},
}
);
break;
case domainAvailability.TRANSFER_PENDING_SAME_USER:
message = translate(
'{{strong}}%(domain)s{{/strong}} is pending transfer. {{a}}Check the transfer status{{/a}} to learn more.',
{
args: { domain },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ domainManagementTransferIn( site, domain ) } />,
},
}
);
break;
case domainAvailability.TRANSFER_PENDING:
message = translate(
"{{strong}}%(domain)s{{/strong}} is pending transfer and can't be connected to WordPress.com right now. " +
'{{a}}Learn More.{{/a}}',
{
args: { domain },
components: {
strong: <strong />,
a: (
<a rel="noopener noreferrer" href={ INCOMING_DOMAIN_TRANSFER_STATUSES_IN_PROGRESS } />
),
},
}
);
break;
case domainAvailability.NOT_REGISTRABLE:
if ( tld ) {
message = translate(
'To use this domain on your site, you can register it elsewhere first and then add it here. {{a}}Learn more{{/a}}.',
{
args: { tld },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ MAP_EXISTING_DOMAIN } />,
},
}
);
severity = 'info';
}
break;
case domainAvailability.MAINTENANCE:
if ( tld ) {
let maintenanceEnd = translate( 'shortly', {
comment: 'If a specific maintenance end time is unavailable, we will show this instead.',
} );
if ( maintenanceEndTime ) {
maintenanceEnd = moment.unix( maintenanceEndTime ).fromNow();
}
message = translate(
'Domains ending with {{strong}}.%(tld)s{{/strong}} are undergoing maintenance. Please ' +
'try a different extension or check back %(maintenanceEnd)s.',
{
args: {
tld,
maintenanceEnd,
},
components: {
strong: <strong />,
},
}
);
severity = 'info';
}
break;
case domainAvailability.PURCHASES_DISABLED:
let maintenanceEnd = translate( 'shortly', {
comment: 'If a specific maintenance end time is unavailable, we will show this instead.',
} );
if ( maintenanceEndTime ) {
maintenanceEnd = moment.unix( maintenanceEndTime ).fromNow();
}
message = translate(
'Domain registration is unavailable at this time. Please select a free subdomain ' +
'or check back %(maintenanceEnd)s.',
{
args: { maintenanceEnd },
}
);
severity = 'info';
break;
case domainAvailability.MAPPABLE:
case domainAvailability.AVAILABLE:
case domainAvailability.TLD_NOT_SUPPORTED:
case domainAvailability.TLD_NOT_SUPPORTED_AND_DOMAIN_NOT_AVAILABLE:
case domainAvailability.TLD_NOT_SUPPORTED_TEMPORARILY:
case domainAvailability.UNKNOWN:
// unavailable domains are displayed in the search results, not as a notice OR
// domain registrations are closed, in which case it is handled in parent
break;
case domainAvailability.EMPTY_RESULTS:
message = translate(
"Sorry, we weren't able to generate any domain name suggestions for that search term. Please try a different set of keywords."
);
break;
case domainAvailability.DISALLOWED:
if ( domain && domain.toLowerCase().indexOf( 'wordpress' ) > -1 ) {
message = translate(
'Due to {{a1}}trademark policy{{/a1}}, ' +
'we are not able to allow domains containing {{strong}}WordPress{{/strong}} to be registered or mapped here. ' +
'Please {{a2}}contact support{{/a2}} if you have any questions.',
{
components: {
strong: <strong />,
a1: (
<a
rel="noopener noreferrer"
href="http://wordpressfoundation.org/trademark-policy/"
/>
),
a2: <a href={ CALYPSO_CONTACT } />,
},
}
);
} else {
message = translate(
'Domain cannot be mapped to a WordPress.com blog because of disallowed term.'
);
}
break;
case domainAvailability.FORBIDDEN_SUBDOMAIN:
message = translate(
"Subdomains starting with 'www.' cannot be mapped to a WordPress.com blog"
);
break;
case domainAvailability.FORBIDDEN:
message = translate( 'Only the owner of the domain can map its subdomains.' );
break;
case domainAvailability.WPCOM_STAGING_DOMAIN:
message = translate( 'This domain is a reserved WordPress.com staging domain' );
break;
case domainAvailability.INVALID_TLD:
case domainAvailability.INVALID:
message = translate( 'Sorry, %(domain)s does not appear to be a valid domain name.', {
args: { domain: domain },
} );
break;
case domainAvailability.MAPPED:
message = translate( 'This domain is already mapped to a WordPress.com site.' );
break;
case domainAvailability.DOTBLOG_SUBDOMAIN:
case domainAvailability.RESTRICTED:
message = translate(
'You cannot map another WordPress.com subdomain - try creating a new site or one of the custom domains below.'
);
break;
case domainAvailability.RECENTLY_UNMAPPED:
message = translate(
'This domain was recently in use by someone else and is not available to map yet. ' +
'Please try again later or contact support.'
);
break;
case domainAvailability.RECENTLY_EXPIRED:
message = translate(
'This domain expired recently. To get it back please {{a}}contact support{{/a}}.',
{
components: {
a: <a href={ CALYPSO_CONTACT } />,
},
}
);
break;
case domainAvailability.UNKOWN_ACTIVE:
message = translate(
'This domain is still active and is not available to map yet. ' +
'Please try again later or contact support.'
);
break;
case domainAvailability.EMPTY_QUERY:
message = translate( 'Please enter a domain name or keyword.' );
break;
case domainAvailability.INVALID_QUERY:
message = translate(
'Your search term can only contain alphanumeric characters, spaces, dots, or hyphens.'
);
break;
case domainAvailability.AVAILABILITY_CHECK_ERROR:
message = translate(
'Sorry, an error occurred when checking the availability of this domain. Please try again in a few minutes.'
);
break;
case domainAvailability.DOMAIN_SUGGESTIONS_THROTTLED:
message = translate(
'You have made too many domain suggestions requests in a short time. Please wait a few minutes and try again.'
);
break;
case domainAvailability.TRANSFERRABLE:
if ( availabilityPreCheck ) {
message = translate(
'Sorry, the domain name you selected is not available. Please choose another domain.'
);
}
break;
case domainAvailability.AVAILABLE_PREMIUM:
message = translate(
"Sorry, {{strong}}%(domain)s{{/strong}} is a premium domain. We don't support purchases of premium domains on WordPress.com, but if you purchase this domain elsewhere, you can {{a}}map it to your site{{/a}}.",
{
args: { domain },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ domainMapping( site, domain ) } />,
},
}
);
break;
case domainAvailability.TRANSFERRABLE_PREMIUM:
message = translate(
"Sorry, {{strong}}%(domain)s{{/strong}} is a premium domain. We don't support transfers of premium domains on WordPress.com, but if you are the owner of this domain, you can {{a}}map it to your site{{/a}}.",
{
args: { domain },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ domainMapping( site, domain ) } />,
},
}
);
break;
default:
message = translate(
'Sorry, there was a problem processing your request. Please try again in a few minutes.'
);
}
return {
message,
severity,
};
}
export { getAvailabilityNotice };