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

[8.x] [kbn-expandable-flyout] - refactor internal redux store (#192644) #193096

Merged
merged 1 commit into from
Sep 16, 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
2 changes: 1 addition & 1 deletion packages/kbn-expandable-flyout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export { ExpandableFlyout } from './src';
export { useExpandableFlyoutApi } from './src/hooks/use_expandable_flyout_api';
export { useExpandableFlyoutState } from './src/hooks/use_expandable_flyout_state';

export { type FlyoutState as ExpandableFlyoutState } from './src/state';
export { type FlyoutPanels as ExpandableFlyoutState } from './src/store/state';

export { ExpandableFlyoutProvider } from './src/provider';
export { withExpandableFlyoutProvider } from './src/with_provider';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@ import {
PREVIEW_SECTION_TEST_ID,
} from './test_ids';
import { TestProvider } from '../test/provider';
import { State } from '../state';
import { State } from '../store/state';

describe('PreviewSection', () => {
const context = {
right: {},
left: {},
preview: [
{
id: 'key',
const context: State = {
panels: {
byId: {
flyout: {
right: undefined,
left: undefined,
preview: [
{
id: 'key',
},
],
},
},
],
} as unknown as State;
},
};

const component = <div>{'component'}</div>;
const left = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
openPreviewPanelAction,
openRightPanelAction,
previousPreviewPanelAction,
} from '../actions';
import { useDispatch } from '../redux';
} from '../store/actions';
import { useDispatch } from '../store/redux';
import { FlyoutPanelProps, type ExpandableFlyoutApi } from '../types';

export type { ExpandableFlyoutApi };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { REDUX_ID_FOR_MEMORY_STORAGE } from '../constants';
import { useExpandableFlyoutContext } from '../context';
import { selectPanelsById, useSelector } from '../redux';
import { selectPanelsById, useSelector } from '../store/redux';

/**
* This hook allows you to access the flyout state, read open right, left and preview panels.
Expand Down
140 changes: 77 additions & 63 deletions packages/kbn-expandable-flyout/src/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@elastic/eui';
import { ExpandableFlyout } from '.';
import { TestProvider } from './test/provider';
import { State } from './state';
import { State } from './store/state';

export default {
component: ExpandableFlyout,
Expand Down Expand Up @@ -103,13 +103,15 @@ const registeredPanels = [

export const Right: Story<void> = () => {
const state: State = {
byId: {
memory: {
right: {
id: 'right',
panels: {
byId: {
memory: {
right: {
id: 'right',
},
left: undefined,
preview: undefined,
},
left: undefined,
preview: undefined,
},
},
};
Expand All @@ -126,15 +128,17 @@ export const Right: Story<void> = () => {

export const Left: Story<void> = () => {
const state: State = {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
panels: {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
},
preview: undefined,
},
preview: undefined,
},
},
};
Expand All @@ -151,19 +155,21 @@ export const Left: Story<void> = () => {

export const Preview: Story<void> = () => {
const state: State = {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
},
preview: [
{
id: 'preview1',
panels: {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
},
],
preview: [
{
id: 'preview1',
},
],
},
},
},
};
Expand All @@ -180,22 +186,24 @@ export const Preview: Story<void> = () => {

export const MultiplePreviews: Story<void> = () => {
const state: State = {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
},
preview: [
{
id: 'preview1',
panels: {
byId: {
memory: {
right: {
id: 'right',
},
{
id: 'preview2',
left: {
id: 'left',
},
],
preview: [
{
id: 'preview1',
},
{
id: 'preview2',
},
],
},
},
},
};
Expand All @@ -212,13 +220,15 @@ export const MultiplePreviews: Story<void> = () => {

export const CollapsedPushVsOverlay: Story<void> = () => {
const state: State = {
byId: {
memory: {
right: {
id: 'right',
panels: {
byId: {
memory: {
right: {
id: 'right',
},
left: undefined,
preview: undefined,
},
left: undefined,
preview: undefined,
},
},
};
Expand All @@ -232,15 +242,17 @@ export const CollapsedPushVsOverlay: Story<void> = () => {

export const ExpandedPushVsOverlay: Story<void> = () => {
const state: State = {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
panels: {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
},
preview: undefined,
},
preview: undefined,
},
},
};
Expand All @@ -254,15 +266,17 @@ export const ExpandedPushVsOverlay: Story<void> = () => {

export const DisableTypeSelection: Story<void> = () => {
const state: State = {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
panels: {
byId: {
memory: {
right: {
id: 'right',
},
left: {
id: 'left',
},
preview: undefined,
},
preview: undefined,
},
},
};
Expand Down
Loading