@@ -2,10 +2,10 @@ import Typography from "@mui/material/Typography";
22import NavigateNextIcon from "@mui/icons-material/NavigateNext" ;
33import { ReactNode , useContext } from "react" ;
44import { Breadcrumbs , Link } from "@mui/material" ;
5- import { executeAction , FileContext } from "@diamondlightsource/cs-web-lib" ;
5+ import { FileContext } from "@diamondlightsource/cs-web-lib" ;
66import { BeamlineStateProperties } from "../store" ;
77import { BeamlineTreeStateContext } from "../App" ;
8- import { buildUrl } from "../utils/urlUtils " ;
8+ import { executeOpenPageActionWithUrlId } from "../utils/csWebLibActions " ;
99
1010export const SynopticBreadcrumbs = ( ) => {
1111 const { state } = useContext ( BeamlineTreeStateContext ) ;
@@ -18,7 +18,11 @@ export const SynopticBreadcrumbs = () => {
1818
1919 return (
2020 < Breadcrumbs
21- onClick = { handleClick ( state . beamlines [ state . currentBeamline ] , fileContext ) }
21+ onClick = { handleClick (
22+ state . currentBeamline ,
23+ state . beamlines [ state . currentBeamline ] ,
24+ fileContext
25+ ) }
2226 separator = { < NavigateNextIcon fontSize = "small" /> }
2327 aria-label = "breadcrumb"
2428 sx = { {
@@ -37,37 +41,23 @@ export const SynopticBreadcrumbs = () => {
3741} ;
3842
3943const handleClick =
40- ( currentBeamlineState : BeamlineStateProperties , fileContext : any ) =>
44+ (
45+ selectedBeamlineId : string ,
46+ beamlineState : BeamlineStateProperties ,
47+ fileContext : any
48+ ) =>
4149 ( event : any ) => {
4250 if ( event . target . pathname ) {
4351 event . preventDefault ( ) ;
4452 const urlId = decodeURI ( event . target . pathname )
4553 . split ( "/" )
4654 . at ( - 1 ) as string ;
4755
48- const fileMetadata = Object . values ( currentBeamlineState . filePathIds ) . find (
49- x => x . urlId === urlId
50- ) ;
51- const newScreen = buildUrl ( currentBeamlineState . host , fileMetadata ?. file ) ;
52-
53- executeAction (
54- {
55- type : "OPEN_PAGE" ,
56- dynamicInfo : {
57- name : newScreen ,
58- location : "main" ,
59- description : undefined ,
60- file : {
61- path : newScreen ,
62- macros : { } ,
63- defaultProtocol : "ca"
64- }
65- }
66- } ,
67- fileContext ,
68- undefined ,
69- { } ,
70- event . target . pathname
56+ executeOpenPageActionWithUrlId (
57+ beamlineState ,
58+ urlId ,
59+ selectedBeamlineId ,
60+ fileContext
7161 ) ;
7262 }
7363 } ;
0 commit comments