From b6ef44f1f3feb717e3b9c3ea0cad802170b68dfd Mon Sep 17 00:00:00 2001 From: raghavaggarwal2308 Date: Wed, 7 Feb 2024 17:00:46 +0530 Subject: [PATCH 1/4] [MM-197] Added check for the 'show' prop before making API request for the link tooltip. --- webapp/src/components/link_tooltip/link_tooltip.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/link_tooltip/link_tooltip.jsx b/webapp/src/components/link_tooltip/link_tooltip.jsx index f34c432b1..8306cf27a 100644 --- a/webapp/src/components/link_tooltip/link_tooltip.jsx +++ b/webapp/src/components/link_tooltip/link_tooltip.jsx @@ -42,7 +42,7 @@ export const getInfoAboutLink = (href, hostname) => { return {}; }; -export const LinkTooltip = ({href, connected, gitlabURL}) => { +export const LinkTooltip = ({href, connected, gitlabURL, show}) => { const [data, setData] = useState(null); const dispatch = useDispatch(); useEffect(() => { @@ -74,12 +74,12 @@ export const LinkTooltip = ({href, connected, gitlabURL}) => { } }; - if (!connected) { + if (!connected || !show) { return; } init(); - }, [connected, href]); + }, [connected, href, show]); const getIconElement = () => { const iconProps = { From 1e23da466ab52d233d2b0691464358892b4f7dd4 Mon Sep 17 00:00:00 2001 From: raghavaggarwal2308 Date: Wed, 7 Feb 2024 18:57:25 +0530 Subject: [PATCH 2/4] [MM-197] Fix lint error --- webapp/src/components/link_tooltip/link_tooltip.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/src/components/link_tooltip/link_tooltip.jsx b/webapp/src/components/link_tooltip/link_tooltip.jsx index 8306cf27a..a675af963 100644 --- a/webapp/src/components/link_tooltip/link_tooltip.jsx +++ b/webapp/src/components/link_tooltip/link_tooltip.jsx @@ -210,4 +210,5 @@ LinkTooltip.propTypes = { href: PropTypes.string.isRequired, connected: PropTypes.bool.isRequired, gitlabURL: PropTypes.string.isRequired, + show: PropTypes.bool, }; From b8940f89f252f5a85fd060c8843d1b7a724c07fb Mon Sep 17 00:00:00 2001 From: raghavaggarwal2308 Date: Thu, 8 Feb 2024 14:25:43 +0530 Subject: [PATCH 3/4] [MM-197] Review fixe --- webapp/src/components/link_tooltip/link_tooltip.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/src/components/link_tooltip/link_tooltip.jsx b/webapp/src/components/link_tooltip/link_tooltip.jsx index a675af963..69bd73224 100644 --- a/webapp/src/components/link_tooltip/link_tooltip.jsx +++ b/webapp/src/components/link_tooltip/link_tooltip.jsx @@ -46,6 +46,10 @@ export const LinkTooltip = ({href, connected, gitlabURL, show}) => { const [data, setData] = useState(null); const dispatch = useDispatch(); useEffect(() => { + if (!connected || !show) { + return; + } + if (!isValidUrl(href)) { return; } @@ -74,10 +78,6 @@ export const LinkTooltip = ({href, connected, gitlabURL, show}) => { } }; - if (!connected || !show) { - return; - } - init(); }, [connected, href, show]); From 1485e8234eecf295a700c79355debf247a14425e Mon Sep 17 00:00:00 2001 From: raghavaggarwal2308 Date: Fri, 9 Feb 2024 13:01:13 +0530 Subject: [PATCH 4/4] [MM-197] Review fix: returned "null" from the component when "show" prop is false --- webapp/src/components/link_tooltip/link_tooltip.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/link_tooltip/link_tooltip.jsx b/webapp/src/components/link_tooltip/link_tooltip.jsx index 69bd73224..40c44b8ac 100644 --- a/webapp/src/components/link_tooltip/link_tooltip.jsx +++ b/webapp/src/components/link_tooltip/link_tooltip.jsx @@ -118,7 +118,7 @@ export const LinkTooltip = ({href, connected, gitlabURL, show}) => { ); }; - if (!data) { + if (!data || !show) { return null; }