From 5dd5b4f614833e5ba070c75589af73e61777e651 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Thu, 13 Apr 2023 15:48:03 +0300 Subject: [PATCH] feat: linkify comments (#3517) --- frontend/package.json | 4 ++- .../ChangeRequestComment.tsx | 5 ++- frontend/yarn.lock | 32 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index aa0c930fff..9c984c5bed 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -52,6 +52,7 @@ "@types/node": "17.0.18", "@types/react": "17.0.56", "@types/react-dom": "17.0.19", + "@types/react-linkify": "1.0.1", "@types/react-router-dom": "5.3.3", "@types/react-table": "7.7.14", "@types/react-test-renderer": "17.0.2", @@ -108,7 +109,8 @@ "vitest": "0.28.5", "whatwg-fetch": "3.6.2", "countries-and-timezones": "^3.4.0", - "date-fns-tz": "^2.0.0" + "date-fns-tz": "^2.0.0", + "react-linkify": "^1.0.0-alpha" }, "optionalDependencies": { "orval": "^6.10.3" diff --git a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestComments/ChangeRequestComment.tsx b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestComments/ChangeRequestComment.tsx index fb202cbf36..226bc8d18f 100644 --- a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestComments/ChangeRequestComment.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestComments/ChangeRequestComment.tsx @@ -4,6 +4,7 @@ import { Box, styled, Typography, Tooltip } from '@mui/material'; import TimeAgo from 'react-timeago'; import { StyledAvatar } from './StyledAvatar'; import { IChangeRequestComment } from '../../changeRequest.types'; +import Linkify from 'react-linkify'; const ChangeRequestCommentWrapper = styled(Box)(({ theme }) => ({ display: 'flex', @@ -44,7 +45,9 @@ export const ChangeRequestComment: FC<{ comment: IChangeRequestComment }> = ({ - {comment.text} + + {comment.text} + ); diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 51faf375da..a5dd173c5a 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2511,6 +2511,13 @@ dependencies: "@types/react" "*" +"@types/react-linkify@1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@types/react-linkify/-/react-linkify-1.0.1.tgz#4ece351faef22bfde1280b6d9ace5e88683a74d4" + integrity sha512-qPxYwjB41ezoKdLXs0MrQ1FnhF3apyyxf3J7WVQQCBu/GyZQAW7Y3TY4317jdh0450QJ4fLqj0rnhIJvFZOamQ== + dependencies: + "@types/react" "*" + "@types/react-router-dom@5.3.3": version "5.3.3" resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.3.3.tgz#e9d6b4a66fcdbd651a5f106c2656a30088cc1e83" @@ -6243,6 +6250,13 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +linkify-it@^2.0.3: + version "2.2.0" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf" + integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw== + dependencies: + uc.micro "^1.0.1" + listr2@^3.8.3: version "3.14.0" resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.14.0.tgz#23101cc62e1375fd5836b248276d1d2b51fdbe9e" @@ -7501,6 +7515,14 @@ react-is@^17.0.1, react-is@^17.0.2: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +react-linkify@^1.0.0-alpha: + version "1.0.0-alpha" + resolved "https://registry.yarnpkg.com/react-linkify/-/react-linkify-1.0.0-alpha.tgz#b391c7b88e3443752fafe76a95ca4434e82e70d5" + integrity sha512-7gcIUvJkAXXttt1fmBK9cwn+1jTa4hbKLGCZ9J1U6EOkyb2/+LKL1Z28d9rtDLMnpvImlNlLPdTPooorl5cpmg== + dependencies: + linkify-it "^2.0.3" + tlds "^1.199.0" + react-markdown@^8.0.4: version "8.0.4" resolved "https://registry.yarnpkg.com/react-markdown/-/react-markdown-8.0.4.tgz#b5ff1f0f29ead71a7a6f98815eb1a70bcc2a036e" @@ -8384,6 +8406,11 @@ tinyspy@^1.0.2: resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-1.0.2.tgz#6da0b3918bfd56170fb3cd3a2b5ef832ee1dff0d" integrity sha512-bSGlgwLBYf7PnUsQ6WOc6SJ3pGOcd+d8AA6EUnLDDM0kWEstC1JIlSZA3UNliDXhd9ABoS7hiRBDCu+XP/sf1Q== +tlds@^1.199.0: + version "1.238.0" + resolved "https://registry.yarnpkg.com/tlds/-/tlds-1.238.0.tgz#ffe7c19c8940c35b497cda187a6927f9450325a4" + integrity sha512-lFPF9pZFhLrPodaJ0wt9QIN0l8jOxqmUezGZnm7BfkDSVd9q667oVIJukLVzhF+4oW7uDlrLlfJrL5yu9RWwew== + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -8561,6 +8588,11 @@ typescript@4.8.4: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== +uc.micro@^1.0.1: + version "1.0.6" + resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== + ufo@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.0.1.tgz#64ed43b530706bda2e4892f911f568cf4cf67d29"