PluginProbe
Extendify / 0.9.2
Extendify v0.9.2
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 0.7.0 All 126 releases
extendify / src / Library / middleware / ReloadRequiredModal.js

ReloadRequiredModal.js in Extendify 0.9.2, at src/Library/middleware/ReloadRequiredModal.js

50 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Modal, Button, ButtonGroup } from '@wordpress/components'
2 import { dispatch, select } from '@wordpress/data'
3 import { useState } from '@wordpress/element'
4 import { __ } from '@wordpress/i18n'
5
6 export default function ReloadRequiredModal() {
7 const [isSaving, setSaving] = useState(false)
8 const { isEditedPostDirty } = select('core/editor')
9 const hasUnsavedChanges = isEditedPostDirty()
10 const saveChanges = () => {
11 setSaving(true)
12 dispatch('core/editor').savePost()
13 setSaving(false)
14 }
15 const reload = () => {
16 // location.reload()
17 }
18 if (!hasUnsavedChanges) {
19 reload()
20 return null
21 }
22 return (
23 <Modal title={__('Reload required', 'extendify')} isDismissible={false}>
24 <p
25 style={{
26 maxWidth: '400px',
27 }}>
28 {__(
29 'Just one more thing! We need to reload the page to continue.',
30 'extendify',
31 )}
32 </p>
33 <ButtonGroup>
34 <Button isPrimary onClick={reload} disabled={isSaving}>
35 {__('Reload page', 'extendify')}
36 </Button>
37 <Button
38 isSecondary
39 onClick={saveChanges}
40 isBusy={isSaving}
41 style={{
42 margin: '0 4px',
43 }}>
44 {__('Save changes', 'extendify')}
45 </Button>
46 </ButtonGroup>
47 </Modal>
48 )
49 }
50