-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
130 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...ionModal/tabs/selectDefectManually/makeDecisionDefectCommentAddon/ai-inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions
62
...sionModal/tabs/selectDefectManually/makeDecisionDefectCommentAddon/defectCommentAddon.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import Parser from 'html-react-parser'; | ||
import classNames from 'classnames/bind'; | ||
import { BubblesPreloader } from 'components/preloaders/bubblesPreloader'; | ||
import styles from './defectCommentAddon.scss'; | ||
import AiIcon from './ai-inline.svg'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
export const DefectCommentAddon = (props) => { | ||
const { | ||
// eslint-disable-next-line react/prop-types | ||
comment: existingComment, | ||
// eslint-disable-next-line react/prop-types | ||
onChangeComment, | ||
// eslint-disable-next-line react/prop-types | ||
item, // TODO: use item id | ||
// ...extensionProps | ||
} = props; | ||
// const { lib: { React, Parser, classNames }, components: { BubblesPreloader } } = extensionProps; | ||
// const cx = React.useMemo(() => classNames.bind(styles), [classNames, styles]); | ||
const [llmSuggestLoading, setLlmSuggestLoading] = React.useState(false); | ||
const [appliedSuggestion, setAppliedSuggestion] = React.useState(''); | ||
|
||
React.useEffect(() => { | ||
if (appliedSuggestion !== existingComment && appliedSuggestion !== '') { | ||
setAppliedSuggestion(''); | ||
} | ||
}, [existingComment]); | ||
|
||
const loadLlmSuggestion = () => { | ||
console.log('Item: ', item); | ||
const suggestedComment = "This defect is not a bug. It's a feature"; | ||
const comment = existingComment ? `${existingComment}\n${suggestedComment}` : suggestedComment; | ||
setLlmSuggestLoading(true); | ||
// TODO: API request will be here instead of a timeout | ||
setTimeout(() => { | ||
onChangeComment(comment); | ||
setAppliedSuggestion(comment); | ||
setLlmSuggestLoading(false); | ||
}, 1500); | ||
}; | ||
|
||
return ( | ||
<div className={cx('defect-comment-addon', { applied: !!appliedSuggestion })}> | ||
{llmSuggestLoading ? ( | ||
<span className={cx('loader')}> | ||
<BubblesPreloader color="#eabcff" /> | ||
</span> | ||
) : ( | ||
<button | ||
className={cx('ask-ai-button')} | ||
onClick={loadLlmSuggestion} | ||
disabled={!!appliedSuggestion} | ||
> | ||
<span className={cx('ai-icon')}>{Parser(AiIcon)}</span> | ||
{appliedSuggestion ? 'Pasted' : 'Ask AI to generate a comment'} | ||
</button> | ||
)} | ||
</div> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
...ionModal/tabs/selectDefectManually/makeDecisionDefectCommentAddon/defectCommentAddon.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.defect-comment-addon { | ||
height: 22px; | ||
margin: 10px 0; | ||
font-size: 13px; | ||
color: #eabcff; | ||
|
||
&.applied { | ||
color: #515151; | ||
path { | ||
fill: #515151; | ||
} | ||
|
||
.ask-ai-button { | ||
&:hover { | ||
cursor: default; | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.ask-ai-button { | ||
display: inline-flex; | ||
align-items: center; | ||
height: 22px; | ||
gap: 8px; | ||
padding: 0; | ||
background: none; | ||
border: none; | ||
color: inherit; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
opacity: 0.8; | ||
} | ||
} | ||
|
||
.ai-icon { | ||
display: inline-block; | ||
width: 19px; | ||
height: 20px; | ||
} | ||
|
||
.loader { | ||
display: inline-block; | ||
width: 50px; | ||
height: 6px; | ||
} |
1 change: 1 addition & 0 deletions
1
...odals/makeDecisionModal/tabs/selectDefectManually/makeDecisionDefectCommentAddon/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { DefectCommentAddon } from './defectCommentAddon'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters