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/actions/ExportButtons.tsx +14 -7 4.0.0-beta.1 → trunk View file →
@@ -1,7 +1,8 @@
1 1 import React from 'react'
2 2 import { __ } from '@wordpress/i18n'
3 3 import { useSnippetsAPI } from '../../../../hooks/useSnippetsAPI'
4 +import { getSnippetType } from '../../../../utils/snippets/snippets'
4 5 import { useSnippetForm } from '../../SnippetForm/WithSnippetFormContext'
5 6 import { downloadSnippetExportFile } from '../../../../utils/files'
6 7 import { Button } from '../../../common/Button'
7 8 import type { SnippetsExport } from '../../../../types/schema/SnippetsExport'
@@ -9,12 +10,14 @@
9 10
10 11 interface ExportButtonProps {
11 12 name: string
12 13 label: string
14 + icon: string
15 + title?: string
13 16 makeRequest: (snippet: Snippet) => Promise<SnippetsExport | string>
14 17 }
15 18
16 -const ExportButton: React.FC<ExportButtonProps> = ({ name, label, makeRequest }) => {
19 +const ExportButton: React.FC<ExportButtonProps> = ({ name, label, icon, title, makeRequest }) => {
17 20 const { snippet, isWorking, setIsWorking, handleRequestError } = useSnippetForm()
18 21
19 22 const handleClick = () => {
20 23 setIsWorking(true)
@@ -26,9 +29,10 @@
26 29 .finally(() => setIsWorking(false))
27 30 }
28 31
29 32 return (
30 - <Button name={name} onClick={handleClick} disabled={isWorking}>
33 + <Button name={name} onClick={handleClick} disabled={isWorking} title={title}>
34 + <span className={`dashicons ${icon}`} aria-hidden="true" />
31 35 {label}
32 36 </Button>
33 37 )
34 38 }
@@ -34,8 +38,9 @@
34 38 }
35 39
36 40 export const ExportButtons: React.FC = () => {
37 41 const api = useSnippetsAPI()
42 + const { snippet } = useSnippetForm()
38 43
39 44 return (
40 45 <div className="snippet-export-buttons">
41 46 <ExportButton
@@ -40,17 +45,19 @@
40 45 <div className="snippet-export-buttons">
41 46 <ExportButton
42 47 name="export_snippet"
43 48 label={__('Export', 'code-snippets')}
49 + icon="dashicons-upload"
50 + title={__('Download snippet as JSON', 'code-snippets')}
44 51 makeRequest={api.export}
45 52 />
46 53
47 - {window.CODE_SNIPPETS_EDIT?.enableDownloads
48 - ? <ExportButton
54 + {window.CODE_SNIPPETS_EDIT?.enableDownloads && 'cond' !== getSnippetType(snippet) && (
55 + <ExportButton
49 56 name="export_snippet_code"
50 - label={__('Download Code', 'code-snippets')}
57 + label={__('Download', 'code-snippets')}
58 + icon="dashicons-download"
51 59 makeRequest={api.exportCode}
52 - />
53 - : null}
60 + />)}
54 61 </div>
55 62 )
56 63 }