Skip to content

Commit

Permalink
fix adding Visualize visualization to dashboard from modal directs us…
Browse files Browse the repository at this point in the history
…er to dashboard listing page (#90090)
  • Loading branch information
Dosant committed Feb 3, 2021
1 parent eb69829 commit 28d46d2
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) &gt; [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) &gt; [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md)

## IKbnUrlStateStorage.cancel property

Cancels any pending url updates

<b>Signature:</b>

```typescript
cancel: () => void;
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface IKbnUrlStateStorage extends IStateStorage
| Property | Type | Description |
| --- | --- | --- |
| [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md) | <code>() =&gt; void</code> | Cancels any pending url updates |
| [change$](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.change_.md) | <code>&lt;State = unknown&gt;(key: string) =&gt; Observable&lt;State &#124; null&gt;</code> | |
| [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.get.md) | <code>&lt;State = unknown&gt;(key: string) =&gt; State &#124; null</code> | |
| [kbnUrlControls](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.kbnurlcontrols.md) | <code>IKbnUrlControls</code> | Lower level wrapper around history library that handles batching multiple URL updates into one history change |
Expand Down

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

1 change: 1 addition & 0 deletions src/plugins/kibana_utils/public/state_sync/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const createSessionStorageStateStorage: (storage?: Storage) => ISessionSt

// @public
export interface IKbnUrlStateStorage extends IStateStorage {
cancel: () => void;
// (undocumented)
change$: <State = unknown>(key: string) => Observable<State | null>;
// (undocumented)
Expand Down
28 changes: 27 additions & 1 deletion src/plugins/kibana_utils/public/state_sync/state_sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('state_sync', () => {
expect(history.length).toBe(startHistoryLength);
expect(getCurrentUrl()).toMatchInlineSnapshot(`"/"`);

urlSyncStrategy.kbnUrlControls.cancel();
urlSyncStrategy.cancel();

expect(history.length).toBe(startHistoryLength);
expect(getCurrentUrl()).toMatchInlineSnapshot(`"/"`);
Expand All @@ -303,6 +303,32 @@ describe('state_sync', () => {
stop();
});

it('cancels pending URL updates when sync stops', async () => {
const { stop, start } = syncStates([
{
stateContainer: withDefaultState(container, defaultState),
storageKey: key,
stateStorage: urlSyncStrategy,
},
]);
start();

const startHistoryLength = history.length;
container.transitions.add({ id: 2, text: '2', completed: false });
container.transitions.add({ id: 3, text: '3', completed: false });
container.transitions.completeAll();

expect(history.length).toBe(startHistoryLength);
expect(getCurrentUrl()).toMatchInlineSnapshot(`"/"`);

stop();

await tick();

expect(history.length).toBe(startHistoryLength);
expect(getCurrentUrl()).toMatchInlineSnapshot(`"/"`);
});

it("should preserve reference to unchanged state slices if them didn't change", async () => {
const otherUnchangedSlice = { a: 'test' };
const oldState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('KbnUrlStateStorage', () => {
const key = '_s';
const pr = urlStateStorage.set(key, state);
expect(getCurrentUrl()).toMatchInlineSnapshot(`"/"`);
urlStateStorage.kbnUrlControls.cancel();
urlStateStorage.cancel();
await pr;
expect(getCurrentUrl()).toMatchInlineSnapshot(`"/"`);
expect(urlStateStorage.get(key)).toEqual(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export interface IKbnUrlStateStorage extends IStateStorage {
get: <State = unknown>(key: string) => State | null;
change$: <State = unknown>(key: string) => Observable<State | null>;

/**
* Cancels any pending url updates
*/
cancel: () => void;

/**
* Lower level wrapper around history library that handles batching multiple URL updates into one history change
*/
Expand Down Expand Up @@ -108,6 +113,9 @@ export const createKbnUrlStateStorage = (
}),
share()
),
cancel() {
url.cancel();
},
kbnUrlControls: url,
};
};

0 comments on commit 28d46d2

Please sign in to comment.