({
packageName,
language,
fromVersion,
toVersion,
shouldShowDiff,
selectedChanges,
onToggleChangeSelection,
appName,
appPackage,
}: DiffViewerProps)
| 74 | appPackage: string |
| 75 | } |
| 76 | const DiffViewer = ({ |
| 77 | packageName, |
| 78 | language, |
| 79 | fromVersion, |
| 80 | toVersion, |
| 81 | shouldShowDiff, |
| 82 | selectedChanges, |
| 83 | onToggleChangeSelection, |
| 84 | appName, |
| 85 | appPackage, |
| 86 | }: DiffViewerProps) => { |
| 87 | const { isLoading, isDone, diff } = useFetchDiff({ |
| 88 | shouldShowDiff, |
| 89 | packageName, |
| 90 | language, |
| 91 | fromVersion, |
| 92 | toVersion, |
| 93 | }) |
| 94 | const [completedDiffs, setCompletedDiffs] = useState<string[]>([]) |
| 95 | const [isGoToDoneClicked, setIsGoToDoneClicked] = useState<boolean>(false) |
| 96 | const donePopoverPossibleOpts = { |
| 97 | done: { |
| 98 | content: 'Scroll to Done section', |
| 99 | cursorType: 's-resize', |
| 100 | }, |
| 101 | top: { |
| 102 | content: 'Scroll to Top', |
| 103 | cursorType: 'n-resize', |
| 104 | }, |
| 105 | } |
| 106 | const [donePopoverOpts, setDonePopoverOpts] = useState( |
| 107 | donePopoverPossibleOpts.done |
| 108 | ) |
| 109 | const doneTitleRef = useRef(null) |
| 110 | |
| 111 | const scrollToDone = () => scrollToRef(doneTitleRef) |
| 112 | const scrollToTop = () => window.scrollTo({ top: 0, behavior: 'smooth' }) |
| 113 | |
| 114 | const handleCompletedFilesCounterClick = () => { |
| 115 | setIsGoToDoneClicked(!isGoToDoneClicked) |
| 116 | if (isGoToDoneClicked) { |
| 117 | setDonePopoverOpts(donePopoverPossibleOpts.done) |
| 118 | scrollToTop() |
| 119 | } else { |
| 120 | setDonePopoverOpts(donePopoverPossibleOpts.top) |
| 121 | scrollToDone() |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | const handleCompleteDiff = (diffKey: string) => { |
| 126 | if (completedDiffs.includes(diffKey)) { |
| 127 | return setCompletedDiffs((prevCompletedDiffs) => |
| 128 | prevCompletedDiffs.filter((completedDiff) => completedDiff !== diffKey) |
| 129 | ) |
| 130 | } |
| 131 | |
| 132 | setCompletedDiffs((prevCompletedDiffs) => [...prevCompletedDiffs, diffKey]) |
| 133 | } |
nothing calls this directly
no test coverage detected