Skip to content

Commit

Permalink
feat: use props to pass homeLink
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Apr 23, 2024
1 parent 05c583c commit f47bd9e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/plugins/home/public/application/components/home_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,27 @@ const renderTutorialDirectory = (props) => {
addBasePath={addBasePath}
openTab={props.match.params.tab}
isCloudEnabled={isCloudEnabled}
homeLink={props.homeLink}
/>
);
};

export function ImportSampleDataApp() {
const { application } = getServices();
return (
<I18nProvider>
<Router>
<Switch>
<Route path="*" exact={true} component={renderTutorialDirectory} />
<Route
path="*"
exact={true}
component={(props) =>
renderTutorialDirectory({
...props,
homeLink: application.getUrlForApp('home'),
})
}
/>
</Switch>
</Router>
</I18nProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class TutorialDirectoryUi extends React.Component {

async componentDidMount() {
this._isMounted = true;
const { chrome, homeLink } = getServices();
const { chrome } = getServices();
const { homeLink } = this.props;

chrome.setBreadcrumbs([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export interface HomeOpenSearchDashboardsServices {
dataSource?: DataSourcePluginStart;
workspaces: WorkspacesStart;
sectionTypes: SectionTypeService;
homeLink?: string;
}

let services: HomeOpenSearchDashboardsServices | null = null;
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/home/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ export class HomePublicPlugin
navLinkStatus: AppNavLinkStatus.hidden,
mount: async (params: AppMountParameters) => {
const [coreStart] = await core.getStartServices();
setCommonService({
homeLink: coreStart.application.getUrlForApp('home'),
});
setCommonService();
coreStart.chrome.docTitle.change(
i18n.translate('home.tutorialDirectory.featureCatalogueTitle', {
defaultMessage: 'Add sample data',
Expand Down

0 comments on commit f47bd9e

Please sign in to comment.