Skip to content

Commit 8d1c1d3

Browse files
authored
fix: add filter to prompt conflicts check (Automattic#2421)
1 parent c96555a commit 8d1c1d3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

assets/wizards/popups/utils.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import apiFetch from '@wordpress/api-fetch';
55
import { __, sprintf } from '@wordpress/i18n';
66
import { addQueryArgs } from '@wordpress/url';
7+
import { applyFilters } from '@wordpress/hooks';
78

89
/**
910
* External dependencies.
@@ -339,20 +340,27 @@ export const warningForPopup = ( prompts, prompt ) => {
339340
);
340341
} );
341342

342-
if ( 0 < conflictingPrompts.length ) {
343+
const filteredConflictingPrompts = applyFilters(
344+
'newspack.wizards.campaigns.conflictingPrompts',
345+
conflictingPrompts,
346+
prompt,
347+
prompts
348+
);
349+
350+
if ( 0 < filteredConflictingPrompts.length ) {
343351
return (
344352
<>
345353
<strong>
346354
{ sprintf(
347355
// Translators: %s: 'Conflicts' or 'Conflict' depending on number of conflicts.
348356
__( '%s detected:', 'newspack' ),
349-
1 < conflictingPrompts.length
357+
1 < filteredConflictingPrompts.length
350358
? __( 'Conflicts', 'newspack' )
351359
: __( 'Conflict', 'newspack' )
352360
) }
353361
</strong>
354362
<ul>
355-
{ conflictingPrompts.map( conflictingPrompt => (
363+
{ filteredConflictingPrompts.map( conflictingPrompt => (
356364
<li key={ conflictingPrompt.id }>
357365
<p data-testid={ `conflict-warning-${ prompt.id }` }>
358366
<strong>{ sprintf( '%s: ', conflictingPrompt.title ) }</strong>

0 commit comments

Comments
 (0)