File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed
src/platform/plugins/shared/home/public Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,21 @@ class TutorialDirectoryUi extends React.Component<
154154 _prevProps : TutorialDirectoryUiProps ,
155155 prevState : Readonly < TutorialDirectoryUiState >
156156 ) {
157+ // Update selected tab when URL changes (e.g., browser back/forward)
158+ if ( _prevProps . openTab !== this . props . openTab ) {
159+ const newTab = this . props . openTab ;
160+ // Validate that the tab exists
161+ const tabExists = this . tabs . some ( ( tab ) => tab . id === newTab ) ;
162+ if ( ! tabExists ) {
163+ // If the tab does not exist, redirect to the default tab
164+ getServices ( ) . history . push ( `#/tutorial_directory/${ SAMPLE_DATA_TAB_ID } ` ) ;
165+ } else if ( newTab !== this . state . selectedTabId ) {
166+ this . setState ( {
167+ selectedTabId : newTab ,
168+ } ) ;
169+ }
170+ }
171+
157172 if ( prevState . selectedTabId !== this . state . selectedTabId ) {
158173 this . setBreadcrumbs ( ) ;
159174 }
@@ -186,6 +201,8 @@ class TutorialDirectoryUi extends React.Component<
186201 this . setState ( {
187202 selectedTabId : id ,
188203 } ) ;
204+ // Update URL to reflect the selected tab
205+ getServices ( ) . history . push ( `#/tutorial_directory/${ id } ` ) ;
189206 } ;
190207
191208 getTabs = ( ) => {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import type {
1717 ApplicationStart ,
1818 ThemeServiceStart ,
1919 I18nStart ,
20+ AppMountParameters ,
2021} from '@kbn/core/public' ;
2122import type { UiCounterMetricType } from '@kbn/analytics' ;
2223import type { UrlForwardingStart } from '@kbn/url-forwarding-plugin/public' ;
@@ -57,6 +58,7 @@ export interface HomeKibanaServices {
5758 overlays : OverlayStart ;
5859 theme : ThemeServiceStart ;
5960 i18nStart : I18nStart ;
61+ history : AppMountParameters [ 'history' ] ;
6062}
6163
6264let services : HomeKibanaServices | null = null ;
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ export interface HomePluginStartDependencies {
4444 urlForwarding : UrlForwardingStart ;
4545 cloud : CloudStart ;
4646 share : SharePluginStart ;
47+ history : AppMountParameters [ 'history' ] ;
4748}
4849
4950export interface HomePluginSetupDependencies {
@@ -114,6 +115,7 @@ export class HomePublicPlugin
114115 theme : core . theme ,
115116 i18nStart : coreStart . i18n ,
116117 shareStart,
118+ history : params . history ,
117119 } ) ;
118120 coreStart . chrome . docTitle . change (
119121 i18n . translate ( 'home.pageTitle' , { defaultMessage : 'Home' } )
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export const AddDataButton: React.FC = () => {
3232 data-test-subj = "gettingStartedUploadMenuItem"
3333 onClick = { ( ) => {
3434 closePopover ( ) ;
35- application . navigateToApp ( 'ml ' , { path : 'filedatavisualizer ' } ) ;
35+ application . navigateToApp ( 'home ' , { path : '#/tutorial_directory/fileDataViz ' } ) ;
3636 } }
3737 >
3838 { i18n . translate ( 'xpack.search.gettingStarted.addDataButton.uploadFile' , {
You can’t perform that action at this time.
0 commit comments