• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / f58711a939378578f715cfb5ab966e6d6a91bfa2

21 Nov 2024 12:49PM CUT coverage: 54.68% (-0.008%) from 54.688%
f58711a939378578f715cfb5ab966e6d6a91bfa2

Pull #21833

github

web-flow
Merge e68dfd5f1 into 6774f0888
Pull Request #21833: Fix admin notices in alert center

7594 of 13598 branches covered (55.85%)

Branch coverage included in aggregate %.

0 of 25 new or added lines in 4 files covered. (0.0%)

22 existing lines in 4 files now uncovered.

29746 of 54690 relevant lines covered (54.39%)

41965.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.69
/packages/js/src/general/components/notice.js
1
import { useCallback } from "@wordpress/element";
2
import { useDispatch } from "@wordpress/data";
3
import { STORE_NAME } from "../constants";
4
import { XIcon } from "@heroicons/react/outline";
5
import { __ } from "@wordpress/i18n";
6
import { useSvgAria } from "@yoast/ui-library";
7
import PropTypes from "prop-types";
8

9
/**
10
 * Renders the notice component.
11
 *
12
 * @param {string} type The title of the notice.
13
 * @param {string} id The id of the notice.
14
 * @param {boolean} isDismissable Whether the notice is dismissable.
15
 * @param {string} children The content of the notice.
16
 *
17
 * @returns {React.Component} The Notice.
18
 */
19
export function Notice( { title, id, isDismissable, children } ) {
20
        const ariaSvgProps = useSvgAria();
×
NEW
21
        const { dismissNotice } = useDispatch( STORE_NAME );
×
22

NEW
23
        const handleDismiss = useCallback( () => {
×
24
                // Dismiss the notice after the rest of the call stack has been processed.
NEW
25
                setTimeout( () => {
×
NEW
26
                        dismissNotice( id );
×
27
                }, 0 );
28
        }, [ dismissNotice, id ] );
29

30
        return (
×
31
                <div id={ id } className="yst-p-3 yst-rounded-md yoast-general-page-notice">
32
                        <div className="yst-flex yst-flex-row yst-items-center yst-min-h-[24px]">
33
                                <span className="yoast-icon" />
34
                                { title && <div className="yst-text-sm yst-font-medium" dangerouslySetInnerHTML={ { __html: title } } /> }
×
35
                                { isDismissable &&
×
36
                                        <div className="yst-relative yst-ml-auto">
37
                                                <button
38
                                                        type="button"
39
                                                        className="notice-dismiss"
40
                                                        onClick={ handleDismiss }
41
                                                >
42
                                                        <span className="yst-sr-only">{ __( "Close", "wordpress-seo" ) }</span>
43
                                                        <XIcon className="yst-h-5 yst-w-5" { ...ariaSvgProps } />
44
                                                </button>
45
                                        </div>
46
                                }
47
                        </div>
48
                        { children && (
×
49
                                <div className="yst-flex-1 yst-text-sm yst-max-w-[600px] yst-pl-[29px]" dangerouslySetInnerHTML={ { __html: children } } />
50
                        ) }
51
                </div>
52
        );
53
}
54

55
Notice.propTypes = {
2✔
56
        title: PropTypes.string.isRequired,
57
        id: PropTypes.string.isRequired,
58
        isDismissable: PropTypes.bool.isRequired,
59
        children: PropTypes.string.isRequired,
60
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc