Skip to content

Commit 7bcb934

Browse files
authored
[Search] Getting started upload file link (#241325)
## Summary We will be updating the add data page here: [[Epic] [Getting Started] Add Data and Sample Data page](elastic/search-team#11598 (comment)) Upload file button goes to: `/app/home#/tutorial_directory/fileDataViz` Sample data button goes to: `/app/home#/tutorial_directory/sampleData` As of now, that page does not change the url when clicking between tabs https://github.com/user-attachments/assets/1e04dfc1-0571-404c-a339-8e4e5932c8a8
1 parent 4f008a6 commit 7bcb934

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/platform/plugins/shared/home/public/application/components/tutorial_directory.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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 = () => {

src/platform/plugins/shared/home/public/application/kibana_services.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
ApplicationStart,
1818
ThemeServiceStart,
1919
I18nStart,
20+
AppMountParameters,
2021
} from '@kbn/core/public';
2122
import type { UiCounterMetricType } from '@kbn/analytics';
2223
import 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

6264
let services: HomeKibanaServices | null = null;

src/platform/plugins/shared/home/public/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface HomePluginStartDependencies {
4444
urlForwarding: UrlForwardingStart;
4545
cloud: CloudStart;
4646
share: SharePluginStart;
47+
history: AppMountParameters['history'];
4748
}
4849

4950
export 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' })

x-pack/solutions/search/plugins/search_getting_started/public/components/header/add_data_button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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', {

0 commit comments

Comments
 (0)