Skip to content

Commit

Permalink
update docked mode enum
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <tygao@amazon.com>
  • Loading branch information
raintygao committed Jan 23, 2024
1 parent 6ff2aea commit f279085
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/core/public/chrome/ui/header/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +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 } from 'src/core/public/overlays';
import { ISidecarConfig, SIDECAR_DOCKED_MODE } from 'src/core/public/overlays';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => () => 'mockId',
Expand Down Expand Up @@ -74,7 +74,7 @@ function mockProps() {
survey: '/',
logos: chromeServiceMock.createStartContract().logos,
sidecarConfig$: new BehaviorSubject<ISidecarConfig>({
dockedMode: 'right',
dockedMode: SIDECAR_DOCKED_MODE.RIGHT,
paddingSize: 640,
}),
};
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, ISidecarConfig } from './overlays';
export {
OverlayStart,
OverlayBannersStart,
OverlayRef,
ISidecarConfig,
SIDECAR_DOCKED_MODE,
} from './overlays';

export {
Toast,
Expand Down
1 change: 1 addition & 0 deletions src/core/public/overlays/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export {
OverlaySidecarOpenOptions,
ISidecarConfig,
getOsdSidecarPaddingStyle,
SIDECAR_DOCKED_MODE,
} from './sidecar';
1 change: 1 addition & 0 deletions src/core/public/overlays/sidecar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export {
OverlaySidecarStart,
OverlaySidecarOpenOptions,
ISidecarConfig,
SIDECAR_DOCKED_MODE,
} from './sidecar_service';
export { getOsdSidecarPaddingStyle } from './helper';
4 changes: 2 additions & 2 deletions src/core/public/overlays/sidecar/resizable_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, { useCallback, useRef } from 'react';
import classNames from 'classnames';
import './rsizable_button.scss';
import { getPosition } from './helper';
import { ISidecarConfig } from './sidecar_service';
import { ISidecarConfig, SIDECAR_DOCKED_MODE } from './sidecar_service';

interface Props {
isHorizontal: boolean;
Expand All @@ -25,7 +25,7 @@ export const ResizableButton = ({
flyoutSize,
minSize = MIN_SIDECAR_SIZE,
}: Props) => {
const isHorizontal = dockedMode !== 'takeover';
const isHorizontal = dockedMode !== SIDECAR_DOCKED_MODE.TAKEOVER;

const classes = classNames('resizableButton', {
'resizableButton--vertical': !isHorizontal,
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/overlays/sidecar/sidecar_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import type { PublicMethodsOf } from '@osd/utility-types';
import { SidecarService, OverlaySidecarStart } from './sidecar_service';
import { BehaviorSubject } from 'rxjs';
import { ISidecarConfig } from './sidecar_service';
import { ISidecarConfig, SIDECAR_DOCKED_MODE } from './sidecar_service';

const createStartContractMock = () => {
const startContract: jest.Mocked<OverlaySidecarStart> = {
open: jest.fn(),
setSidecarConfig: jest.fn(),
getSidecarConfig$: jest.fn().mockReturnValue(
new BehaviorSubject<ISidecarConfig>({
dockedMode: 'right',
dockedMode: SIDECAR_DOCKED_MODE.RIGHT,
paddingSize: 640,
})
),
Expand Down
7 changes: 6 additions & 1 deletion src/core/public/overlays/sidecar/sidecar_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,14 @@ interface StartDeps {
targetDomElement: Element;
}

export enum SIDECAR_DOCKED_MODE {
LEFT = 'left',
RIGHT = 'right',
TAKEOVER = 'takeover',
}
export interface ISidecarConfig {
// takeover mode will docked to bottom
dockedMode: 'left' | 'right' | 'takeover';
dockedMode: SIDECAR_DOCKED_MODE;
paddingSize: number;
minSize?: number;
isHidden?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/rendering/app_containers.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import { mount } from 'enzyme';
import React from 'react';

import { AppWrapper, AppContainer } from './app_containers';
import { ISidecarConfig } from '../overlays';
import { ISidecarConfig, SIDECAR_DOCKED_MODE } from '../overlays';

describe('AppWrapper', () => {
it('toggles the `hidden-chrome` class depending on the chrome visibility state', () => {
const chromeVisible$ = new BehaviorSubject<boolean>(true);
const sidecarConfig$ = new BehaviorSubject<ISidecarConfig>({
dockedMode: 'right',
dockedMode: SIDECAR_DOCKED_MODE.RIGHT,
paddingSize: 640,
});

Expand Down

0 comments on commit f279085

Please sign in to comment.