Skip to content

Commit

Permalink
get panel actions running
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Jan 5, 2024
1 parent c20e71c commit 1f079fb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ export class FlyoutCreateDrilldownAction implements Action<EmbeddableContext> {
}

public async isCompatible(context: EmbeddableContext) {
const isEditMode = context.embeddable.getInput().viewMode === 'edit';
return isEditMode && this.isEmbeddableCompatible(context);
return false;
// TODO
/*const isEditMode = context.embeddable.getInput().viewMode === 'edit';
return isEditMode && this.isEmbeddableCompatible(context);*/
}

public async execute(context: EmbeddableContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ export class FlyoutEditDrilldownAction implements Action<EmbeddableContext> {
public readonly MenuItem = MenuItem as any;

public async isCompatible({ embeddable }: EmbeddableContext) {
if (embeddable.getInput().viewMode !== ViewMode.EDIT) return false;
return false;
// TODO
/*if (embeddable.getInput().viewMode !== ViewMode.EDIT) return false;
if (!isEnhancedEmbeddable(embeddable)) return false;
return embeddable.enhancements.dynamicActions.state.get().events.length > 0;
return embeddable.enhancements.dynamicActions.state.get().events.length > 0;*/
}

public async execute(context: EmbeddableContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ interface Context {
}

export async function isEditActionCompatible(embeddable: IEmbeddable) {
return false;
// TODO
// display the action only if dashboard is on editable mode
const inDashboardEditMode = embeddable.getInput().viewMode === 'edit';
return Boolean(isLensEmbeddable(embeddable) && embeddable.getIsEditable() && inDashboardEditMode);
/*const inDashboardEditMode = embeddable.getInput().viewMode === 'edit';
return Boolean(isLensEmbeddable(embeddable) && embeddable.getIsEditable() && inDashboardEditMode);*/
}

export async function executeEditAction({
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/maps/public/routes/map_test_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React from 'react';
import { BehaviorSubject } from 'rxjs';
import { Provider } from 'react-redux';
import { EuiEmptyPrompt, EuiTitle } from '@elastic/eui';
import {
Expand Down Expand Up @@ -42,6 +43,8 @@ const mapEmbeddableFactory: EmbeddableComponentFactory<MapInput, MapApi> = {
});
await savedMap.whenReady();

const viewMode$ = new BehaviorSubject<ViewMode>('edit');

/**
* Here we create the actual Component inline. This would be the equavalent of the
*`Embeddable` class in the legacy system.
Expand All @@ -64,6 +67,8 @@ const mapEmbeddableFactory: EmbeddableComponentFactory<MapInput, MapApi> = {
* Here we could open a flyout or modal to edit the embeddable.
*/
},
//type: MAP_SAVED_OBJECT_TYPE,
viewMode: viewMode$,
someSpecialMapFunction: () => {
console.log('look at me, I am a special map function');
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { isLegacyMap } from '../../legacy_visualizations/is_legacy_map';
import type { FilterByMapExtentActionContext } from './types';

export function isCompatible({ embeddable }: FilterByMapExtentActionContext) {
console.log('embeddable.type', embeddable.type);
return (
(embeddable.type === MAP_SAVED_OBJECT_TYPE || isLegacyMap(embeddable)) &&
!embeddable.getInput().disableTriggers
Expand Down

0 comments on commit 1f079fb

Please sign in to comment.