@@ -10,6 +10,7 @@ import {
1010 useToggle ,
1111} from '@openedx/paragon' ;
1212import { useEffect , useCallback } from 'react' ;
13+ import { Link } from 'react-router-dom' ;
1314import { MoreVert } from '@openedx/paragon/icons' ;
1415
1516import { useComponentPickerContext } from '../common/context/ComponentPickerContext' ;
@@ -70,7 +71,7 @@ const UnitMenu = ({ containerId, displayName }: ContainerMenuProps) => {
7071const UnitInfo = ( ) => {
7172 const intl = useIntl ( ) ;
7273
73- const { setUnitId } = useLibraryContext ( ) ;
74+ const { libraryId } = useLibraryContext ( ) ;
7475 const { componentPickerMode } = useComponentPickerContext ( ) ;
7576 const {
7677 defaultTab,
@@ -81,7 +82,7 @@ const UnitInfo = () => {
8182 sidebarAction,
8283 } = useSidebarContext ( ) ;
8384 const jumpToCollections = sidebarAction === SidebarActions . JumpToAddCollections ;
84- const { insideUnit, navigateTo } = useLibraryRoutes ( ) ;
85+ const { insideUnit } = useLibraryRoutes ( ) ;
8586
8687 const tab : UnitInfoTab = (
8788 sidebarTab && isUnitInfoTab ( sidebarTab )
@@ -90,15 +91,7 @@ const UnitInfo = () => {
9091 const unitId = sidebarComponentInfo ?. id ;
9192 const { data : container } = useContainer ( unitId ) ;
9293
93- const handleOpenUnit = useCallback ( ( ) => {
94- if ( componentPickerMode ) {
95- setUnitId ( unitId ) ;
96- } else {
97- navigateTo ( { unitId } ) ;
98- }
99- } , [ componentPickerMode , navigateTo , unitId ] ) ;
100-
101- const showOpenUnitButton = ! insideUnit || componentPickerMode ;
94+ const showOpenUnitButton = ! insideUnit && ! componentPickerMode ;
10295
10396 const renderTab = useCallback ( ( infoTab : UnitInfoTab , component : React . ReactNode , title : string ) => {
10497 if ( hiddenTabs . includes ( infoTab ) ) {
@@ -130,7 +123,8 @@ const UnitInfo = () => {
130123 < Button
131124 variant = "outline-primary"
132125 className = "m-1 text-nowrap flex-grow-1"
133- onClick = { handleOpenUnit }
126+ as = { Link }
127+ to = { `/library/${ libraryId } /unit/${ unitId } ` }
134128 >
135129 { intl . formatMessage ( messages . openUnitButton ) }
136130 </ Button >
0 commit comments