Fix copy cotent and stop click propagation

pull/4504/head
ioedeveloper 10 months ago committed by Aniket
parent e87db8bf44
commit 24416dcc55
  1. 4
      apps/circuit-compiler/src/app/components/feedback.tsx
  2. 10
      apps/circuit-compiler/src/app/components/feedbackAlert.tsx
  3. 1
      apps/circuit-compiler/src/app/types/index.ts
  4. 1
      libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx

@ -45,8 +45,7 @@ export function CompilerFeedback ({ feedback, filePathToId, hideWarnings, openEr
<RenderIf condition={response.type === 'Error'}>
<div className={`circuit_feedback ${response.type.toLowerCase()} alert alert-danger`} data-id="circuit_feedback">
<FeedbackAlert
message={response.message}
location={ response.labels[0] ? response.labels[0].message + ` ${filePathToId[response.labels[0].file_id]}:${response.labels[0].range.start}:${response.labels[0].range.end}` : null}
message={response.message + (response.labels[0] ? ": " + response.labels[0].message + ` ${filePathToId[response.labels[0].file_id]}:${response.labels[0].range.start}:${response.labels[0].range.end}` : '')}
askGPT={ () => handleAskGPT(response) } />
</div>
</RenderIf>
@ -54,7 +53,6 @@ export function CompilerFeedback ({ feedback, filePathToId, hideWarnings, openEr
<div className={`circuit_feedback ${response.type.toLowerCase()} alert alert-warning`} data-id="circuit_feedback">
<FeedbackAlert
message={response.message}
location={null}
askGPT={() => { handleAskGPT(response) }} />
</div>
</RenderIf>

@ -3,7 +3,7 @@ import { FeedbackAlertProps } from '../types'
import { RenderIf } from '@remix-ui/helper'
import {CopyToClipboard} from '@remix-ui/clipboard'
export function FeedbackAlert ({ message, location, askGPT }: FeedbackAlertProps) {
export function FeedbackAlert ({ message, askGPT }: FeedbackAlertProps) {
const [ showAlert, setShowAlert] = useState<boolean>(true)
const handleCloseAlert = () => {
@ -14,9 +14,6 @@ export function FeedbackAlert ({ message, location, askGPT }: FeedbackAlertProps
<RenderIf condition={showAlert}>
<>
<span> { message } </span>
<RenderIf condition={location !== null}>
<span> { location }</span>
</RenderIf>
<div className="close" data-id="renderer" onClick={handleCloseAlert}>
<i className="fas fa-times"></i>
</div>
@ -24,7 +21,10 @@ export function FeedbackAlert ({ message, location, askGPT }: FeedbackAlertProps
<span className="ml-3 pt-1 py-1" >
<CopyToClipboard content={message} className="p-0 m-0 far fa-copy error" direction={'top'} />
</span>
<span className="border border-success text-success btn-sm" onClick={askGPT}>ASK GPT</span>
<span className="border border-success text-success btn-sm" onClick={(e) => {
e.stopPropagation()
askGPT()
}}>ASK GPT</span>
</div>
</>
</RenderIf>

@ -72,7 +72,6 @@ export type CompilerReport = {
export type FeedbackAlertProps = {
message: string,
location: string,
askGPT: () => void
}

@ -44,6 +44,7 @@ export const CopyToClipboard = (props: ICopyToClipboard) => {
content = getContent && getContent()
copyData()
}
e.stopPropagation()
e.preventDefault()
}

Loading…
Cancel
Save