@wordpress/reusable-blocks 5.41.1-next.v.202603102151.0 → 5.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.cjs +24 -1
- package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.cjs.map +3 -3
- package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.mjs +28 -2
- package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.mjs.map +2 -2
- package/package.json +14 -14
- package/src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +30 -4
package/CHANGELOG.md
CHANGED
|
@@ -26,12 +26,14 @@ var import_components = require("@wordpress/components");
|
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
27
|
var import_blocks = require("@wordpress/blocks");
|
|
28
28
|
var import_data = require("@wordpress/data");
|
|
29
|
+
var import_element = require("@wordpress/element");
|
|
29
30
|
var import_block_editor = require("@wordpress/block-editor");
|
|
30
31
|
var import_url = require("@wordpress/url");
|
|
31
32
|
var import_core_data = require("@wordpress/core-data");
|
|
32
33
|
var import_store = require("../../store/index.cjs");
|
|
33
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
35
|
function ReusableBlocksManageButton({ clientId }) {
|
|
36
|
+
const [showConfirmDialog, setShowConfirmDialog] = (0, import_element.useState)(false);
|
|
35
37
|
const { canRemove, isVisible, managePatternsUrl } = (0, import_data.useSelect)(
|
|
36
38
|
(select) => {
|
|
37
39
|
const { getBlock, canRemoveBlock } = select(import_block_editor.store);
|
|
@@ -63,9 +65,30 @@ function ReusableBlocksManageButton({ clientId }) {
|
|
|
63
65
|
if (!isVisible) {
|
|
64
66
|
return null;
|
|
65
67
|
}
|
|
68
|
+
const handleDetach = () => {
|
|
69
|
+
convertBlockToStatic(clientId);
|
|
70
|
+
setShowConfirmDialog(false);
|
|
71
|
+
};
|
|
66
72
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
67
73
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuItem, { href: managePatternsUrl, children: (0, import_i18n.__)("Manage patterns") }),
|
|
68
|
-
canRemove && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
74
|
+
canRemove && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuItem, { onClick: () => setShowConfirmDialog(true), children: (0, import_i18n.__)("Disconnect pattern") }),
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
|
+
import_components.__experimentalConfirmDialog,
|
|
78
|
+
{
|
|
79
|
+
isOpen: showConfirmDialog,
|
|
80
|
+
onConfirm: handleDetach,
|
|
81
|
+
onCancel: () => setShowConfirmDialog(false),
|
|
82
|
+
confirmButtonText: (0, import_i18n.__)("Disconnect"),
|
|
83
|
+
size: "medium",
|
|
84
|
+
title: (0, import_i18n.__)("Disconnect pattern?"),
|
|
85
|
+
__experimentalHideHeader: false,
|
|
86
|
+
children: (0, import_i18n.__)(
|
|
87
|
+
"Blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here."
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
] })
|
|
69
92
|
] });
|
|
70
93
|
}
|
|
71
94
|
var reusable_blocks_manage_button_default = ReusableBlocksManageButton;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["blockEditorStore", "coreStore", "reusableBlocksStore"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as reusableBlocksStore } from '../../store';\n\nfunction ReusableBlocksManageButton( { clientId } ) {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock } = select( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t\tid: reusableBlock.attributes.ref,\n\t\t\t\t\t} ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\tconst handleDetach = () => {\n\t\tconvertBlockToStatic( clientId );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t\t{ canRemove && (\n\t\t\t\t<>\n\t\t\t\t\t<MenuItem onClick={ () => setShowConfirmDialog( true ) }>\n\t\t\t\t\t\t{ __( 'Disconnect pattern' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t\t<ConfirmDialog\n\t\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\t\tonConfirm={ handleDetach }\n\t\t\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t\t\t\tconfirmButtonText={ __( 'Disconnect' ) }\n\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\ttitle={ __( 'Disconnect pattern?' ) }\n\t\t\t\t\t\t__experimentalHideHeader={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ConfirmDialog>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksManageButton;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,kBAAmB;AACnB,oBAAgC;AAChC,kBAAuC;AACvC,qBAAyB;AACzB,0BAA0C;AAC1C,iBAA6B;AAC7B,uBAAmC;AAKnC,mBAA6C;AAq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Z,UAAW,MAAM,qBAAsB,KAAM;AAAA,UAC7C,uBAAoB,gBAAI,YAAa;AAAA,UACrC,MAAK;AAAA,UACL,WAAQ,gBAAI,qBAAsB;AAAA,UAClC,0BAA2B;AAAA,UAEzB;AAAA,YACD;AAAA,UACD;AAAA;AAAA,MACD;AAAA,OACD;AAAA,KAEF;AAEF;AAEA,IAAO,wCAAQ;",
|
|
6
|
+
"names": ["blockEditorStore", "coreStore", "reusableBlocksStore", "ConfirmDialog"]
|
|
7
7
|
}
|
package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.mjs
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
// packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
MenuItem,
|
|
4
|
+
__experimentalConfirmDialog as ConfirmDialog
|
|
5
|
+
} from "@wordpress/components";
|
|
3
6
|
import { __ } from "@wordpress/i18n";
|
|
4
7
|
import { isReusableBlock } from "@wordpress/blocks";
|
|
5
8
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
9
|
+
import { useState } from "@wordpress/element";
|
|
6
10
|
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
7
11
|
import { addQueryArgs } from "@wordpress/url";
|
|
8
12
|
import { store as coreStore } from "@wordpress/core-data";
|
|
9
13
|
import { store as reusableBlocksStore } from "../../store/index.mjs";
|
|
10
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
15
|
function ReusableBlocksManageButton({ clientId }) {
|
|
16
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
12
17
|
const { canRemove, isVisible, managePatternsUrl } = useSelect(
|
|
13
18
|
(select) => {
|
|
14
19
|
const { getBlock, canRemoveBlock } = select(blockEditorStore);
|
|
@@ -40,9 +45,30 @@ function ReusableBlocksManageButton({ clientId }) {
|
|
|
40
45
|
if (!isVisible) {
|
|
41
46
|
return null;
|
|
42
47
|
}
|
|
48
|
+
const handleDetach = () => {
|
|
49
|
+
convertBlockToStatic(clientId);
|
|
50
|
+
setShowConfirmDialog(false);
|
|
51
|
+
};
|
|
43
52
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
53
|
/* @__PURE__ */ jsx(MenuItem, { href: managePatternsUrl, children: __("Manage patterns") }),
|
|
45
|
-
canRemove && /* @__PURE__ */
|
|
54
|
+
canRemove && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
+
/* @__PURE__ */ jsx(MenuItem, { onClick: () => setShowConfirmDialog(true), children: __("Disconnect pattern") }),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
ConfirmDialog,
|
|
58
|
+
{
|
|
59
|
+
isOpen: showConfirmDialog,
|
|
60
|
+
onConfirm: handleDetach,
|
|
61
|
+
onCancel: () => setShowConfirmDialog(false),
|
|
62
|
+
confirmButtonText: __("Disconnect"),
|
|
63
|
+
size: "medium",
|
|
64
|
+
title: __("Disconnect pattern?"),
|
|
65
|
+
__experimentalHideHeader: false,
|
|
66
|
+
children: __(
|
|
67
|
+
"Blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here."
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] })
|
|
46
72
|
] });
|
|
47
73
|
}
|
|
48
74
|
var reusable_blocks_manage_button_default = ReusableBlocksManageButton;
|
package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as reusableBlocksStore } from '../../store';\n\nfunction ReusableBlocksManageButton( { clientId } ) {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock } = select( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t\tid: reusableBlock.attributes.ref,\n\t\t\t\t\t} ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\tconst handleDetach = () => {\n\t\tconvertBlockToStatic( clientId );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t\t{ canRemove && (\n\t\t\t\t<>\n\t\t\t\t\t<MenuItem onClick={ () => setShowConfirmDialog( true ) }>\n\t\t\t\t\t\t{ __( 'Disconnect pattern' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t\t<ConfirmDialog\n\t\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\t\tonConfirm={ handleDetach }\n\t\t\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t\t\t\tconfirmButtonText={ __( 'Disconnect' ) }\n\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\ttitle={ __( 'Disconnect pattern?' ) }\n\t\t\t\t\t\t__experimentalHideHeader={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ConfirmDialog>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksManageButton;\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAChC,SAAS,WAAW,mBAAmB;AACvC,SAAS,gBAAgB;AACzB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,oBAAoB;AAC7B,SAAS,SAAS,iBAAiB;AAKnC,SAAS,SAAS,2BAA2B;AAqD1C,SAIC,UAJD,KAIC,YAJD;AAnDH,SAAS,2BAA4B,EAAE,SAAS,GAAI;AACnD,QAAM,CAAE,mBA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B;AAAA,UAClC,0BAA2B;AAAA,UAEzB;AAAA,YACD;AAAA,UACD;AAAA;AAAA,MACD;AAAA,OACD;AAAA,KAEF;AAEF;AAEA,IAAO,wCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/reusable-blocks",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.42.0",
|
|
4
4
|
"description": "Reusable blocks utilities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"build-module/store/index.mjs"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@wordpress/base-styles": "^6.
|
|
54
|
-
"@wordpress/block-editor": "^15.
|
|
55
|
-
"@wordpress/blocks": "^15.
|
|
56
|
-
"@wordpress/components": "^32.4.
|
|
57
|
-
"@wordpress/core-data": "^7.
|
|
58
|
-
"@wordpress/data": "^10.
|
|
59
|
-
"@wordpress/element": "^6.
|
|
60
|
-
"@wordpress/i18n": "^6.
|
|
61
|
-
"@wordpress/icons": "^12.0.
|
|
62
|
-
"@wordpress/notices": "^5.
|
|
63
|
-
"@wordpress/private-apis": "^1.
|
|
64
|
-
"@wordpress/url": "^4.
|
|
53
|
+
"@wordpress/base-styles": "^6.18.0",
|
|
54
|
+
"@wordpress/block-editor": "^15.15.0",
|
|
55
|
+
"@wordpress/blocks": "^15.15.0",
|
|
56
|
+
"@wordpress/components": "^32.4.0",
|
|
57
|
+
"@wordpress/core-data": "^7.42.0",
|
|
58
|
+
"@wordpress/data": "^10.42.0",
|
|
59
|
+
"@wordpress/element": "^6.42.0",
|
|
60
|
+
"@wordpress/i18n": "^6.15.0",
|
|
61
|
+
"@wordpress/icons": "^12.0.0",
|
|
62
|
+
"@wordpress/notices": "^5.42.0",
|
|
63
|
+
"@wordpress/private-apis": "^1.42.0",
|
|
64
|
+
"@wordpress/url": "^4.42.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"react": "^18.0.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "c20787b1778ae64c2db65643b1c236309d68e6ba"
|
|
74
74
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
MenuItem,
|
|
6
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
7
|
+
} from '@wordpress/components';
|
|
5
8
|
import { __ } from '@wordpress/i18n';
|
|
6
9
|
import { isReusableBlock } from '@wordpress/blocks';
|
|
7
10
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
|
+
import { useState } from '@wordpress/element';
|
|
8
12
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
13
|
import { addQueryArgs } from '@wordpress/url';
|
|
10
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -15,6 +19,8 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
15
19
|
import { store as reusableBlocksStore } from '../../store';
|
|
16
20
|
|
|
17
21
|
function ReusableBlocksManageButton( { clientId } ) {
|
|
22
|
+
const [ showConfirmDialog, setShowConfirmDialog ] = useState( false );
|
|
23
|
+
|
|
18
24
|
const { canRemove, isVisible, managePatternsUrl } = useSelect(
|
|
19
25
|
( select ) => {
|
|
20
26
|
const { getBlock, canRemoveBlock } = select( blockEditorStore );
|
|
@@ -56,15 +62,35 @@ function ReusableBlocksManageButton( { clientId } ) {
|
|
|
56
62
|
return null;
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
const handleDetach = () => {
|
|
66
|
+
convertBlockToStatic( clientId );
|
|
67
|
+
setShowConfirmDialog( false );
|
|
68
|
+
};
|
|
69
|
+
|
|
59
70
|
return (
|
|
60
71
|
<>
|
|
61
72
|
<MenuItem href={ managePatternsUrl }>
|
|
62
73
|
{ __( 'Manage patterns' ) }
|
|
63
74
|
</MenuItem>
|
|
64
75
|
{ canRemove && (
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
|
|
76
|
+
<>
|
|
77
|
+
<MenuItem onClick={ () => setShowConfirmDialog( true ) }>
|
|
78
|
+
{ __( 'Disconnect pattern' ) }
|
|
79
|
+
</MenuItem>
|
|
80
|
+
<ConfirmDialog
|
|
81
|
+
isOpen={ showConfirmDialog }
|
|
82
|
+
onConfirm={ handleDetach }
|
|
83
|
+
onCancel={ () => setShowConfirmDialog( false ) }
|
|
84
|
+
confirmButtonText={ __( 'Disconnect' ) }
|
|
85
|
+
size="medium"
|
|
86
|
+
title={ __( 'Disconnect pattern?' ) }
|
|
87
|
+
__experimentalHideHeader={ false }
|
|
88
|
+
>
|
|
89
|
+
{ __(
|
|
90
|
+
'Blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here.'
|
|
91
|
+
) }
|
|
92
|
+
</ConfirmDialog>
|
|
93
|
+
</>
|
|
68
94
|
) }
|
|
69
95
|
</>
|
|
70
96
|
);
|