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 / ReportSummaryFields.tsx

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

60 lines 2.0 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 { TextControl, TextareaControl } from '@wordpress/components'
3 import { __ } from '@wordpress/i18n'
4 import { DuplicateReports } from './DuplicateReports'
5 import type { DuplicateReport, FeedbackDraft, FeedbackType } from '../../types/Feedback'
6
7 /** What the description asks for, and an example answer, for each kind of report. */
8 const DESCRIPTION_COPY: Record<FeedbackType, { label: string, placeholder: string }> = {
9 bug: {
10 label: __('What went wrong?', 'code-snippets'),
11 placeholder: __('The editor stopped highlighting PHP and the Save button did nothing.', 'code-snippets')
12 },
13 feature: {
14 label: __('What would you like Code Snippets to do?', 'code-snippets'),
15 placeholder: __('Let me tag snippets so I can filter large libraries by project.', 'code-snippets')
16 },
17 feedback: {
18 label: __('What is on your mind?', 'code-snippets'),
19 placeholder: __('The new Conditions tab is much clearer, but the icons are hard to tell apart.', 'code-snippets')
20 }
21 }
22
23 export interface ReportSummaryFieldsProps {
24 type: FeedbackType
25 draft: FeedbackDraft
26 duplicates: DuplicateReport[]
27 updateDraft: (changes: Partial<FeedbackDraft>) => void
28 }
29
30 export const ReportSummaryFields: React.FC<ReportSummaryFieldsProps> = ({
31 type,
32 draft,
33 duplicates,
34 updateDraft
35 }) =>
36 <>
37 <div className="code-snippets-feedback-field">
38 <TextControl
39 label={__('Title', 'code-snippets')}
40 help={__('A one-line summary. This becomes the issue title.', 'code-snippets')}
41 maxLength={120}
42 value={draft.title}
43 placeholder={__('Syntax highlighting stops after switching editor tabs', 'code-snippets')}
44 onChange={title => updateDraft({ title })}
45 />
46 </div>
47
48 <DuplicateReports reports={duplicates} />
49
50 <div className="code-snippets-feedback-field">
51 <TextareaControl
52 label={DESCRIPTION_COPY[type].label}
53 rows={4}
54 value={draft.description}
55 placeholder={DESCRIPTION_COPY[type].placeholder}
56 onChange={description => updateDraft({ description })}
57 />
58 </div>
59 </>
60