From 9c7dc144d5eb672402ca959fb668717cfac05662 Mon Sep 17 00:00:00 2001 From: Arun Jain Date: Wed, 20 Nov 2024 18:45:34 +0530 Subject: [PATCH 1/6] feat: update renderer for marked --- package-lock.json | 11 ++--- package.json | 2 +- src/Common/Markdown/MarkDown.tsx | 67 ++++++++++++++++--------------- src/Common/Markdown/markdown.scss | 2 +- 4 files changed, 43 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index f3ede91ec..7df634f19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -65,7 +65,7 @@ "@rjsf/validator-ajv8": "^5.13.3", "@typeform/embed-react": "2.20.0", "dompurify": "^3.0.2", - "marked": "4.3.0", + "marked": "^13.0.3", "react": "^17.0.2", "react-dom": "^17.0.2", "react-draggable": "^4.4.5", @@ -7292,15 +7292,16 @@ } }, "node_modules/marked": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", - "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/marked/-/marked-13.0.3.tgz", + "integrity": "sha512-rqRix3/TWzE9rIoFGIn8JmsVfhiuC8VIQ8IdX5TfzmeBucdY05/0UlzKaw0eVtpcN/OdVFpBk7CjKGo9iHJ/zA==", + "license": "MIT", "peer": true, "bin": { "marked": "bin/marked.js" }, "engines": { - "node": ">= 12" + "node": ">= 18" } }, "node_modules/memoize-one": { diff --git a/package.json b/package.json index 47c57a3fd..c69829fad 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "@rjsf/validator-ajv8": "^5.13.3", "@typeform/embed-react": "2.20.0", "dompurify": "^3.0.2", - "marked": "4.3.0", + "marked": "^13.0.3", "react": "^17.0.2", "react-dom": "^17.0.2", "react-draggable": "^4.4.5", diff --git a/src/Common/Markdown/MarkDown.tsx b/src/Common/Markdown/MarkDown.tsx index 624b797f4..99e289584 100644 --- a/src/Common/Markdown/MarkDown.tsx +++ b/src/Common/Markdown/MarkDown.tsx @@ -14,14 +14,12 @@ * limitations under the License. */ -import { marked } from 'marked' +import { marked, Tokens } from 'marked' import DOMPurify from 'dompurify' import { useEffect, useRef } from 'react' import { MarkDownProps } from './Types' import './markdown.scss' -const uncheckedCheckboxInputElement = `` -const checkedCheckboxInputElement = `` const renderer = new marked.Renderer() const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscapedText, ...props }: MarkDownProps) => { @@ -39,62 +37,67 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap getHeight() }, [markdown]) - const isReadmeInputCheckbox = (text: string) => { - if (text.includes(uncheckedCheckboxInputElement) || text.includes(checkedCheckboxInputElement)) { - return true - } - return false - } - - renderer.listitem = (text: string) => { - if (isReadmeInputCheckbox(text)) { - // eslint-disable-next-line no-param-reassign - text = text - .replace( - uncheckedCheckboxInputElement, - '', - ) - .replace( - checkedCheckboxInputElement, - '', - ) - return `
  • ${text}
  • ` + renderer.listitem = ({ text, task, checked }: Tokens.ListItem) => { + if (task) { + if (checked) { + return `
  • + + ${text} +
  • ` + } + return `
  • + + ${text} +
  • ` } return `
  • ${text}
  • ` } - renderer.image = (href: string, title: string, text: string) => + renderer.image = ({ href, title, text }: Tokens.Image) => `${text}` - renderer.table = (header, body) => ` + renderer.table = ({ header, rows }: Tokens.Table) => { + const renderTableRow = (row: Tokens.TableCell[]) => ` + + ${row.map((rowCell) => `${marked(rowCell.text)}`).join('')} + + ` + + return `
    - ${header} - ${body} + + ${header.map((headerCell) => ``).join('')} + + + ${rows.map((row) => renderTableRow(row)).join('')} +
    ${headerCell.text}
    ` + } - renderer.heading = (text, level) => { + renderer.heading = ({ text, depth }: Tokens.Heading) => { const escapedText = disableEscapedText ? '' : text.toLowerCase().replace(/[^\w]+/g, '-') return ` - + ${text} - + ` } marked.setOptions({ renderer, gfm: true, - smartLists: true, ...(breaks && { breaks: true }), }) - const createMarkup = () => ({ __html: DOMPurify.sanitize(marked(markdown), { USE_PROFILES: { html: true } }) }) + const createMarkup = () => ({ + __html: DOMPurify.sanitize(marked(markdown) as string, { USE_PROFILES: { html: true } }), + }) return (
    Date: Wed, 20 Nov 2024 18:47:47 +0530 Subject: [PATCH 2/6] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 879d84951..452837e93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.11", + "version": "1.0.11-beta-1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.11", + "version": "1.0.11-beta-1", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 3c85a4377..201b06e20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.11", + "version": "1.0.11-beta-1", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 6fabc6642a9c96c3a0f71181d5e1757a9f77af77 Mon Sep 17 00:00:00 2001 From: Arun Jain Date: Thu, 21 Nov 2024 00:18:41 +0530 Subject: [PATCH 3/6] chore: history sidebar styles update --- src/Shared/Components/CICDHistory/Sidebar.tsx | 16 +++++++--------- .../Components/CICDHistory/cicdHistory.scss | 4 +--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Shared/Components/CICDHistory/Sidebar.tsx b/src/Shared/Components/CICDHistory/Sidebar.tsx index 323fa33c9..491f78b14 100644 --- a/src/Shared/Components/CICDHistory/Sidebar.tsx +++ b/src/Shared/Components/CICDHistory/Sidebar.tsx @@ -210,7 +210,7 @@ const HistorySummaryCard = React.memo( > {getTriggerStatusIcon(status)}
    -
    -
    +
    +
    {moment(startedOn).format(DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT)}
    {isCDType && ( <> -
    +
    {['pre', 'post'].includes(stage?.toLowerCase()) ? `${stage}-deploy` : stage}
    - {artifact && ( -
    +
    {artifact.split(':')[1].slice(-12)}
    @@ -241,7 +240,7 @@ const HistorySummaryCard = React.memo( )} -
    +
    {triggeredBy === 1 ? 'auto trigger' : triggeredByEmail}
    @@ -377,11 +376,10 @@ const Sidebar = React.memo(
    )} -
    +
    {fetchIdData === FetchIdDataStatus.SUCCESS && ( )} - {Array.from(triggerHistory) .sort(([a], [b]) => b - a) .map(([triggerId, triggerDetails], index) => ( diff --git a/src/Shared/Components/CICDHistory/cicdHistory.scss b/src/Shared/Components/CICDHistory/cicdHistory.scss index 7df3367f4..cf3a0a102 100644 --- a/src/Shared/Components/CICDHistory/cicdHistory.scss +++ b/src/Shared/Components/CICDHistory/cicdHistory.scss @@ -198,7 +198,6 @@ .deployment-history-card-container { text-decoration: unset; - padding: 0 16px; &:hover { text-decoration: unset; @@ -212,8 +211,7 @@ .deployment-history-card { display: grid; grid-template-columns: 20px 1fr; - padding: 12px 0; - column-gap: 12px; + column-gap: 8px; } .app-status__icon { From 8d3648c432daabb5f2c8d0abbd927ac28bf88225 Mon Sep 17 00:00:00 2001 From: Arun Jain Date: Mon, 25 Nov 2024 15:58:37 +0530 Subject: [PATCH 4/6] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/Markdown/MarkDown.tsx | 16 +++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 594eec745..f9e72a981 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.1.3", + "version": "1.1.3-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.1.3", + "version": "1.1.3-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 1af37d231..c61b1090f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.1.3", + "version": "1.1.3-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/Markdown/MarkDown.tsx b/src/Common/Markdown/MarkDown.tsx index 99e289584..ccd218be7 100644 --- a/src/Common/Markdown/MarkDown.tsx +++ b/src/Common/Markdown/MarkDown.tsx @@ -37,6 +37,12 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap getHeight() }, [markdown]) + const renderTableRow = (row: Tokens.TableCell[]) => ` + + ${row.map((rowCell) => `${marked(rowCell.text)}`).join('')} + + ` + renderer.listitem = ({ text, task, checked }: Tokens.ListItem) => { if (task) { if (checked) { @@ -56,14 +62,7 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap renderer.image = ({ href, title, text }: Tokens.Image) => `${text}` - renderer.table = ({ header, rows }: Tokens.Table) => { - const renderTableRow = (row: Tokens.TableCell[]) => ` - - ${row.map((rowCell) => `${marked(rowCell.text)}`).join('')} - - ` - - return ` + renderer.table = ({ header, rows }: Tokens.Table) => `
    @@ -75,7 +74,6 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap
    ` - } renderer.heading = ({ text, depth }: Tokens.Heading) => { const escapedText = disableEscapedText ? '' : text.toLowerCase().replace(/[^\w]+/g, '-') From 877b70679fb72861ebd976abb1134cb14ad2ec77 Mon Sep 17 00:00:00 2001 From: Arun Jain Date: Mon, 25 Nov 2024 16:27:25 +0530 Subject: [PATCH 5/6] chore: update list intem function --- src/Common/Markdown/MarkDown.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Common/Markdown/MarkDown.tsx b/src/Common/Markdown/MarkDown.tsx index ccd218be7..251d8b9b8 100644 --- a/src/Common/Markdown/MarkDown.tsx +++ b/src/Common/Markdown/MarkDown.tsx @@ -45,14 +45,8 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap renderer.listitem = ({ text, task, checked }: Tokens.ListItem) => { if (task) { - if (checked) { - return `
  • - - ${text} -
  • ` - } return `
  • - + ${text}
  • ` } From 0550b4ae4bdebc6de8949eda55bd9698a194f485 Mon Sep 17 00:00:00 2001 From: Arun Jain Date: Mon, 25 Nov 2024 18:45:20 +0530 Subject: [PATCH 6/6] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f9e72a981..2d194f7ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.1.3-beta-3", + "version": "1.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.1.3-beta-3", + "version": "1.1.4", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index c61b1090f..ab1cbfc70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.1.3-beta-3", + "version": "1.1.4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js",