@@ -6,10 +6,9 @@ import {
66 useSuspenseQuery ,
77 keepPreviousData ,
88} from '@tanstack/react-query' ;
9- import { useNavigate } from '@tanstack/react-router' ;
109import { Button , Modal } from '@wordpress/components' ;
1110import { filterSortAndPaginate } from '@wordpress/dataviews' ;
12- import { __ , sprintf } from '@wordpress/i18n' ;
11+ import { __ } from '@wordpress/i18n' ;
1312import { getISOWeek , getISOWeekYear } from 'date-fns' ;
1413import deepmerge from 'deepmerge' ;
1514import { useState , useEffect } from 'react' ;
@@ -19,7 +18,7 @@ import { useAuth } from '../app/auth';
1918import { useAppContext } from '../app/context' ;
2019import { usePersistentView } from '../app/hooks/use-persistent-view' ;
2120import { sitesRoute } from '../app/router/sites' ;
22- import { DataViewsEmptyState } from '../components/dataviews' ;
21+ import { DataViewsEmptyStateV2 } from '../components/dataviews' ;
2322import OptInSurvey from '../components/opt-in-survey' ;
2423import { PageHeader } from '../components/page-header' ;
2524import PageLayout from '../components/page-layout' ;
@@ -33,9 +32,8 @@ import {
3332 recordViewChanges ,
3433 sanitizeFields ,
3534} from './dataviews' ;
36- import EmptySitesState from './empty-sites-state' ;
35+ import { EmptySitesStateContent } from './empty-sites-state' ;
3736import { InviteAcceptedFlashMessage } from './invite-accepted-flash-message' ;
38- import noSitesIllustration from './no-sites-illustration.svg' ;
3937import { SitesNotices } from './notices' ;
4038import { OptInWelcomeModal } from './welcome-modal' ;
4139import type {
@@ -183,7 +181,6 @@ function filterSortAndPaginateSites( sites: Site[], view: View, totalItems: numb
183181
184182export default function Sites ( ) {
185183 const { recordTracksEvent } = useAnalytics ( ) ;
186- const navigate = useNavigate ( { from : sitesRoute . fullPath } ) ;
187184 const queryClient = useQueryClient ( ) ;
188185 const currentSearchParams = sitesRoute . useSearch ( ) ;
189186 const isRestoringAccount = ! ! currentSearchParams . restored ;
@@ -228,24 +225,7 @@ export default function Sites() {
228225 updateView ( nextView ) ;
229226 } ;
230227
231- const hasFilterOrSearch = ( view . filters && view . filters . length > 0 ) || view . search ;
232-
233- const emptyTitle = hasFilterOrSearch ? __ ( 'No sites found' ) : __ ( 'No sites' ) ;
234-
235- const userHasNoSites = user . site_count === 0 ;
236-
237- let emptyDescription = __ ( 'Get started by creating a new site.' ) ;
238- if ( view . search ) {
239- emptyDescription = sprintf (
240- // Translators: %s is the search term used when looking for sites by title or domain name.
241- __ (
242- 'Your search for “%s” did not match any sites. Try searching by the site title or domain name.'
243- ) ,
244- view . search
245- ) ;
246- } else if ( hasFilterOrSearch ) {
247- emptyDescription = __ ( 'Your search did not match any sites.' ) ;
248- }
228+ const userHasSites = user . site_count > 0 ;
249229
250230 useEffect ( ( ) => {
251231 if ( sites ) {
@@ -261,37 +241,6 @@ export default function Sites() {
261241 ? filterSortAndPaginateSites ( sites ?? [ ] , view , totalItems ?? 0 )
262242 : filterSortAndPaginate ( sites ?? [ ] , view , fields ) ;
263243
264- const emptyState = (
265- < DataViewsEmptyState
266- title = { emptyTitle }
267- description = { emptyDescription }
268- illustration = { < img src = { noSitesIllustration } alt = "" width = { 408 } height = { 280 } /> }
269- actions = {
270- < >
271- { view . search && (
272- < Button
273- __next40pxDefaultSize
274- variant = "secondary"
275- onClick = { ( ) => {
276- navigate ( {
277- search : {
278- ...currentSearchParams ,
279- search : undefined ,
280- } ,
281- } ) ;
282- } }
283- >
284- { __ ( 'Clear search' ) }
285- </ Button >
286- ) }
287- < Button __next40pxDefaultSize variant = "primary" onClick = { ( ) => setIsModalOpen ( true ) } >
288- { __ ( 'Add new site' ) }
289- </ Button >
290- </ >
291- }
292- />
293- ) ;
294-
295244 return (
296245 < >
297246 { ! isDashboardBackport ( ) && < OptInWelcomeModal /> }
@@ -306,7 +255,7 @@ export default function Sites() {
306255 < PageHeader
307256 title = { __ ( 'Sites' ) }
308257 actions = {
309- userHasNoSites ? null : (
258+ userHasSites && (
310259 < Button
311260 variant = "primary"
312261 onClick = { ( ) => setIsModalOpen ( true ) }
@@ -325,21 +274,34 @@ export default function Sites() {
325274 </ >
326275 }
327276 >
328- { ! userHasNoSites ? (
277+ { userHasSites ? (
329278 < SitesDataViews
330279 view = { view }
331280 sites = { filteredData }
332281 fields = { fields }
333282 actions = { actions }
334283 isLoading = { isLoadingSites || ( isPlaceholderData && hasNoData ) }
335284 isPlaceholderData = { isPlaceholderData }
336- empty = { emptyState }
285+ empty = {
286+ < DataViewsEmptyStateV2
287+ title = { __ ( 'No domains match your search' ) }
288+ description = { __ ( 'Try again, or add a new domain with the options below.' ) }
289+ isBorderless
290+ >
291+ < EmptySitesStateContent />
292+ </ DataViewsEmptyStateV2 >
293+ }
337294 paginationInfo = { paginationInfo }
338295 onChangeView = { handleViewChange }
339296 onResetView = { resetView }
340297 />
341298 ) : (
342- < EmptySitesState />
299+ < DataViewsEmptyStateV2
300+ title = { __ ( 'Add your first domain name' ) }
301+ description = { __ ( 'Establish a unique online identity for your site.' ) }
302+ >
303+ < EmptySitesStateContent />
304+ </ DataViewsEmptyStateV2 >
343305 ) }
344306 </ PageLayout >
345307 { /* ExPlat's Evergreen A/A Test Experiment:
0 commit comments