@@ -15,17 +15,18 @@ import { getInitials } from '../../../js/utils';
1515/**
1616 * SiteSelection component.
1717 *
18- * @param {Object } props - Component props.
19- * @param {Array } props.siteInfo - Array of connected site information.
20- * @param {boolean } props.isApplying - Boolean indicating if templates are being applied.
21- * @param {Function } props.setIsApplying - Function to set the isApplying state.
22- * @param {Function } props.onApply - Function to handle applying templates to selected sites.
23- * @param {Function } props.setIsApplyModalOpen - Function to control the visibility of the apply modal.
24- * @param {Function } props.setSelectedSites - Function to set the selected site IDs.
25- * @param {Array } props.selectedSites - Array of selected site IDs.
26- * @param {Object } props.notice - Notice object containing type and message.
27- * @param {Array } props.brandSiteTemplates - Array of templates available for brand sites.
28- * @param {Array } props.selectedTemplates - Array of selected template IDs.
18+ * @param {Object } props - Component props.
19+ * @param {Array } props.siteInfo - Array of connected site information.
20+ * @param {boolean } props.isApplying - Boolean indicating if templates are being applied.
21+ * @param {Function } props.setIsApplying - Function to set the isApplying state.
22+ * @param {Function } props.onApply - Function to handle applying templates to selected sites.
23+ * @param {Function } props.setIsApplyModalOpen - Function to control the visibility of the apply modal.
24+ * @param {Function } props.setSelectedSites - Function to set the selected site IDs.
25+ * @param {Array } props.selectedSites - Array of selected site IDs.
26+ * @param {Object } props.notice - Notice object containing type and message.
27+ * @param {Array } props.brandSiteTemplates - Array of templates available for brand sites.
28+ * @param {Array } props.selectedTemplates - Array of selected template IDs.
29+ * @param {Object } props.sitesHealthCheckResult - Object containing health check results for sites.
2930 * @return {JSX.Element } The rendered component.
3031 */
3132const SiteSelection = ( {
@@ -39,6 +40,7 @@ const SiteSelection = ( {
3940 notice,
4041 brandSiteTemplates,
4142 selectedTemplates,
43+ sitesHealthCheckResult,
4244} ) => {
4345 const handleSiteSelection = ( siteId ) => {
4446 setSelectedSites ( ( prevSelected ) => {
@@ -145,7 +147,7 @@ const SiteSelection = ( {
145147 onClick = { selectAllSites }
146148 disabled = {
147149 selectedSelectableSiteCount === selectableSiteCount ||
148- selectableSiteCount === 0
150+ selectableSiteCount === 0
149151 }
150152 className = "od-bulk-action"
151153 >
@@ -185,7 +187,7 @@ const SiteSelection = ( {
185187 < div className = "od-sites-list od-sites-grid" >
186188 { siteInfo . map ( ( { id, name, url, logo } ) => {
187189 const isSelected = selectedSites . includes ( id ) ;
188- const isDisabled = areAllTemplatesPresent ( id ) && ! isSelected ;
190+ const isDisabled = ( ( areAllTemplatesPresent ( id ) && ! isSelected ) || ( sitesHealthCheckResult [ id ] && ! sitesHealthCheckResult [ id ] . success ) ) ;
189191
190192 return (
191193 < div
@@ -205,7 +207,9 @@ const SiteSelection = ( {
205207 < div className = "od-site-inner" >
206208 { isSelected && (
207209 < div className = "od-site-selected-indicator" >
208- < span className = "dashicons dashicons-yes-alt" > </ span >
210+ {
211+ renderIcon ( { sitesHealthCheckResult, id } )
212+ }
209213 </ div >
210214 ) }
211215 { isDisabled && ! isSelected && (
@@ -216,7 +220,7 @@ const SiteSelection = ( {
216220 'onedesign' ,
217221 ) }
218222 >
219- < span className = "dashicons dashicons-yes" > </ span >
223+ { renderIcon ( { sitesHealthCheckResult , id } ) }
220224 </ div >
221225 ) }
222226 < div className = "od-site-logo" >
@@ -314,4 +318,22 @@ const SiteSelection = ( {
314318 ) ;
315319} ;
316320
321+ /**
322+ * Render the appropriate dashicon based on health check result.
323+ *
324+ * @param {Object } props - Component props.
325+ * @param {Object } props.sitesHealthCheckResult - Object containing health check results for sites.
326+ * @param {number } props.id - Site ID.
327+ * @return {JSX.Element } The rendered dashicon element.
328+ */
329+ const renderIcon = ( { sitesHealthCheckResult, id } ) => {
330+ return (
331+ sitesHealthCheckResult [ id ] && ! sitesHealthCheckResult [ id ] . success ? (
332+ < span className = "dashicons dashicons-warning" > </ span >
333+ ) : (
334+ < span className = "dashicons dashicons-yes-alt" > </ span >
335+ )
336+ ) ;
337+ } ;
338+
317339export default SiteSelection ;
0 commit comments