Skip to content

Commit 944086c

Browse files
authored
Merge pull request #435 from devtron-labs/release-candidate-v0.24.0
release: Release candidate v0.24.0
2 parents 079cf1c + 36d91b3 commit 944086c

36 files changed

+931
-212
lines changed

package-lock.json

Lines changed: 207 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.1.0-patch-1",
3+
"version": "1.2.0",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -79,7 +79,6 @@
7979
"@rjsf/validator-ajv8": "^5.13.3",
8080
"@typeform/embed-react": "2.20.0",
8181
"dompurify": "^3.0.2",
82-
"marked": "4.3.0",
8382
"react": "^17.0.2",
8483
"react-dom": "^17.0.2",
8584
"react-draggable": "^4.4.5",
@@ -92,11 +91,14 @@
9291
},
9392
"dependencies": {
9493
"@types/react-dates": "^21.8.6",
94+
"marked": "^13.0.3",
9595
"ansi_up": "^5.2.1",
9696
"dayjs": "^1.11.13",
9797
"fast-json-patch": "^3.1.1",
98+
"framer-motion": "^6.5.1",
9899
"jsonpath-plus": "^10.0.0",
99100
"react-dates": "^21.8.0",
101+
"react-diff-viewer-continued": "^3.4.0",
100102
"react-monaco-editor": "^0.54.0",
101103
"sass": "^1.69.7",
102104
"tslib": "2.7.0"

src/Assets/Icon/ic-info-outline.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Assets/Icon/ic-medium-info.svg

Lines changed: 5 additions & 0 deletions
Loading

src/Common/CustomInput/CustomInput.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ export const CustomInput = ({
6969
const handleOnBlur = (event) => {
7070
// NOTE: This is to prevent the input from being trimmed when the user do not want to trim the input
7171
if (!noTrim) {
72-
event.stopPropagation()
73-
event.target.value = event.target.value?.trim()
74-
onChange(event)
72+
const trimmedValue = event.target.value?.trim()
73+
74+
if (event.target.value !== trimmedValue) {
75+
event.stopPropagation()
76+
event.target.value = trimmedValue
77+
onChange(event)
78+
}
7579
}
7680
if (typeof onBlur === 'function') {
7781
onBlur(event)

src/Common/Hooks/UseRegisterShortcut/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const KEYBOARD_KEYS_MAP = {
2525
E: 'E',
2626
R: 'R',
2727
K: 'K',
28+
Escape: 'Escape',
29+
Enter: 'Enter',
2830
} as const
2931

3032
export type SupportedKeyboardKeysType = keyof typeof KEYBOARD_KEYS_MAP

src/Common/Markdown/MarkDown.tsx

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { marked } from 'marked'
17+
import { marked, Tokens } from 'marked'
1818
import DOMPurify from 'dompurify'
1919
import { useEffect, useRef } from 'react'
2020
import { MarkDownProps } from './Types'
2121
import './markdown.scss'
2222

23-
const uncheckedCheckboxInputElement = `<input checked="" disabled="" type="checkbox">`
24-
const checkedCheckboxInputElement = `<input disabled="" type="checkbox">`
2523
const renderer = new marked.Renderer()
2624

2725
const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscapedText, ...props }: MarkDownProps) => {
@@ -39,62 +37,59 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap
3937
getHeight()
4038
}, [markdown])
4139

42-
const isReadmeInputCheckbox = (text: string) => {
43-
if (text.includes(uncheckedCheckboxInputElement) || text.includes(checkedCheckboxInputElement)) {
44-
return true
45-
}
46-
return false
47-
}
40+
const renderTableRow = (row: Tokens.TableCell[]) => `
41+
<tr>
42+
${row.map((rowCell) => `<td align="${rowCell.align}">${marked(rowCell.text)}</td>`).join('')}
43+
</tr>
44+
`
4845

49-
renderer.listitem = (text: string) => {
50-
if (isReadmeInputCheckbox(text)) {
51-
// eslint-disable-next-line no-param-reassign
52-
text = text
53-
.replace(
54-
uncheckedCheckboxInputElement,
55-
'<input type="checkbox" style="margin: 0 0.2em 0.25em -1.4em;" class="dc__vertical-align-middle" checked disabled>',
56-
)
57-
.replace(
58-
checkedCheckboxInputElement,
59-
'<input type="checkbox" style="margin: 0 0.2em 0.25em -1.4em;" class="dc__vertical-align-middle" disabled>',
60-
)
61-
return `<li style="list-style: none">${text}</li>`
46+
renderer.listitem = ({ text, task, checked }: Tokens.ListItem) => {
47+
if (task) {
48+
return `<li style="list-style: none">
49+
<input disabled type="checkbox" ${checked ? 'checked' : ''} class="dc__vertical-align-middle" style="margin: 0 0.2em 0.25em -1.4em">
50+
${text}
51+
</li>`
6252
}
6353
return `<li>${text}</li>`
6454
}
6555

66-
renderer.image = (href: string, title: string, text: string) =>
56+
renderer.image = ({ href, title, text }: Tokens.Image) =>
6757
`<img src="${href}" alt="${text}" title="${title}" class="max-w-100">`
6858

69-
renderer.table = (header, body) => `
59+
renderer.table = ({ header, rows }: Tokens.Table) => `
7060
<div class="table-container">
7161
<table>
72-
${header}
73-
${body}
62+
<thead>
63+
<tr>${header.map((headerCell) => `<th align="${headerCell.align}">${headerCell.text}</th>`).join('')}</tr>
64+
</thead>
65+
<tbody>
66+
${rows.map((row) => renderTableRow(row)).join('')}
67+
</tbody>
7468
</table>
7569
</div>
7670
`
7771

78-
renderer.heading = (text, level) => {
72+
renderer.heading = ({ text, depth }: Tokens.Heading) => {
7973
const escapedText = disableEscapedText ? '' : text.toLowerCase().replace(/[^\w]+/g, '-')
8074

8175
return `
8276
<a name="${escapedText}" rel="noreferrer noopener" class="anchor" href="#${escapedText}">
83-
<h${level} data-testid="deployment-template-readme-version">
77+
<h${depth} data-testid="deployment-template-readme-version">
8478
<span class="header-link"></span>
8579
${text}
86-
</h${level}>
80+
</h${depth}>
8781
</a>`
8882
}
8983

9084
marked.setOptions({
9185
renderer,
9286
gfm: true,
93-
smartLists: true,
9487
...(breaks && { breaks: true }),
9588
})
9689

97-
const createMarkup = () => ({ __html: DOMPurify.sanitize(marked(markdown), { USE_PROFILES: { html: true } }) })
90+
const createMarkup = () => ({
91+
__html: DOMPurify.sanitize(marked(markdown) as string, { USE_PROFILES: { html: true } }),
92+
})
9893

9994
return (
10095
<article

src/Common/Markdown/markdown.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
border-spacing: 0;
2727
border-collapse: collapse;
2828

29-
tbody {
29+
tbody, thead {
3030
td,
3131
th {
3232
padding: 6px 13px;

src/Common/Modals/VisibleModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export class VisibleModal extends React.Component<{
3434
}
3535

3636
escFunction(event) {
37-
stopPropagation(event)
3837
if (event.keyCode === 27 || event.key === 'Escape') {
38+
stopPropagation(event)
3939
if (this.props.onEscape) {
4040
this.props.onEscape(event)
4141
} else if (this.props.close) {

src/Common/TippyCustomized.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { useRef, useState } from 'react'
17+
import { useRef, useState } from 'react'
1818
import Tippy from '@tippyjs/react'
1919
import { ReactComponent as CloseIcon } from '../Assets/Icon/ic-cross.svg'
2020
import { ReactComponent as Help } from '../Assets/Icon/ic-help.svg'
@@ -31,6 +31,12 @@ export const TippyCustomized = (props: TippyCustomizedProps) => {
3131
const [showHeadingInfo, setShowHeadingInfo] = useState(false)
3232
const isWhiteTheme = props.theme === TippyTheme.white
3333

34+
const closeOnEsc = (e) => {
35+
if (e.keyCode === 27) {
36+
closeTippy(e)
37+
}
38+
}
39+
3440
const onTippyMount = (tippyInstance) => {
3541
tippyRef.current = tippyInstance
3642
document.addEventListener('keydown', closeOnEsc)
@@ -47,12 +53,7 @@ export const TippyCustomized = (props: TippyCustomizedProps) => {
4753
}
4854
}
4955
setShowHeadingInfo(false)
50-
}
51-
52-
const closeOnEsc = (e) => {
53-
if (e.keyCode === 27) {
54-
closeTippy(e)
55-
}
56+
document.removeEventListener('keydown', closeOnEsc)
5657
}
5758

5859
const toggleHeadingInfo = (e) => {

0 commit comments

Comments
 (0)