|
@@ -2,12 +2,12 @@ import { useTranslation } from 'react-i18next'
|
|
|
import { useHistoryContext } from '../../../../context/history-context'
|
|
import { useHistoryContext } from '../../../../context/history-context'
|
|
|
import { UpdateRange } from '../../../../services/types/update'
|
|
import { UpdateRange } from '../../../../services/types/update'
|
|
|
import Compare from './compare'
|
|
import Compare from './compare'
|
|
|
-import { updateRangeUnion } from '../../../../utils/range'
|
|
|
|
|
import MaterialIcon from '../../../../../../shared/components/material-icon'
|
|
import MaterialIcon from '../../../../../../shared/components/material-icon'
|
|
|
|
|
+import { ItemSelectionState } from '../../../../utils/history-details'
|
|
|
|
|
|
|
|
type CompareItemsProps = {
|
|
type CompareItemsProps = {
|
|
|
updateRange: UpdateRange
|
|
updateRange: UpdateRange
|
|
|
- selected: boolean
|
|
|
|
|
|
|
+ selected: ItemSelectionState
|
|
|
closeDropdown: () => void
|
|
closeDropdown: () => void
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -18,62 +18,14 @@ function CompareItems({
|
|
|
}: CompareItemsProps) {
|
|
}: CompareItemsProps) {
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
const { selection } = useHistoryContext()
|
|
const { selection } = useHistoryContext()
|
|
|
- const { updateRange: selRange, comparing } = selection
|
|
|
|
|
-
|
|
|
|
|
- // Comparing mode variables
|
|
|
|
|
- const notASelectionBoundaryComparingMode =
|
|
|
|
|
- !!selRange &&
|
|
|
|
|
- comparing &&
|
|
|
|
|
- updateRange.toV !== selRange.toV &&
|
|
|
|
|
- updateRange.fromV !== selRange.fromV
|
|
|
|
|
- const showCompareWithSelected = !comparing && !!selRange && !selected
|
|
|
|
|
- const showCompareToThisComparingMode =
|
|
|
|
|
- notASelectionBoundaryComparingMode && updateRange.toV > selRange.toV
|
|
|
|
|
- const showCompareFromThisComparingMode =
|
|
|
|
|
- notASelectionBoundaryComparingMode && updateRange.fromV < selRange.fromV
|
|
|
|
|
-
|
|
|
|
|
- // Normal mode variables
|
|
|
|
|
- const notASelectionBoundaryNormalMode =
|
|
|
|
|
- !!selRange &&
|
|
|
|
|
- updateRange.toV !== selRange.toV &&
|
|
|
|
|
- updateRange.fromV !== selRange.fromV
|
|
|
|
|
- const showCompareToThisNormalMode =
|
|
|
|
|
- notASelectionBoundaryNormalMode && updateRange.toV > selRange.toV
|
|
|
|
|
- const showCompareFromThisNormalMode =
|
|
|
|
|
- notASelectionBoundaryNormalMode && updateRange.fromV < selRange.fromV
|
|
|
|
|
-
|
|
|
|
|
- let iconTypeNonSelectedVersion = ''
|
|
|
|
|
- let toolTipDescriptionNonSelectedVersion = ''
|
|
|
|
|
-
|
|
|
|
|
- if (showCompareToThisNormalMode) {
|
|
|
|
|
- iconTypeNonSelectedVersion = 'align_start'
|
|
|
|
|
- toolTipDescriptionNonSelectedVersion = t(
|
|
|
|
|
- 'history_compare_up_to_this_version'
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- if (showCompareFromThisNormalMode) {
|
|
|
|
|
- iconTypeNonSelectedVersion = 'align_end'
|
|
|
|
|
- toolTipDescriptionNonSelectedVersion = t(
|
|
|
|
|
- 'history_compare_from_this_version'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ const { updateRange: selRange } = selection
|
|
|
|
|
+ if (selRange === null) {
|
|
|
|
|
+ return null
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- {showCompareWithSelected ? (
|
|
|
|
|
- <Compare
|
|
|
|
|
- comparisonRange={updateRangeUnion(updateRange, selRange)}
|
|
|
|
|
- closeDropdown={closeDropdown}
|
|
|
|
|
- toolTipDescription={toolTipDescriptionNonSelectedVersion}
|
|
|
|
|
- icon={
|
|
|
|
|
- <MaterialIcon
|
|
|
|
|
- type={iconTypeNonSelectedVersion}
|
|
|
|
|
- className="material-symbols-rounded history-dropdown-icon p-1"
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
- ) : null}
|
|
|
|
|
- {showCompareFromThisComparingMode ? (
|
|
|
|
|
|
|
+ {selected === 'belowSelected' ? (
|
|
|
<Compare
|
|
<Compare
|
|
|
comparisonRange={{
|
|
comparisonRange={{
|
|
|
fromV: updateRange.fromV,
|
|
fromV: updateRange.fromV,
|
|
@@ -91,7 +43,7 @@ function CompareItems({
|
|
|
}
|
|
}
|
|
|
/>
|
|
/>
|
|
|
) : null}
|
|
) : null}
|
|
|
- {showCompareToThisComparingMode ? (
|
|
|
|
|
|
|
+ {selected === 'aboveSelected' ? (
|
|
|
<Compare
|
|
<Compare
|
|
|
comparisonRange={{
|
|
comparisonRange={{
|
|
|
fromV: selRange.fromV,
|
|
fromV: selRange.fromV,
|