Skip to content

Commit 51a044a

Browse files
authored
Dashboard v2: lazy load php version (#103558)
1 parent 81a3c5b commit 51a044a

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

client/dashboard/app/router.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
siteCurrentPlanQuery,
1919
siteEngagementStatsQuery,
2020
siteMonitorUptimeQuery,
21-
sitePHPVersionQuery,
2221
} from './queries';
2322
import { queryClient } from './query-client';
2423
import Root from './root';
@@ -94,9 +93,6 @@ const siteOverviewRoute = createRoute( {
9493
site.jetpack && site.jetpack_modules.includes( 'monitor' )
9594
? queryClient.ensureQueryData( siteMonitorUptimeQuery( siteSlug ) )
9695
: undefined,
97-
site.is_wpcom_atomic
98-
? queryClient.ensureQueryData( sitePHPVersionQuery( siteSlug ) )
99-
: undefined,
10096
] );
10197
},
10298
} ).lazy( () =>

client/dashboard/sites/overview/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { wordpress } from '@wordpress/icons';
1212
import {
1313
siteQuery,
1414
siteMonitorUptimeQuery,
15-
sitePHPVersionQuery,
1615
siteCurrentPlanQuery,
1716
siteEngagementStatsQuery,
1817
} from '../../app/queries';
@@ -39,10 +38,6 @@ function SiteOverview() {
3938
...siteMonitorUptimeQuery( siteSlug ),
4039
enabled: site?.jetpack && site?.jetpack_modules.includes( 'monitor' ),
4140
} );
42-
const { data: phpVersion } = useQuery( {
43-
...sitePHPVersionQuery( siteSlug ),
44-
enabled: site?.is_wpcom_atomic,
45-
} );
4641
const { data: currentPlan } = useQuery( siteCurrentPlanQuery( siteSlug ) );
4742
const { data: engagementStats } = useQuery( siteEngagementStatsQuery( siteSlug ) );
4843

@@ -73,7 +68,7 @@ function SiteOverview() {
7368
}
7469
>
7570
<HStack alignment="flex-start" spacing={ 8 }>
76-
<Sidebar site={ site } phpVersion={ phpVersion } currentPlan={ currentPlan } />
71+
<Sidebar site={ site } currentPlan={ currentPlan } />
7772
<VStack spacing={ 8 }>
7873
<Card style={ { padding: '16px' } }>
7974
<VStack>

client/dashboard/sites/overview/site-card.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useQuery } from '@tanstack/react-query';
12
import {
23
__experimentalVStack as VStack,
34
__experimentalHStack as HStack,
@@ -8,23 +9,24 @@ import {
89
} from '@wordpress/components';
910
import { dateI18n } from '@wordpress/date';
1011
import { __, sprintf } from '@wordpress/i18n';
12+
import { sitePHPVersionQuery } from '../../app/queries';
1113
import { getSiteStatusLabel } from '../../utils/site-status';
1214
import SitePreview from '../site-preview';
1315
import type { Site, Plan } from '../../data/types';
1416

17+
function TextBlur( { text }: { text: string } ) {
18+
return <span className="text-blur" data-text={ text } />;
19+
}
20+
21+
function PHPVersion( { siteSlug }: { siteSlug: string } ) {
22+
return useQuery( sitePHPVersionQuery( siteSlug ) ).data ?? <TextBlur text="X.Y" />;
23+
}
24+
1525
/**
1626
* SiteCard component to display site information in a card format
1727
*/
18-
export default function SiteCard( {
19-
site,
20-
phpVersion,
21-
currentPlan,
22-
}: {
23-
site: Site;
24-
phpVersion?: string;
25-
currentPlan: Plan;
26-
} ) {
27-
const { options, URL: url, is_private } = site;
28+
export default function SiteCard( { site, currentPlan }: { site: Site; currentPlan: Plan } ) {
29+
const { options, URL: url, is_private, is_wpcom_atomic } = site;
2830
// If the site is a private A8C site, X-Frame-Options is set to same
2931
// origin.
3032
const iframeDisabled = site.is_a8c && is_private;
@@ -65,12 +67,18 @@ export default function SiteCard( {
6567
<HStack justify="space-between">
6668
<Field title={ __( 'Status' ) }>{ getSiteStatusLabel( site ) }</Field>
6769
</HStack>
68-
<HStack justify="space-between">
69-
{ options?.software_version && (
70-
<Field title={ __( 'WordPress' ) }>{ options.software_version }</Field>
71-
) }
72-
{ phpVersion && <Field title={ __( 'PHP' ) }>{ phpVersion }</Field> }
73-
</HStack>
70+
{ ( options?.software_version || is_wpcom_atomic ) && (
71+
<HStack justify="space-between">
72+
{ options?.software_version && (
73+
<Field title={ __( 'WordPress' ) }>{ options.software_version }</Field>
74+
) }
75+
{ is_wpcom_atomic && (
76+
<Field title={ __( 'PHP' ) }>
77+
<PHPVersion siteSlug={ site.slug } />
78+
</Field>
79+
) }
80+
</HStack>
81+
) }
7482
<PlanDetails site={ site } currentPlan={ currentPlan } />
7583
</VStack>
7684
</VStack>
@@ -80,7 +88,7 @@ export default function SiteCard( {
8088

8189
function Field( { children, title }: { children: React.ReactNode; title: React.ReactNode } ) {
8290
return (
83-
<VStack className="site-overview-field">
91+
<VStack className="site-overview-field" style={ { flex: 1 } }>
8492
<FieldTitle>{ title }</FieldTitle>
8593
<div className="site-overview-field-children">{ children }</div>
8694
</VStack>

client/dashboard/sites/overview/style.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@
2424
display: none;
2525
}
2626
}
27+
28+
.text-blur::after {
29+
content: attr(data-text);
30+
filter: blur(4px);
31+
}

0 commit comments

Comments
 (0)