From b053e73e7654cbcf5b66dd7cbc96a0a9527bc3de Mon Sep 17 00:00:00 2001 From: Andrew Rumble Date: Wed, 10 Apr 2024 10:56:17 +0100 Subject: [PATCH] Merge pull request #17815 from overleaf/ar-allow-labels-to-be-added-in-label-list Allow labels to be added from label list GitOrigin-RevId: 61abbc74aff1901f4adb16575b02148f8dbf99e2 --- .../change-list/all-history-list.tsx | 2 +- ...ntent.tsx => history-dropdown-content.tsx} | 18 +++++------ .../dropdown/label-dropdown-content.tsx | 32 ------------------- .../change-list/history-version.tsx | 10 +++--- .../change-list/label-list-item.tsx | 4 +-- .../history/components/change-list.spec.tsx | 4 +-- 6 files changed, 19 insertions(+), 51 deletions(-) rename services/web/frontend/js/features/history/components/change-list/dropdown/{version-dropdown-content.tsx => history-dropdown-content.tsx} (67%) delete mode 100644 services/web/frontend/js/features/history/components/change-list/dropdown/label-dropdown-content.tsx diff --git a/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx b/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx index 7c5cdfe03e..a2ded4fcc6 100644 --- a/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx +++ b/services/web/frontend/js/features/history/components/change-list/all-history-list.tsx @@ -201,7 +201,7 @@ function AllHistoryList() { update.toV ) const dropdownActive = - update === activeDropdownItem.item && + update.toV === activeDropdownItem.item && activeDropdownItem.whichDropDown === 'moreOptions' const compareDropdownActive = update === activeDropdownItem.item && diff --git a/services/web/frontend/js/features/history/components/change-list/dropdown/version-dropdown-content.tsx b/services/web/frontend/js/features/history/components/change-list/dropdown/history-dropdown-content.tsx similarity index 67% rename from services/web/frontend/js/features/history/components/change-list/dropdown/version-dropdown-content.tsx rename to services/web/frontend/js/features/history/components/change-list/dropdown/history-dropdown-content.tsx index 33605d2199..74bfa4b13d 100644 --- a/services/web/frontend/js/features/history/components/change-list/dropdown/version-dropdown-content.tsx +++ b/services/web/frontend/js/features/history/components/change-list/dropdown/history-dropdown-content.tsx @@ -1,38 +1,38 @@ import AddLabel from './menu-item/add-label' import Download from './menu-item/download' -import { LoadedUpdate } from '../../../services/types/update' +import { Version } from '../../../services/types/update' import { useCallback } from 'react' import { ActiveDropdown } from '../../../hooks/use-dropdown-active-item' type VersionDropdownContentProps = { projectId: string - update: LoadedUpdate + version: Version closeDropdownForItem: ActiveDropdown['closeDropdownForItem'] } -function VersionDropdownContent({ +function HistoryDropdownContent({ projectId, - update, + version, closeDropdownForItem, }: VersionDropdownContentProps) { const closeDropdown = useCallback(() => { - closeDropdownForItem(update, 'moreOptions') - }, [closeDropdownForItem, update]) + closeDropdownForItem(version, 'moreOptions') + }, [closeDropdownForItem, version]) return ( <> ) } -export default VersionDropdownContent +export default HistoryDropdownContent diff --git a/services/web/frontend/js/features/history/components/change-list/dropdown/label-dropdown-content.tsx b/services/web/frontend/js/features/history/components/change-list/dropdown/label-dropdown-content.tsx deleted file mode 100644 index 8f91999594..0000000000 --- a/services/web/frontend/js/features/history/components/change-list/dropdown/label-dropdown-content.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import Download from './menu-item/download' -import { Version } from '../../../services/types/update' -import { ActiveDropdown } from '../../../hooks/use-dropdown-active-item' -import { useCallback } from 'react' - -type LabelDropdownContentProps = { - projectId: string - version: Version - closeDropdownForItem: ActiveDropdown['closeDropdownForItem'] -} - -function LabelDropdownContent({ - projectId, - version, - closeDropdownForItem, -}: LabelDropdownContentProps) { - const closeDropdown = useCallback(() => { - closeDropdownForItem(version, 'moreOptions') - }, [closeDropdownForItem, version]) - - return ( - <> - - - ) -} - -export default LabelDropdownContent diff --git a/services/web/frontend/js/features/history/components/change-list/history-version.tsx b/services/web/frontend/js/features/history/components/change-list/history-version.tsx index a66a02d8d4..627f198e82 100644 --- a/services/web/frontend/js/features/history/components/change-list/history-version.tsx +++ b/services/web/frontend/js/features/history/components/change-list/history-version.tsx @@ -15,7 +15,7 @@ import { } from '../../utils/history-details' import { ActiveDropdown } from '../../hooks/use-dropdown-active-item' import { HistoryContextValue } from '../../context/types/history-context-value' -import VersionDropdownContent from './dropdown/version-dropdown-content' +import HistoryDropdownContent from './dropdown/history-dropdown-content' import CompareItems from './dropdown/menu-item/compare-items' import CompareVersionDropdown from './dropdown/compare-version-dropdown' import { CompareVersionDropdownContentAllHistory } from './dropdown/compare-version-dropdown-content' @@ -55,7 +55,7 @@ function HistoryVersion({ }: HistoryVersionProps) { const orderedLabels = orderBy(update.labels, ['created_at'], ['desc']) const closeDropdown = useCallback(() => { - closeDropdownForItem(update, 'moreOptions') + closeDropdownForItem(update.toV, 'moreOptions') }, [closeDropdownForItem, update]) const updateRange = updateRangeForUpdate(update) @@ -102,15 +102,15 @@ function HistoryVersion({ isOpened={dropdownOpen} setIsOpened={(isOpened: boolean) => setActiveDropdownItem({ - item: update, + item: update.toV, isOpened, whichDropDown: 'moreOptions', }) } > {dropdownActive ? ( - diff --git a/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx b/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx index a6fc87ed8d..57b4ea07aa 100644 --- a/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx +++ b/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx @@ -8,11 +8,11 @@ import { LoadedLabel } from '../../services/types/label' import { useTranslation } from 'react-i18next' import { ActiveDropdown } from '../../hooks/use-dropdown-active-item' import { HistoryContextValue } from '../../context/types/history-context-value' -import LabelDropdownContent from './dropdown/label-dropdown-content' import CompareItems from './dropdown/menu-item/compare-items' import { ItemSelectionState } from '../../utils/history-details' import CompareVersionDropdown from './dropdown/compare-version-dropdown' import { CompareVersionDropdownContentLabelsList } from './dropdown/compare-version-dropdown-content' +import HistoryDropdownContent from '@/features/history/components/change-list/dropdown/history-dropdown-content' type LabelListItemProps = { version: Version @@ -87,7 +87,7 @@ function LabelListItem({ setIsOpened={setIsOpened} > {dropdownActive ? ( - { @@ -327,7 +327,7 @@ describe('change list', function () { cy.findByRole('menu').within(() => { cy.findByRole('menuitem', { name: /label this version/i, - }).should('not.exist') + }).should('exist') }) }) })