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
code-snippets / js / components / FeedbackReporter / FeedbackPanel.tsx

FeedbackPanel.tsx in Code Snippets trunk, at js/components/FeedbackReporter/FeedbackPanel.tsx

54 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react'
2 import { Button, Modal } from '@wordpress/components'
3 import { __, sprintf } from '@wordpress/i18n'
4 import { useFeedbackReport } from '../../hooks/useFeedbackReport'
5 import { FeedbackForm } from './FeedbackForm'
6 import { FeedbackSuccess } from './FeedbackSuccess'
7 import type { FeedbackConfig } from '../../types/Feedback'
8
9 export interface FeedbackPanelProps {
10 config: FeedbackConfig
11 onClose: VoidFunction
12 }
13
14 export const FeedbackPanel: React.FC<FeedbackPanelProps> = ({ config, onClose }) => {
15 const report = useFeedbackReport(config)
16
17 return <Modal
18 title={__('Send feedback', 'code-snippets')}
19 className="code-snippets-feedback-modal"
20 closeButtonLabel={__('Close', 'code-snippets')}
21 onRequestClose={onClose}
22 >
23 <p className="code-snippets-feedback-panel__subtitle">
24 {sprintf(
25 // translators: 1: plugin version, 2: plugin edition, either Free or Pro.
26 __('Code Snippets %1$s %2$s', 'code-snippets'),
27 config.version,
28 'pro' === config.edition ? __('Pro', 'code-snippets') : __('Free', 'code-snippets')
29 )}
30 </p>
31
32 <div className="code-snippets-feedback-panel__body">
33 {report.result
34 ? <FeedbackSuccess result={report.result} />
35 : <FeedbackForm config={config} report={report} />}
36 </div>
37
38 <div className="code-snippets-feedback-panel__footer">
39 <Button variant="tertiary" onClick={onClose}>
40 {report.result ? __('Close', 'code-snippets') : __('Cancel', 'code-snippets')}
41 </Button>
42
43 {!report.result &&
44 <Button
45 variant="primary"
46 disabled={!report.draft.type || report.isSending}
47 onClick={report.submit}
48 >
49 {report.isSending ? __('Sending…', 'code-snippets') : __('Send report', 'code-snippets')}
50 </Button>}
51 </div>
52 </Modal>
53 }
54