Skip to content

Commit

Permalink
add history
Browse files Browse the repository at this point in the history
  • Loading branch information
christineweng committed Nov 22, 2024
1 parent eb68fb2 commit 1481cf3
Show file tree
Hide file tree
Showing 43 changed files with 682 additions and 135 deletions.
1 change: 1 addition & 0 deletions packages/kbn-expandable-flyout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export { ExpandableFlyout } from './src';

export { useExpandableFlyoutApi } from './src/hooks/use_expandable_flyout_api';
export { useExpandableFlyoutState } from './src/hooks/use_expandable_flyout_state';
export { useExpandableFlyoutHistory } from './src/hooks/use_expandable_flyout_history';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Container', () => {
},
left: undefined,
preview: undefined,
history: [{ id: 'key' }],
},
},
},
Expand Down Expand Up @@ -85,6 +86,7 @@ describe('Container', () => {
id: 'key',
},
preview: undefined,
history: [],
},
},
},
Expand Down Expand Up @@ -112,6 +114,7 @@ describe('Container', () => {
id: 'key',
},
],
history: [],
},
},
},
Expand All @@ -137,6 +140,7 @@ describe('Container', () => {
},
left: undefined,
preview: undefined,
history: [],
},
},
},
Expand All @@ -163,6 +167,7 @@ describe('Container', () => {
},
left: undefined,
preview: undefined,
history: [],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('PreviewSection', () => {
id: 'key',
},
],
history: [],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

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

/**
* This hook allows you to access the flyout state, read open right, left and preview panels.
*/
export const useExpandableFlyoutHistory = () => {
const { urlKey } = useExpandableFlyoutContext();
// if no urlKey is provided, we are in memory storage mode and use the reserved word 'memory'
const id = urlKey || REDUX_ID_FOR_MEMORY_STORAGE;
return useSelector(selectHistoryById(id));
};
9 changes: 9 additions & 0 deletions packages/kbn-expandable-flyout/src/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const Right: Story<void> = () => {
},
left: undefined,
preview: undefined,
history: [{ id: 'right' }],
},
},
},
Expand Down Expand Up @@ -139,6 +140,7 @@ export const Left: Story<void> = () => {
id: 'left',
},
preview: undefined,
history: [{ id: 'right' }],
},
},
},
Expand Down Expand Up @@ -171,6 +173,7 @@ export const Preview: Story<void> = () => {
id: 'preview1',
},
],
history: [{ id: 'right' }],
},
},
},
Expand Down Expand Up @@ -206,6 +209,7 @@ export const MultiplePreviews: Story<void> = () => {
id: 'preview2',
},
],
history: [{ id: 'right' }],
},
},
},
Expand All @@ -232,6 +236,7 @@ export const CollapsedPushMode: Story<void> = () => {
},
left: undefined,
preview: undefined,
history: [{ id: 'right' }],
},
},
},
Expand Down Expand Up @@ -260,6 +265,7 @@ export const ExpandedPushMode: Story<void> = () => {
id: 'left',
},
preview: undefined,
history: [{ id: 'right' }],
},
},
},
Expand Down Expand Up @@ -288,6 +294,7 @@ export const DisableTypeSelection: Story<void> = () => {
id: 'left',
},
preview: undefined,
history: [{ id: 'right' }],
},
},
},
Expand Down Expand Up @@ -318,6 +325,7 @@ export const ResetWidths: Story<void> = () => {
id: 'left',
},
preview: undefined,
history: [{ id: 'right' }],
},
},
},
Expand All @@ -343,6 +351,7 @@ export const DisableResizeWidthSelection: Story<void> = () => {
id: 'left',
},
preview: undefined,
history: [{ id: 'right' }],
},
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-expandable-flyout/src/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('ExpandableFlyout', () => {
},
left: undefined,
preview: undefined,
history: [{ id: 'key' }],
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-expandable-flyout/src/provider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('UrlSynchronizer', () => {
right: { id: 'key1' },
left: { id: 'key11' },
preview: undefined,
history: [{ id: 'key1' }],
},
},
needsSync: true,
Expand Down Expand Up @@ -93,6 +94,7 @@ describe('UrlSynchronizer', () => {
right: { id: 'key1' },
left: { id: 'key2' },
preview: undefined,
history: [{ id: 'key1' }],
},
},
needsSync: true,
Expand Down
Loading

0 comments on commit 1481cf3

Please sign in to comment.