diff --git a/src/components/Insights/InsightJiraTicket/index.tsx b/src/components/Insights/InsightJiraTicket/index.tsx index 532b2b280..e45001d74 100644 --- a/src/components/Insights/InsightJiraTicket/index.tsx +++ b/src/components/Insights/InsightJiraTicket/index.tsx @@ -50,26 +50,35 @@ export const InsightJiraTicket = (props: InsightJiraTicketProps) => { }); }; - const handleInsightTicketLink = (data: unknown) => { - const linkTicketResponse = data as LinkTicketResponse; + useEffect(() => { + const handleInsightTicketLink = (data: unknown) => { + const linkTicketResponse = data as LinkTicketResponse; - if (linkTicketResponse.success) { - setTicketLink(linkTicketResponse.ticketLink); - } else { - setErrorMessage(linkTicketResponse.message); - } + if (linkTicketResponse.success) { + setTicketLink(linkTicketResponse.ticketLink); + } else { + setErrorMessage(linkTicketResponse.message); + } - window.sendMessageToDigma({ - action: actions.GET_DATA - }); + window.sendMessageToDigma({ + action: actions.GET_DATA + }); - props.onReloadSpanInsight && props.onReloadSpanInsight(); - }; + props.onReloadSpanInsight && props.onReloadSpanInsight(); + }; - dispatcher.addActionListener( - actions.SET_TICKET_LINK, - handleInsightTicketLink - ); + dispatcher.addActionListener( + actions.SET_TICKET_LINK, + handleInsightTicketLink + ); + + return () => { + dispatcher.removeActionListener( + actions.SET_TICKET_LINK, + handleInsightTicketLink + ); + }; + }, []); useEffect(() => { if (props.relatedInsight) { diff --git a/src/components/common/JiraTicket/Field/index.tsx b/src/components/common/JiraTicket/Field/index.tsx index 891200984..891419311 100644 --- a/src/components/common/JiraTicket/Field/index.tsx +++ b/src/components/common/JiraTicket/Field/index.tsx @@ -28,7 +28,7 @@ export const Field = (props: FieldProps) => { props.multiline === true ? "top" : "center"; return ( - + {props.label} diff --git a/src/components/common/JiraTicket/Field/styles.ts b/src/components/common/JiraTicket/Field/styles.ts index 076cedf73..81c93784a 100644 --- a/src/components/common/JiraTicket/Field/styles.ts +++ b/src/components/common/JiraTicket/Field/styles.ts @@ -1,11 +1,12 @@ import styled from "styled-components"; import { redScale } from "../../../common/App/getTheme"; -import { ButtonContainerProps, ContentProps } from "./types"; +import { ButtonContainerProps, ContainerProps, ContentProps } from "./types"; -export const Container = styled.div` +export const Container = styled.div` display: flex; flex-direction: column; gap: 6px; + ${({ $selectable }) => (!$selectable ? "user-select: none;" : "")} `; export const Label = styled.label` diff --git a/src/components/common/JiraTicket/Field/types.ts b/src/components/common/JiraTicket/Field/types.ts index d3e635fd4..dd14d5a7a 100644 --- a/src/components/common/JiraTicket/Field/types.ts +++ b/src/components/common/JiraTicket/Field/types.ts @@ -14,6 +14,7 @@ export interface FieldProps { button: ReactNode; multiline?: boolean; errorMessage?: string; + selectable?: boolean; } export interface ButtonContainerProps { @@ -24,3 +25,7 @@ export interface ButtonContainerProps { export interface ContentProps { $multiline?: boolean; } + +export interface ContainerProps { + $selectable?: boolean; +} diff --git a/src/components/common/JiraTicket/index.tsx b/src/components/common/JiraTicket/index.tsx index 5e0e56eac..a1bfdfdaf 100644 --- a/src/components/common/JiraTicket/index.tsx +++ b/src/components/common/JiraTicket/index.tsx @@ -123,11 +123,13 @@ export const JiraTicket = (props: JiraTicketProps) => { onClick={() => copyToClipboard("summary", props.summary)} /> } + selectable={false} /> {props.description.isLoading ? (