PluginProbe
Code Snippets / 3.10.2
Code Snippets v3.10.2
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 / WelcomeMenu / Changelog.tsx

Changelog.tsx in Code Snippets 3.10.2, at js/components/WelcomeMenu/Changelog.tsx

90 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { Fragment } from 'react'
2 import { __, sprintf } from '@wordpress/i18n'
3 import { CHANGELOG_SECTIONS } from '../../types/schema/WelcomeSchema'
4 import type { ChangelogSectionTitle } from '../../types/schema/WelcomeSchema'
5
6 const CHANGELOG_LABELS: Record<ChangelogSectionTitle, string> = {
7 Added: __('New features', 'code-snippets'),
8 Changed: __('Improvements', 'code-snippets'),
9 Deprecated: __('Deprecated features', 'code-snippets'),
10 Removed: __('Removed features', 'code-snippets'),
11 Fixed: __('Bug fixes', 'code-snippets'),
12 Security: __('Security updates', 'code-snippets'),
13 Other: __('Other', 'code-snippets')
14 }
15
16 const CHANGELOG_ICONS: Record<ChangelogSectionTitle, string> = {
17 Added: 'lightbulb',
18 Changed: 'chart-line',
19 Deprecated: 'remove',
20 Removed: 'trash',
21 Fixed: 'buddicons-replies',
22 Security: 'shield',
23 Other: 'open-folder'
24 }
25
26 const PLUGIN_TYPE_LABELS: Record<string, string> = {
27 core: __('Core', 'code-snippets'),
28 pro: __('Pro', 'code-snippets')
29 }
30
31 const CHANGELOG_DATA = window.CODE_SNIPPETS_WELCOME?.changelog
32
33 interface ChangelogSectionProps {
34 section: ChangelogSectionTitle
35 entries: Record<string, string[]>
36 }
37
38 const ChangelogSection: React.FC<ChangelogSectionProps> = ({ section, entries }) =>
39 <>
40 <h4>
41 <span className={`dashicons dashicons-${CHANGELOG_ICONS[section]}`} aria-hidden="true"></span>
42 {CHANGELOG_LABELS[section]}
43 </h4>
44 <ul>
45 {Object.entries(entries).map(([pluginType, changes]) =>
46 changes.map(change =>
47 <li key={change}>
48 <span className={`badge ${pluginType}-badge`}>
49 {PLUGIN_TYPE_LABELS[pluginType] ?? pluginType}
50 </span>
51 <span>{change}</span>
52 </li>)
53 )}
54 </ul>
55 </>
56
57 export const Changelog = () =>
58 <div className="code-snippets-changelog">
59 <div className="code-snippets-header-wrapper">
60 <h2>{__('Latest changes', 'code-snippets')}</h2>
61 <a
62 href="https://wordpress.org/plugins/code-snippets/changelog"
63 className="button button-primary button-large"
64 target="_blank" rel="noreferrer"
65 >
66 {__('View changelog', 'code-snippets')}
67 <span className="screen-reader-text">
68 {__('(opens in a new tab)', 'code-snippets')}
69 </span>
70 </a>
71 </div>
72 <div className="code-snippets-changelog-entries">
73 {CHANGELOG_DATA?.map(({ version, date, entries }) =>
74 <Fragment key={version}>
75 <h3>
76 {sprintf(
77 /* translators: %s: version number. */
78 __('Version %s', 'code-snippets'),
79 version
80 )}
81 <span>{date}</span>
82 </h3>
83 {CHANGELOG_SECTIONS.map(section =>
84 entries[section]
85 ? <ChangelogSection key={section} section={section} entries={entries[section]} />
86 : null)}
87 </Fragment>)}
88 </div>
89 </div>
90