forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support right navigation register
Signed-off-by: tygao <tygao@amazon.com>
- Loading branch information
Showing
4 changed files
with
97 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/core/public/chrome/ui/header/right_navigation_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiButtonIcon } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { CoreStart } from 'src/core/public'; | ||
|
||
export interface RightNavigationButtonProps { | ||
application: CoreStart['application']; | ||
http: CoreStart['http']; | ||
appId: string; | ||
iconType: string; | ||
title: string; | ||
} | ||
|
||
export const RightNavigationButton = ({ | ||
application, | ||
http, | ||
appId, | ||
iconType, | ||
title, | ||
}: RightNavigationButtonProps) => { | ||
const navigateToApp = () => { | ||
const appUrl = application.getUrlForApp(appId, { | ||
path: '/', | ||
absolute: false, | ||
}); | ||
// Remove prefix in Url including workspace and other prefix | ||
const targetUrl = http.basePath.prepend(http.basePath.remove(appUrl), { | ||
withoutClientBasePath: true, | ||
}); | ||
application.navigateToUrl(targetUrl); | ||
}; | ||
|
||
return ( | ||
<EuiButtonIcon | ||
iconType={iconType} | ||
aria-label={title} | ||
title={title} | ||
onClick={navigateToApp} | ||
style={{ | ||
height: '48px', | ||
minWidth: '48px', | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters