2021-08-18 00:07:46 +03:00
|
|
|
import { Fragment } from 'react'
|
2021-06-09 23:44:32 +03:00
|
|
|
import cx from 'classnames'
|
2022-11-03 23:44:02 +03:00
|
|
|
import { slug } from 'github-slugger'
|
2021-06-09 23:44:32 +03:00
|
|
|
import { ReleaseNotePatch } from './types'
|
|
|
|
import { Link } from 'components/Link'
|
|
|
|
|
2021-08-16 17:10:58 +03:00
|
|
|
import styles from './PatchNotes.module.scss'
|
|
|
|
|
2021-06-09 23:44:32 +03:00
|
|
|
const SectionToLabelMap: Record<string, string> = {
|
|
|
|
features: 'Features',
|
|
|
|
bugs: 'Bug fixes',
|
|
|
|
known_issues: 'Known issues',
|
|
|
|
security_fixes: 'Security fixes',
|
|
|
|
changes: 'Changes',
|
|
|
|
deprecations: 'Deprecations',
|
|
|
|
backups: 'Backups',
|
|
|
|
}
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
patch: ReleaseNotePatch
|
|
|
|
withReleaseNoteLabel?: boolean
|
|
|
|
}
|
|
|
|
export function PatchNotes({ patch, withReleaseNoteLabel }: Props) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{Object.entries(patch.sections).map(([key, sectionItems], i, arr) => {
|
|
|
|
const isLast = i === arr.length - 1
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
key={key}
|
|
|
|
className={cx(
|
2022-02-03 00:28:47 +03:00
|
|
|
'py-6 d-block d-xl-flex',
|
2021-06-09 23:44:32 +03:00
|
|
|
!withReleaseNoteLabel && 'mx-6',
|
|
|
|
!isLast && 'border-bottom'
|
|
|
|
)}
|
|
|
|
>
|
2022-02-03 00:28:47 +03:00
|
|
|
<ul className={cx(withReleaseNoteLabel)}>
|
2022-02-01 02:50:11 +03:00
|
|
|
<h3>{SectionToLabelMap[key] || 'INVALID SECTION'}</h3>
|
2021-06-09 23:44:32 +03:00
|
|
|
{sectionItems.map((item) => {
|
|
|
|
if (typeof item === 'string') {
|
2021-08-16 17:10:58 +03:00
|
|
|
return <li key={item} className="f4" dangerouslySetInnerHTML={{ __html: item }} />
|
2021-06-09 23:44:32 +03:00
|
|
|
}
|
|
|
|
|
2022-11-03 23:44:02 +03:00
|
|
|
const headingSlug = item.heading ? slug(item.heading) : ''
|
2021-06-09 23:44:32 +03:00
|
|
|
return (
|
2022-11-03 23:44:02 +03:00
|
|
|
<Fragment key={headingSlug}>
|
|
|
|
<h4 id={headingSlug} className={cx(styles.sectionHeading, 'text-bold f4')}>
|
|
|
|
<Link href={`#${headingSlug}`}>{item.heading}</Link>
|
2021-06-09 23:44:32 +03:00
|
|
|
</h4>
|
2021-08-18 18:01:51 +03:00
|
|
|
{item.notes.map((note) => {
|
|
|
|
return (
|
2021-12-07 12:36:37 +03:00
|
|
|
<li key={note} className="f4" dangerouslySetInnerHTML={{ __html: note }} />
|
2021-08-18 18:01:51 +03:00
|
|
|
)
|
|
|
|
})}
|
2021-08-18 00:07:46 +03:00
|
|
|
</Fragment>
|
2021-06-09 23:44:32 +03:00
|
|
|
)
|
|
|
|
})}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|