PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Agent / components / SharedBlockNotice.jsx

SharedBlockNotice.jsx in Extendify 3.2.1, at src/Agent/components/SharedBlockNotice.jsx

35 lines 881 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {
2 fetchSharedBlockUsage,
3 isSharedBlockId,
4 sharedBlockNotice,
5 } from '@agent/lib/shared-block-usage';
6 import { useEffect, useState } from '@wordpress/element';
7
8 export const SharedBlockNotice = ({ blockIds }) => {
9 const [notice, setNotice] = useState(null);
10 const shared = (Array.isArray(blockIds) ? blockIds : []).find((id) =>
11 isSharedBlockId(id),
12 );
13
14 useEffect(() => {
15 if (!shared) return setNotice(null);
16 let live = true;
17 fetchSharedBlockUsage(shared)
18 .then((usage) => live && setNotice(sharedBlockNotice(usage)))
19 // A missing scope must not block the save the user already reviewed.
20 .catch(() => live && setNotice(null));
21 return () => {
22 live = false;
23 };
24 }, [shared]);
25
26 if (!notice) return null;
27
28 return (
29 <p className="m-0 mt-2 p-0 text-sm text-gray-700">
30 <span aria-hidden="true"></span>
31 <span>{notice}</span>
32 </p>
33 );
34 };
35