PluginProbe
Code Snippets / trunk
Code Snippets vtrunk
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
← All changes | js/components/EditMenu/EditorSidebar/EditorSidebar.tsx +29 -20 3.10.0-beta.1 → trunk View file →
@@ -1,12 +1,13 @@
1 1 import React from 'react'
2 2 import { Spinner } from '@wordpress/components'
3 3 import { __, isRTL } from '@wordpress/i18n'
4 +import { ConfirmDeleteDialog, useDeleteSnippet } from '../../common/snippets/ConfirmDeleteDialog'
4 5 import { buildUrl } from '../../../utils/urls'
6 +import { Button } from '../../common/Button'
5 7 import { useSnippetForm } from '../SnippetForm/WithSnippetFormContext'
6 8 import { isNetworkAdmin } from '../../../utils/screen'
7 9 import { isCondition } from '../../../utils/snippets/snippets'
8 -import { DeleteButton } from '../../common/DeleteButton'
9 10 import { ConditionModalButton } from '../ConditionModal/ConditionModalButton'
10 11 import { SnippetLocationInput } from '../SnippetForm/fields/SnippetLocationInput'
11 12 import { Notices } from '../SnippetForm/page/Notices'
12 13 import { ShortcodeInfo } from './actions/ShortcodeInfo'
@@ -25,8 +26,19 @@
25 26
26 27 export const EditorSidebar: React.FC<EditorSidebarProps> = ({ setIsUpgradeDialogOpen }) => {
27 28 const { snippet, isWorking, setIsWorking, handleRequestError } = useSnippetForm()
28 29
30 + const { requestDelete, deleteDialogProps } = useDeleteSnippet({
31 + snippet,
32 + setIsWorking,
33 + onSuccess: () => {
34 + window.location.replace(buildUrl(window.CODE_SNIPPETS?.urls.manage, { result: 'deleted' }))
35 + },
36 + onError: error => {
37 + handleRequestError(error, __('Could not delete snippet.', 'code-snippets'))
38 + }
39 + })
40 +
29 41 return (
30 42 <div className="snippet-editor-sidebar">
31 43 <div className="box">
32 44 {snippet.id && !isCondition(snippet) ? <ActivationSwitch /> : null}
@@ -34,30 +46,26 @@
34 46 {isNetworkAdmin() && <MultisiteSharingSettings />}
35 47
36 48 {isRTL() && <RTLControl />}
37 49
38 - <ConditionModalButton setIsDialogOpen={setIsUpgradeDialogOpen} />
39 - <SnippetLocationInput />
40 - <ShortcodeInfo />
41 - <PriorityInput />
50 + <div className="snippet-editor-sidebar-settings">
51 + <ConditionModalButton setIsModalOpen={setIsUpgradeDialogOpen} />
52 + <SnippetLocationInput />
53 + <ShortcodeInfo />
54 + <PriorityInput />
55 + </div>
42 56
43 - {snippet.id
44 - ? <div className="row-actions visible inline-form-field">
57 + {!!snippet.id && (
58 + <div className="row-actions visible inline-form-field">
45 59 <ExportButtons />
46 - <DeleteButton
47 - snippet={snippet}
48 - disabled={isWorking || snippet.locked}
49 - setIsWorking={setIsWorking}
50 - onSuccess={() => {
51 - window.location.replace(buildUrl(window.CODE_SNIPPETS?.urls.manage, { result: 'deleted' }))
52 - }}
53 - onError={error => {
54 - handleRequestError(error, __('Could not delete snippet.', 'code-snippets'))
55 - }}
56 - />
60 +
61 + <Button className="delete-button" onClick={() => void requestDelete()} disabled={isWorking || snippet.locked}>
62 + <span className="dashicons dashicons-trash" aria-hidden="true" />
63 + {snippet.trashed ? __('Delete Permanently', 'code-snippets') : __('Trash', 'code-snippets')}
64 + </Button>
65 +
57 66 <LockControl />
58 - </div>
59 - : null}
67 + </div>)}
60 68 </div>
61 69
62 70 <p className="submit">
63 71 <SubmitButtons />
@@ -64,7 +72,8 @@
64 72 {isWorking ? <Spinner /> : ''}
65 73 </p>
66 74
67 75 <Notices placement="sidebar" />
76 + <ConfirmDeleteDialog {...deleteDialogProps} />
68 77 </div>
69 78 )
70 79 }