diff --git a/services/web/frontend/js/features/history/components/change-list/dropdown/compare-version-dropdown-content.tsx b/services/web/frontend/js/features/history/components/change-list/dropdown/compare-version-dropdown-content.tsx index 70e7f49c58..ae5e77a5b5 100644 --- a/services/web/frontend/js/features/history/components/change-list/dropdown/compare-version-dropdown-content.tsx +++ b/services/web/frontend/js/features/history/components/change-list/dropdown/compare-version-dropdown-content.tsx @@ -1,10 +1,11 @@ import { LoadedUpdate, Version } from '../../../services/types/update' -import { ReactNode, useCallback } from 'react' +import { useCallback } from 'react' import { ActiveDropdown } from '../../../hooks/use-dropdown-active-item' -import { MenuItem } from 'react-bootstrap' import { useTranslation } from 'react-i18next' -import CompareItems from './menu-item/compare-items' import { updateRangeForUpdate } from '../../../utils/history-details' +import CompareDropDownItem from './menu-item/compare-dropdown-item' +import { useHistoryContext } from '../../../context/history-context' +import MaterialIcon from '../../../../../shared/components/material-icon' type VersionDropdownContentAllHistoryProps = { update: LoadedUpdate @@ -22,25 +23,45 @@ function CompareVersionDropdownContentAllHistory({ }, [closeDropdownForItem, update]) const { t } = useTranslation() - + const { selection } = useHistoryContext() + const { updateRange: selRange } = selection + if (selRange === null) { + return null + } return ( <> - - - - - - + + } + /> + + } + /> ) } @@ -61,47 +82,46 @@ function CompareVersionDropdownContentLabelsList({ }, [closeDropdownForItem, version]) const { t } = useTranslation() + const { selection } = useHistoryContext() + const { updateRange: selRange } = selection + if (selRange === null) { + return null + } return ( <> - - - - - - - - ) -} - -type DropdownOptionProps = { - children: ReactNode -} - -function DropdownOption({ children, ...props }: DropdownOptionProps) { - return ( - <> - {children} + + } + /> + + } + /> ) } diff --git a/services/web/frontend/js/features/history/components/change-list/dropdown/menu-item/compare-dropdown-item.tsx b/services/web/frontend/js/features/history/components/change-list/dropdown/menu-item/compare-dropdown-item.tsx new file mode 100644 index 0000000000..fa907f2abf --- /dev/null +++ b/services/web/frontend/js/features/history/components/change-list/dropdown/menu-item/compare-dropdown-item.tsx @@ -0,0 +1,43 @@ +import Icon from '../../../../../../shared/components/icon' +import { useHistoryContext } from '../../../../context/history-context' +import { UpdateRange } from '../../../../services/types/update' +import { ReactNode } from 'react' +import { Button, MenuItem } from 'react-bootstrap' + +type CompareProps = { + comparisonRange: UpdateRange + icon: ReactNode + text: string + closeDropdown: () => void +} + +function CompareDropDownItem({ + comparisonRange, + text, + closeDropdown, + icon = , + ...props +}: CompareProps) { + const { setSelection } = useHistoryContext() + + const handleCompareVersion = (e: React.MouseEvent ) diff --git a/services/web/test/frontend/features/history/components/change-list.spec.tsx b/services/web/test/frontend/features/history/components/change-list.spec.tsx index 0221b3a4b7..6a387d4463 100644 --- a/services/web/test/frontend/features/history/components/change-list.spec.tsx +++ b/services/web/test/frontend/features/history/components/change-list.spec.tsx @@ -363,9 +363,11 @@ describe('change list', function () { .eq(1) .within(() => { cy.findByRole('button', { name: /compare drop down/i }).click() - cy.findByRole('button', { - name: /compare up to this version/i, - }).click() + cy.findByRole('menu').within(() => { + cy.findByRole('menuitem', { + name: /compare up to this version/i, + }).click() + }) }) cy.findAllByTestId('history-version-details').should($versions => {