Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sidecar service #5920

Merged
merged 21 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Workspace] Add a workspace client in workspace plugin ([#6094](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6094))
- [Multiple Datasource] Add component to show single selected data source in read only mode ([#6125](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6125))
- [Workspace] Add workspace id in basePath ([#6060](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6060))
- Add sidecar service ([#5920](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5920))

### 🐛 Bug Fixes

Expand Down
2 changes: 2 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { notificationServiceMock } from '../notifications/notifications_service.
import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock';
import { ChromeService } from './chrome_service';
import { getAppInfo } from '../application/utils';
import { overlayServiceMock } from '../mocks';

class FakeApp implements App {
public title: string;
Expand Down Expand Up @@ -70,6 +71,7 @@ function defaultStartDeps(availableApps?: App[]) {
injectedMetadata: injectedMetadataServiceMock.createStartContract(),
notifications: notificationServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
overlays: overlayServiceMock.createStartContract(),
};

if (availableApps) {
Expand Down
5 changes: 5 additions & 0 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { ChromeHelpExtensionMenuLink } from './ui/header/header_help_menu';
import { Branding } from '../';
import { getLogos } from '../../common';
import type { Logos } from '../../common/types';
import { OverlayStart } from '../overlays';

export { ChromeNavControls, ChromeRecentlyAccessed, ChromeDocTitle };

Expand Down Expand Up @@ -96,6 +97,7 @@ export interface StartDeps {
injectedMetadata: InjectedMetadataStart;
notifications: NotificationsStart;
uiSettings: IUiSettingsClient;
overlays: OverlayStart;
}

type CollapsibleNavHeaderRender = () => JSX.Element | null;
Expand Down Expand Up @@ -166,6 +168,7 @@ export class ChromeService {
injectedMetadata,
notifications,
uiSettings,
overlays,
}: StartDeps): Promise<InternalChromeStart> {
this.initVisibility(application);

Expand All @@ -177,6 +180,7 @@ export class ChromeService {
const customNavLink$ = new BehaviorSubject<ChromeNavLink | undefined>(undefined);
const helpSupportUrl$ = new BehaviorSubject<string>(OPENSEARCH_DASHBOARDS_ASK_OPENSEARCH_LINK);
const isNavDrawerLocked$ = new BehaviorSubject(localStorage.getItem(IS_LOCKED_KEY) === 'true');
const sidecarConfig$ = overlays.sidecar.getSidecarConfig$();

const navControls = this.navControls.start();
const navLinks = this.navLinks.start({ application, http });
Expand Down Expand Up @@ -280,6 +284,7 @@ export class ChromeService {
logos={logos}
survey={injectedMetadata.getSurvey()}
collapsibleNavHeaderRender={this.collapsibleNavHeaderRender}
sidecarConfig$={sidecarConfig$}
/>
),

Expand Down
134 changes: 134 additions & 0 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/core/public/chrome/ui/header/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { httpServiceMock } from '../../../http/http_service.mock';
import { applicationServiceMock, chromeServiceMock } from '../../../mocks';
import { Header } from './header';
import { StubBrowserStorage } from 'test_utils/stub_browser_storage';
import { ISidecarConfig, SIDECAR_DOCKED_MODE } from '../../../overlays';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => () => 'mockId',
Expand Down Expand Up @@ -72,6 +73,10 @@ function mockProps() {
branding: {},
survey: '/',
logos: chromeServiceMock.createStartContract().logos,
sidecarConfig$: new BehaviorSubject<ISidecarConfig>({
dockedMode: SIDECAR_DOCKED_MODE.RIGHT,
paddingSize: 640,
}),
};
}

Expand Down
13 changes: 10 additions & 3 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import classnames from 'classnames';
import React, { createRef, useState } from 'react';
import React, { createRef, useMemo, useState } from 'react';
import useObservable from 'react-use/lib/useObservable';
import { Observable } from 'rxjs';
import { LoadingIndicator } from '../';
Expand All @@ -65,7 +65,7 @@ import { HeaderNavControls } from './header_nav_controls';
import { HeaderActionMenu } from './header_action_menu';
import { HeaderLogo } from './header_logo';
import type { Logos } from '../../../../common/types';

import { ISidecarConfig, getOsdSidecarPaddingStyle } from '../../../overlays';
export interface HeaderProps {
opensearchDashboardsVersion: string;
application: InternalApplicationStart;
Expand Down Expand Up @@ -94,6 +94,7 @@ export interface HeaderProps {
branding: ChromeBranding;
logos: Logos;
survey: string | undefined;
sidecarConfig$: Observable<ISidecarConfig | undefined>;
}

export function Header({
Expand All @@ -112,6 +113,11 @@ export function Header({
const isVisible = useObservable(observables.isVisible$, false);
const isLocked = useObservable(observables.isLocked$, false);
const [isNavOpen, setIsNavOpen] = useState(false);
const sidecarConfig = useObservable(observables.sidecarConfig$, undefined);

const sidecarPaddingStyle = useMemo(() => {
return getOsdSidecarPaddingStyle(sidecarConfig);
}, [sidecarConfig]);

if (!isVisible) {
return <LoadingIndicator loadingCount$={observables.loadingCount$} showAsBar />;
Expand All @@ -132,6 +138,7 @@ export function Header({
<EuiHeader
className="expandedHeader"
theme={expandedHeaderColorScheme}
style={sidecarPaddingStyle}
position="fixed"
sections={[
{
Expand Down Expand Up @@ -170,7 +177,7 @@ export function Header({
/>
)}

<EuiHeader position="fixed" className="primaryHeader">
<EuiHeader position="fixed" className="primaryHeader" style={sidecarPaddingStyle}>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right" className="header__toggleNavButtonSection">
<EuiHeaderSectionItemButton
Expand Down
1 change: 1 addition & 0 deletions src/core/public/core_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export class CoreSystem {
injectedMetadata,
notifications,
uiSettings,
overlays,
});

this.coreApp.start({ application, http, notifications, uiSettings });
Expand Down
8 changes: 7 additions & 1 deletion src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ export {
IHttpResponseInterceptorOverrides,
} from './http';

export { OverlayStart, OverlayBannersStart, OverlayRef } from './overlays';
export {
OverlayStart,
OverlayBannersStart,
OverlayRef,
ISidecarConfig,
SIDECAR_DOCKED_MODE,
} from './overlays';

export {
Toast,
Expand Down
7 changes: 7 additions & 0 deletions src/core/public/overlays/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ export { OverlayBannersStart } from './banners';
export { OverlayFlyoutStart, OverlayFlyoutOpenOptions } from './flyout';
export { OverlayModalStart, OverlayModalOpenOptions } from './modal';
export { OverlayService, OverlayStart } from './overlay_service';
export {
OverlaySidecarStart,
OverlaySidecarOpenOptions,
ISidecarConfig,
getOsdSidecarPaddingStyle,
SIDECAR_DOCKED_MODE,
} from './sidecar';
2 changes: 2 additions & 0 deletions src/core/public/overlays/overlay_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { OverlayService, OverlayStart } from './overlay_service';
import { overlayBannersServiceMock } from './banners/banners_service.mock';
import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock';
import { overlayModalServiceMock } from './modal/modal_service.mock';
import { overlaySidecarServiceMock } from './sidecar/sidecar_service.mock';

const createStartContractMock = () => {
const overlayStart = overlayModalServiceMock.createStartContract();
Expand All @@ -41,6 +42,7 @@ const createStartContractMock = () => {
openModal: overlayStart.open,
openConfirm: overlayStart.openConfirm,
banners: overlayBannersServiceMock.createStartContract(),
sidecar: overlaySidecarServiceMock.createStartContract(),
};
return startContract;
};
Expand Down
Loading
Loading