index.js
50 lines
| 1 | /** |
| 2 | * Block dependencies |
| 3 | */ |
| 4 | import GiveBlankSlate from '../blank-slate/index'; |
| 5 | |
| 6 | /** |
| 7 | * Internal dependencies |
| 8 | */ |
| 9 | const {__} = wp.i18n; |
| 10 | const {Button} = wp.components; |
| 11 | const {Component} = wp.element; |
| 12 | |
| 13 | /** |
| 14 | * Render No forms Found UI |
| 15 | */ |
| 16 | |
| 17 | class EditForm extends Component { |
| 18 | constructor(props){ |
| 19 | super(props); |
| 20 | |
| 21 | this.changeForm = this.changeForm.bind(this); |
| 22 | } |
| 23 | |
| 24 | changeForm() { |
| 25 | this.props.setAttributes({prevId: this.props.attributes.id}); |
| 26 | this.props.setAttributes({id: 0}); |
| 27 | } |
| 28 | |
| 29 | render() { |
| 30 | return ( |
| 31 | <GiveBlankSlate title={__('Edit Form.')} |
| 32 | description={__('You can not see donation form preview because there is something went wrong with donation form settings.')}> |
| 33 | <Button isPrimary |
| 34 | isLarge |
| 35 | target="_blank" |
| 36 | href={`${ wpApiSettings.schema.url }/wp-admin/post.php?post=${this.props.formId}&action=edit`}> |
| 37 | {__('Edit Donation Form')} |
| 38 | </Button> |
| 39 | |
| 40 | <Button isLarge |
| 41 | onClick={this.changeForm}> |
| 42 | {__('Change Form')} |
| 43 | </Button> |
| 44 | </GiveBlankSlate> |
| 45 | ); |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | export default EditForm; |
| 50 |