feat: 🎸 close drilldown manager on view mode switch (#99309) (#99424)

This commit is contained in:
Vadim Dalecky 2021-05-06 02:22:10 +02:00 committed by GitHub
parent b06ae0c3e6
commit 7043ba61ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View file

@ -7,13 +7,14 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
import { skip, take, takeUntil } from 'rxjs/operators';
import { distinctUntilChanged, filter, map, skip, take, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { Action } from '../../../../../../../../src/plugins/ui_actions/public';
import { toMountPoint } from '../../../../../../../../src/plugins/kibana_react/public';
import {
CONTEXT_MENU_TRIGGER,
EmbeddableContext,
ViewMode,
} from '../../../../../../../../src/plugins/embeddable/public';
import {
isEnhancedEmbeddable,
@ -111,5 +112,19 @@ export class FlyoutCreateDrilldownAction implements Action<EmbeddableContext> {
core.application.currentAppId$.pipe(takeUntil(closed$), skip(1), take(1)).subscribe(() => {
close();
});
// Close flyout on dashboard switch to "view" mode.
embeddable
.getInput$()
.pipe(
takeUntil(closed$),
map((input) => input.viewMode),
distinctUntilChanged(),
filter((mode) => mode !== ViewMode.EDIT),
take(1)
)
.subscribe(() => {
close();
});
}
}

View file

@ -6,7 +6,7 @@
*/
import React from 'react';
import { skip, take, takeUntil } from 'rxjs/operators';
import { distinctUntilChanged, filter, map, skip, take, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { Action } from '../../../../../../../../src/plugins/ui_actions/public';
import {
@ -95,5 +95,19 @@ export class FlyoutEditDrilldownAction implements Action<EmbeddableContext> {
core.application.currentAppId$.pipe(takeUntil(closed$), skip(1), take(1)).subscribe(() => {
close();
});
// Close flyout on dashboard switch to "view" mode.
embeddable
.getInput$()
.pipe(
takeUntil(closed$),
map((input) => input.viewMode),
distinctUntilChanged(),
filter((mode) => mode !== ViewMode.EDIT),
take(1)
)
.subscribe(() => {
close();
});
}
}