fix adding Visualize visualization to dashboard from modal directs user to dashboard listing page (#90090)

This commit is contained in:
Anton Dosov 2021-02-03 17:48:07 +01:00 committed by GitHub
parent c67e291189
commit 84a67a44d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 2 deletions

View file

@ -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;
```

View file

@ -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 |

View file

@ -4,6 +4,7 @@ exports[`after fetch When given a title that matches multiple dashboards, filter
<DashboardListing
kbnUrlStateStorage={
Object {
"cancel": [Function],
"change$": [Function],
"get": [Function],
"kbnUrlControls": Object {
@ -150,6 +151,7 @@ exports[`after fetch hideWriteControls 1`] = `
<DashboardListing
kbnUrlStateStorage={
Object {
"cancel": [Function],
"change$": [Function],
"get": [Function],
"kbnUrlControls": Object {
@ -249,6 +251,7 @@ exports[`after fetch initialFilter 1`] = `
initialFilter="testFilter"
kbnUrlStateStorage={
Object {
"cancel": [Function],
"change$": [Function],
"get": [Function],
"kbnUrlControls": Object {
@ -394,6 +397,7 @@ exports[`after fetch renders all table rows 1`] = `
<DashboardListing
kbnUrlStateStorage={
Object {
"cancel": [Function],
"change$": [Function],
"get": [Function],
"kbnUrlControls": Object {
@ -539,6 +543,7 @@ exports[`after fetch renders call to action when no dashboards exist 1`] = `
<DashboardListing
kbnUrlStateStorage={
Object {
"cancel": [Function],
"change$": [Function],
"get": [Function],
"kbnUrlControls": Object {
@ -684,6 +689,7 @@ exports[`after fetch renders warning when listingLimit is exceeded 1`] = `
<DashboardListing
kbnUrlStateStorage={
Object {
"cancel": [Function],
"change$": [Function],
"get": [Function],
"kbnUrlControls": Object {

View file

@ -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)

View file

@ -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(`"/"`);
@ -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 = {

View file

@ -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);

View file

@ -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
*/
@ -108,6 +113,9 @@ export const createKbnUrlStateStorage = (
}),
share()
),
cancel() {
url.cancel();
},
kbnUrlControls: url,
};
};