File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ export interface TabState {
5353export function addPage (
5454 pageState : PageState ,
5555 location : string ,
56- desc : FileDescription
56+ desc : FileDescription ,
57+ pathname ?: string
5758) : PageState {
5859 const pagesCopy = { ...pageState } ;
5960 pagesCopy [ location ] = desc ;
@@ -171,7 +172,11 @@ export function selectTab(
171172export type FileContextType = {
172173 pageState : PageState ;
173174 tabState : TabState ;
174- addPage : ( location : string , fileDesc : FileDescription ) => void ;
175+ addPage : (
176+ location : string ,
177+ fileDesc : FileDescription ,
178+ pathname ?: string
179+ ) => void ;
175180 removePage : ( location : string , fileDesc ?: FileDescription ) => void ;
176181 addTab : (
177182 location : string ,
@@ -238,9 +243,13 @@ export const FileProvider: React.FC<FileProviderProps> = (
238243 const fileContext = {
239244 pageState,
240245 tabState,
241- addPage : ( location : string , fileDesc : FileDescription ) : void => {
246+ addPage : (
247+ location : string ,
248+ fileDesc : FileDescription ,
249+ pathname ?: string
250+ ) : void => {
242251 const newPageState = addPage ( pageState , location , fileDesc ) ;
243- history . push ( history . location . pathname , {
252+ history . push ( pathname ? pathname : history . location . pathname , {
244253 pageState : newPageState ,
245254 tabState : history . location . state ?. tabState ?? tabState
246255 } ) ;
Original file line number Diff line number Diff line change 11export { onRenderCallback } from "./profilerCallback" ;
2- export { FileProvider } from "./fileContext" ;
2+ export { FileProvider , FileContext } from "./fileContext" ;
33export { OutlineContext , OutlineProvider } from "./outlineContext" ;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export { TabContainer } from "./Tabs/tabContainer";
3636export { DynamicTabs } from "./Tabs/dynamicTabs" ;
3737export { XYPlot } from "./XYPlot/xyPlot" ;
3838export { Webcam } from "./Webcam/webcam" ;
39+ export { executeAction } from "./widgetActions" ;
3940
4041// By importing and calling this function you ensure all the
4142// above widgets are imported and thus registered.
Original file line number Diff line number Diff line change @@ -120,14 +120,15 @@ export const getActionDescription = (action: WidgetAction): string => {
120120export const openPage = (
121121 action : DynamicAction ,
122122 fileContext ?: FileContextType ,
123- parentMacros ?: MacroMap
123+ parentMacros ?: MacroMap ,
124+ pathname ?: string
124125) : void => {
125126 const { location, file } = action . dynamicInfo ;
126127 file . macros = {
127128 ...( parentMacros ?? { } ) ,
128129 ...file . macros
129130 } ;
130- fileContext ?. addPage ( location , file ) ;
131+ fileContext ?. addPage ( location , file , pathname ) ;
131132} ;
132133
133134export const closePage = (
@@ -163,12 +164,13 @@ export const executeAction = (
163164 action : WidgetAction ,
164165 files ?: FileContextType ,
165166 exitContext ?: ExitContextType ,
166- parentMacros ?: MacroMap
167+ parentMacros ?: MacroMap ,
168+ pathname ?: string
167169) : void => {
168170 switch ( action . type ) {
169171 case OPEN_PAGE :
170172 if ( files ) {
171- openPage ( action , files , parentMacros ) ;
173+ openPage ( action , files , parentMacros , pathname ) ;
172174 } else {
173175 log . error ( "Tried to open a page but no file context passed" ) ;
174176 }
You can’t perform that action at this time.
0 commit comments