|
29 | 29 | */
|
30 | 30 |
|
31 | 31 | import './header_logo.scss';
|
| 32 | +import { EuiHeaderProps } from '@elastic/eui'; |
32 | 33 | import { i18n } from '@osd/i18n';
|
33 | 34 | import React from 'react';
|
34 | 35 | import useObservable from 'react-use/lib/useObservable';
|
35 | 36 | import { Observable } from 'rxjs';
|
36 | 37 | import { ChromeNavLink } from '../..';
|
37 | 38 | import { ChromeBranding } from '../../chrome_service';
|
| 39 | +import { HttpStart } from '../../../http'; |
38 | 40 |
|
39 | 41 | function findClosestAnchor(element: HTMLElement): HTMLAnchorElement | void {
|
40 | 42 | let current = element;
|
@@ -96,32 +98,45 @@ function onClick(
|
96 | 98 | }
|
97 | 99 | }
|
98 | 100 |
|
99 |
| -export const DEFAULT_DARK_LOGO = 'opensearch_logo_dark_mode.svg'; |
100 |
| -export const DEFAULT_LOGO = 'opensearch_logo_default_mode.svg'; |
| 101 | +export const DEFAULT_LOGO = 'plugins/home/assets/logos/opensearch_dashboards.svg'; |
| 102 | +export const DEFAULT_DARK_LOGO = 'plugins/home/assets/logos/opensearch_dashboards_darkmode.svg'; |
| 103 | + |
101 | 104 | interface Props {
|
102 | 105 | href: string;
|
103 | 106 | navLinks$: Observable<ChromeNavLink[]>;
|
104 | 107 | forceNavigation$: Observable<boolean>;
|
105 | 108 | navigateToApp: (appId: string) => void;
|
106 | 109 | branding: ChromeBranding;
|
| 110 | + basePath: HttpStart['basePath']; |
| 111 | + // What background is the logo appearing on; this is unrelated to theme:darkMode |
| 112 | + theme?: EuiHeaderProps['theme']; |
107 | 113 | }
|
108 | 114 |
|
109 |
| -export function HeaderLogo({ href, navigateToApp, branding, ...observables }: Props) { |
| 115 | +export function HeaderLogo({ |
| 116 | + href, |
| 117 | + navigateToApp, |
| 118 | + branding, |
| 119 | + basePath, |
| 120 | + theme = 'default', |
| 121 | + ...observables |
| 122 | +}: Props) { |
110 | 123 | const forceNavigation = useObservable(observables.forceNavigation$, false);
|
111 | 124 | const navLinks = useObservable(observables.navLinks$, []);
|
112 | 125 | const {
|
113 |
| - darkMode, |
114 |
| - assetFolderUrl = '', |
115 |
| - logo = {}, |
| 126 | + logo: { defaultUrl: customLogoUrl, darkModeUrl: customDarkLogoUrl } = {}, |
116 | 127 | applicationTitle = 'opensearch dashboards',
|
117 | 128 | } = branding;
|
118 |
| - const { defaultUrl: logoUrl, darkModeUrl: darkLogoUrl } = logo; |
119 | 129 |
|
120 |
| - const customLogo = darkMode ? darkLogoUrl ?? logoUrl : logoUrl; |
121 |
| - const defaultLogo = darkMode ? DEFAULT_DARK_LOGO : DEFAULT_LOGO; |
| 130 | + // Attempt to find a suitable custom branded logo before falling back on OSD's |
| 131 | + let logoSrc = theme === 'dark' && customDarkLogoUrl ? customDarkLogoUrl : customLogoUrl; |
| 132 | + let testSubj = 'customLogo'; |
| 133 | + |
| 134 | + // If no custom branded logo was set, use OSD's |
| 135 | + if (!logoSrc) { |
| 136 | + logoSrc = `${basePath.serverBasePath}/${theme === 'dark' ? DEFAULT_DARK_LOGO : DEFAULT_LOGO}`; |
| 137 | + testSubj = 'defaultLogo'; |
| 138 | + } |
122 | 139 |
|
123 |
| - const logoSrc = customLogo ? customLogo : `${assetFolderUrl}/${defaultLogo}`; |
124 |
| - const testSubj = customLogo ? 'customLogo' : 'defaultLogo'; |
125 | 140 | const alt = `${applicationTitle} logo`;
|
126 | 141 |
|
127 | 142 | return (
|
|
0 commit comments