From 091346853018cb06071442b21b07592cd54a6f33 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:36:16 +0200 Subject: [PATCH 1/2] chore(deps): bump ip from 1.1.8 to 1.1.9 (#689) Bumps [ip](https://github.com/indutny/node-ip) from 1.1.8 to 1.1.9. - [Commits](https://github.com/indutny/node-ip/compare/v1.1.8...v1.1.9) --- updated-dependencies: - dependency-name: ip dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index e248b585..c8d35683 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4128,7 +4128,7 @@ resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== -"@types/react-dom@^17.0.14": +"@types/react-dom@17.0.20", "@types/react-dom@^17.0.14": version "17.0.20" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.20.tgz#e0c8901469d732b36d8473b40b679ad899da1b53" integrity sha512-4pzIjSxDueZZ90F52mU3aPoogkHIoSIDG+oQ+wQK7Cy2B9S+MvOqY0uEA/qawKz381qrEDkvpwyt8Bm31I8sbA== @@ -4159,7 +4159,7 @@ "@types/history" "^4.7.11" "@types/react" "*" -"@types/react@*", "@types/react@^17", "@types/react@^17.0.14": +"@types/react@*", "@types/react@17.0.63", "@types/react@^17", "@types/react@^17.0.14": version "17.0.63" resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.63.tgz#78ca41a34b1e4fd5ba9398d33bc78a81bfd5c180" integrity sha512-T+aaG8RlIkgJ4VzWLJYbMW9QX7sIAV8CcuyV6FU6Hm7yu3Bee1YBZQRu2vYEm/dU8kre+/mzl2aGYh5MFgVLaQ== @@ -8563,14 +8563,14 @@ ioredis@^5.3.2: standard-as-callback "^2.1.0" ip@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" - integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== + version "1.1.9" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.9.tgz#8dfbcc99a754d07f425310b86a99546b1151e396" + integrity sha512-cyRxvOEpNHNtchU3Ln9KC/auJgup87llfQpQ+t5ghoC/UhL16SWzbueiCsdTnWmqAWl7LadfuwhlqmtOaqMHdQ== ip@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" - integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== + version "2.0.1" + resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.1.tgz#e8f3595d33a3ea66490204234b77636965307105" + integrity sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ== ipaddr.js@1.9.1: version "1.9.1" From 37921ddbc4372271e94c88b3e48e61083f8d51f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Yepes?= <23552631+ivnnv@users.noreply.github.com> Date: Tue, 27 Feb 2024 03:20:43 -0500 Subject: [PATCH 2/2] Highlight to be a FunctionalComponent (#693) * Highlight to be a FunctionalComponent * nl --- .../ui/src/components/Highlight/Highlight.tsx | 84 ++++++++----------- .../Details/DetailsContent/DetailsContent.tsx | 8 +- 2 files changed, 39 insertions(+), 53 deletions(-) diff --git a/packages/ui/src/components/Highlight/Highlight.tsx b/packages/ui/src/components/Highlight/Highlight.tsx index 777b8bb1..fcb0384e 100644 --- a/packages/ui/src/components/Highlight/Highlight.tsx +++ b/packages/ui/src/components/Highlight/Highlight.tsx @@ -1,5 +1,5 @@ import cn from 'clsx'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { asyncHighlight } from '../../utils/highlight/highlight'; import s from './Highlight.module.css'; import { Button } from '../Button/Button'; @@ -7,52 +7,40 @@ import { CopyIcon } from '../Icons/Copy'; interface HighlightProps { language: 'json' | 'stacktrace'; - children: string | null; + text: string; } -export class Highlight extends React.Component { - private codeRef = React.createRef(); - - public shouldComponentUpdate(nextProps: Readonly) { - return ( - nextProps.language !== this.props.language || - (Array.isArray(this.props.children) - ? this.props.children.some( - (item: any) => !([] as any).concat(nextProps.children).includes(item) - ) - : nextProps.children !== this.props.children) - ); - } - - public componentDidMount() { - return this.highlightCode(); - } - - public componentDidUpdate() { - return this.highlightCode(); - } - - public render() { - const { language } = this.props; - return ( -
-
-          
-        
- -
- ); - } - - private async highlightCode() { - const node = this.codeRef.current?.querySelector('code'); - if (node) { - node.innerHTML = await asyncHighlight(this.props.children as string, this.props.language); - } - } -} +export const Highlight: React.FC = ({ language, text }) => { + const [code, setCode] = useState(''); + + const textToCode = async () => { + setCode(await asyncHighlight(text as string, language)); + }; + + useEffect(() => { + textToCode(); + }, []); + + useEffect(() => { + textToCode(); + }, [language, text]); + + const handleCopyClick = () => { + navigator.clipboard.writeText(text ?? ''); + }; + + return ( +
+
+        
+      
+ + +
+ ); +}; diff --git a/packages/ui/src/components/JobCard/Details/DetailsContent/DetailsContent.tsx b/packages/ui/src/components/JobCard/Details/DetailsContent/DetailsContent.tsx index b26632ee..3687f960 100644 --- a/packages/ui/src/components/JobCard/Details/DetailsContent/DetailsContent.tsx +++ b/packages/ui/src/components/JobCard/Details/DetailsContent/DetailsContent.tsx @@ -29,7 +29,7 @@ export const DetailsContent = ({ selectedTab, job, actions }: DetailsContentProp {t('JOB.SHOW_DATA_BTN')} ) : ( - {JSON.stringify({ data, returnValue }, null, 2)} + ); case 'Options': return collapseJobOptions && !collapseState.options ? ( @@ -37,7 +37,7 @@ export const DetailsContent = ({ selectedTab, job, actions }: DetailsContentProp {t('JOB.SHOW_OPTIONS_BTN')} ) : ( - {JSON.stringify(opts, null, 2)} + ); case 'Error': if (stacktrace.length === 0) { @@ -49,9 +49,7 @@ export const DetailsContent = ({ selectedTab, job, actions }: DetailsContentProp {t('JOB.SHOW_ERRORS_BTN')} ) : ( - - {stacktrace.join('\n')} - + ); case 'Logs': return ;