CTA.js
5 years ago
CheckboxControl.js
5 years ago
CodeMirror.js
3 years ago
ColorPicker.js
5 years ago
ComboboxControl.js
3 years ago
Disabled.js
5 years ago
Fields.js
5 years ago
Group.js
3 years ago
Groups.js
5 years ago
Integration.js
5 years ago
Loading.js
5 years ago
Media.js
3 years ago
Notices.js
3 years ago
NullView.js
5 years ago
Page.js
5 years ago
SaveButton.js
3 years ago
SelectControl.js
5 years ago
TextControl.js
5 years ago
ToggleControl.js
5 years ago
Disabled.js
36 lines
| 1 | const { __ } = wp.i18n; |
| 2 | const { useState } = wp.element; |
| 3 | const { Modal, Button } = wp.components; |
| 4 | |
| 5 | export default ({ children, disabled }) => { |
| 6 | const [dialog, setDialog] = useState(false); |
| 7 | |
| 8 | if (!disabled) { |
| 9 | return <div>{children}</div>; |
| 10 | } |
| 11 | |
| 12 | return ( |
| 13 | <div> |
| 14 | <div |
| 15 | className="presto-options__disabled-overlay" |
| 16 | onClick={(e) => { |
| 17 | setDialog(true); |
| 18 | e.preventDefault(); |
| 19 | return false; |
| 20 | }} |
| 21 | > |
| 22 | <div>{children}</div> |
| 23 | </div> |
| 24 | {!!dialog && ( |
| 25 | <Modal title={disabled?.title} onRequestClose={() => setDialog(false)}> |
| 26 | <h2>{disabled?.heading}</h2> |
| 27 | <p>{disabled?.message}</p> |
| 28 | <Button href={disabled?.link} target="_blank" isPrimary> |
| 29 | {__("Learn More", "presto-player")} |
| 30 | </Button> |
| 31 | </Modal> |
| 32 | )} |
| 33 | </div> |
| 34 | ); |
| 35 | }; |
| 36 |