Skip to content

Commit 241686c

Browse files
committed
Relocate tutorials imagery
Signed-off-by: Miki <miki@amazon.com>
1 parent fe1f1d1 commit 241686c

File tree

6 files changed

+62
-12
lines changed

6 files changed

+62
-12
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
2525
- [@osd/pm] Fix `file:`-linked dependencies' resolution to improve ability to test with local packages ([#4342](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4342))
2626
- [Multiple DataSource] Backend support for adding sample data ([#4268](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4268))
2727
- Add configurable defaults and overrides to uiSettings ([#4344](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4344))
28+
- Update header logo selection logic to match the header's ([#4383](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4383))
2829

2930
### 🐛 Bug Fixes
3031

src/core/public/chrome/ui/header/header.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import {
3232
EuiHeader,
33+
EuiHeaderProps,
3334
EuiHeaderSection,
3435
EuiHeaderSectionItem,
3536
EuiHeaderSectionItemButton,
@@ -116,14 +117,16 @@ export function Header({
116117
const className = classnames('hide-for-sharing', 'headerGlobalNav');
117118
const { useExpandedHeader = true, darkMode } = branding;
118119

120+
const headerTheme: EuiHeaderProps['theme'] = 'dark';
121+
119122
return (
120123
<>
121124
<header className={className} data-test-subj="headerGlobalNav">
122125
<div id="globalHeaderBars">
123126
{useExpandedHeader && (
124127
<EuiHeader
125128
className="expandedHeader"
126-
theme="dark"
129+
theme={headerTheme}
127130
position="fixed"
128131
sections={[
129132
{
@@ -134,6 +137,9 @@ export function Header({
134137
navLinks$={observables.navLinks$}
135138
navigateToApp={application.navigateToApp}
136139
branding={branding}
140+
basePath={basePath}
141+
/* This theme should match the theme of EuiHeader */
142+
theme={headerTheme}
137143
/>,
138144
],
139145
borders: 'none',

src/core/public/chrome/ui/header/header_logo.test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import React from 'react';
77
import { BehaviorSubject } from 'rxjs';
88
import { mountWithIntl } from 'test_utils/enzyme_helpers';
99
import { HeaderLogo, DEFAULT_DARK_LOGO, DEFAULT_LOGO } from './header_logo';
10+
import { BasePath } from '../../../http/base_path';
1011

1112
const mockProps = () => ({
1213
href: '/',
14+
basePath: new BasePath('/base'),
1315
navLinks$: new BehaviorSubject([]),
1416
forceNavigation$: new BehaviorSubject(false),
1517
navigateToApp: jest.fn(),

src/core/public/chrome/ui/header/header_logo.tsx

+26-11
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
*/
3030

3131
import './header_logo.scss';
32+
import { EuiHeaderProps } from '@elastic/eui';
3233
import { i18n } from '@osd/i18n';
3334
import React from 'react';
3435
import useObservable from 'react-use/lib/useObservable';
3536
import { Observable } from 'rxjs';
3637
import { ChromeNavLink } from '../..';
3738
import { ChromeBranding } from '../../chrome_service';
39+
import { HttpStart } from '../../../http';
3840

3941
function findClosestAnchor(element: HTMLElement): HTMLAnchorElement | void {
4042
let current = element;
@@ -96,32 +98,45 @@ function onClick(
9698
}
9799
}
98100

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+
101104
interface Props {
102105
href: string;
103106
navLinks$: Observable<ChromeNavLink[]>;
104107
forceNavigation$: Observable<boolean>;
105108
navigateToApp: (appId: string) => void;
106109
branding: ChromeBranding;
110+
basePath: HttpStart['basePath'];
111+
// What background is the logo appearing on; this is unrelated to theme:darkMode
112+
theme?: EuiHeaderProps['theme'];
107113
}
108114

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) {
110123
const forceNavigation = useObservable(observables.forceNavigation$, false);
111124
const navLinks = useObservable(observables.navLinks$, []);
112125
const {
113-
darkMode,
114-
assetFolderUrl = '',
115-
logo = {},
126+
logo: { defaultUrl: customLogoUrl, darkModeUrl: customDarkLogoUrl } = {},
116127
applicationTitle = 'opensearch dashboards',
117128
} = branding;
118-
const { defaultUrl: logoUrl, darkModeUrl: darkLogoUrl } = logo;
119129

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+
}
122139

123-
const logoSrc = customLogo ? customLogo : `${assetFolderUrl}/${defaultLogo}`;
124-
const testSubj = customLogo ? 'customLogo' : 'defaultLogo';
125140
const alt = `${applicationTitle} logo`;
126141

127142
return (
Loading
Loading

0 commit comments

Comments
 (0)