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

feat: 🎸 don't show drilldown action in "edit" mode #69371

Merged
merged 1 commit into from
Jun 17, 2020
Merged
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
20 changes: 13 additions & 7 deletions x-pack/plugins/embeddable_enhanced/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
defaultEmbeddableFactoryProvider,
EmbeddableContext,
PANEL_NOTIFICATION_TRIGGER,
ViewMode,
} from '../../../../src/plugins/embeddable/public';
import { EnhancedEmbeddable, EnhancedEmbeddableContext } from './types';
import {
Expand Down Expand Up @@ -106,6 +107,15 @@ export class EmbeddableEnhancedPlugin
);
}

private readonly isEmbeddableContext = (context: unknown): context is EmbeddableContext => {
if (!(context as EmbeddableContext)?.embeddable) {
// eslint-disable-next-line no-console
console.warn('For drilldowns to work action context should contain .embeddable field.');
return false;
}
return true;
};

private enhanceEmbeddableWithDynamicActions<E extends IEmbeddable>(
embeddable: E
): EnhancedEmbeddable<E> {
Expand All @@ -114,13 +124,9 @@ export class EmbeddableEnhancedPlugin
const storage = new EmbeddableActionStorage(embeddable as EmbeddableWithDynamicActions);
const dynamicActions = new DynamicActionManager({
isCompatible: async (context: unknown) => {
if (!(context as EmbeddableContext)?.embeddable) {
// eslint-disable-next-line no-console
console.warn('For drilldowns to work action context should contain .embeddable field.');
return false;
}

return (context as EmbeddableContext).embeddable.runtimeId === embeddable.runtimeId;
if (!this.isEmbeddableContext(context)) return false;
if (context.embeddable.getInput().viewMode !== ViewMode.VIEW) return false;
return context.embeddable.runtimeId === embeddable.runtimeId;
},
storage,
uiActions: this.uiActions!,
Expand Down