11import { selectUser } from "@/src/reduxStore/states/general" ;
22import { selectAvailableLinks , selectDisplayUserRole , selectSelectedLink , selectUserDisplayId , selectUserIconsData , setAvailableLinks , setHoverGroupDict , setSelectedLink , setUserDisplayId } from "@/src/reduxStore/states/pages/labeling" ;
33import { selectProjectId } from "@/src/reduxStore/states/project" ;
4- import { LabelingLinkType , UserType } from "@/src/types/components/projects/projectId/labeling/labeling-main-component" ;
4+ import { LabelingLinkType , NavigationBarTopProps , UserType } from "@/src/types/components/projects/projectId/labeling/labeling-main-component" ;
55import { UserRole } from "@/src/types/shared/sidebar" ;
66import { SessionManager } from "@/src/util/classes/labeling/session-manager" ;
77import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants" ;
@@ -14,8 +14,9 @@ import Dropdown2 from "@/submodules/react-components/components/Dropdown2";
1414import { useEffect } from "react" ;
1515import { useLazyQuery } from "@apollo/client" ;
1616import { AVAILABLE_LABELING_LINKS } from "@/src/services/gql/queries/labeling" ;
17+ import { parseLinkFromText } from "@/src/util/shared/link-parser-helper" ;
1718
18- export default function NavigationBarTop ( props : { absoluteWarning ?: string } ) {
19+ export default function NavigationBarTop ( props : NavigationBarTopProps ) {
1920 const router = useRouter ( ) ;
2021 const dispatch = useDispatch ( ) ;
2122
@@ -56,6 +57,12 @@ export default function NavigationBarTop(props: { absoluteWarning?: string }) {
5657 router . push ( `/projects/${ projectId } /labeling/${ SessionManager . labelingLinkData . huddleId } ?pos=${ SessionManager . huddleData . linkData . requestedPos } &type=${ SessionManager . huddleData . linkData . linkType } ` ) ;
5758 }
5859
60+ function dropdownSelectLink ( option : any ) {
61+ dispatch ( setSelectedLink ( option ) ) ;
62+ const linkData = parseLinkFromText ( option . link ) ;
63+ router . push ( `${ linkData . route } ?pos=${ linkData . queryParams . pos } &type=${ linkData . queryParams . type } ` )
64+ }
65+
5966 return ( < >
6067 { user && < div className = "w-full px-4 border-gray-200 border-b h-16" >
6168 < div className = "relative flex-shrink-0 bg-white shadow-sm flex justify-between items-center h-full" >
@@ -100,8 +107,8 @@ export default function NavigationBarTop(props: { absoluteWarning?: string }) {
100107
101108 </ > ) : ( < div className = "flex justify-center items-center overflow-visible" >
102109 < span className = "mr-2" > Available Tasks:</ span >
103- < Dropdown2 options = { availableLinks && availableLinks . length > 0 ? availableLinks : [ 'No links available' ] } disabled = { availableLinks ?. length == 0 }
104- buttonName = { selectedLink ? selectedLink . name : 'Select slice' } selectedOption = { ( option : any ) => dispatch ( setSelectedLink ( option ) ) } />
110+ < Dropdown2 options = { availableLinks && availableLinks . length > 0 ? availableLinks : [ 'No links available' ] } disabled = { availableLinks ?. length == 0 || props . lockedLink }
111+ buttonName = { selectedLink ? selectedLink . name : 'Select slice' } selectedOption = { ( option : any ) => dropdownSelectLink ( option ) } />
105112 </ div > ) }
106113 </ div >
107114 { props . absoluteWarning && < div className = "left-0 right-0 flex items-center justify-center pointer-events-none top-4 z-100" >
0 commit comments