Skip to content

Commit

Permalink
Add openAddDataControlFlyout to API
Browse files Browse the repository at this point in the history
  • Loading branch information
Heenawter committed Aug 8, 2024
1 parent 7984b71 commit c3af340
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { ControlGroupApi, ControlGroupRuntimeState, ControlGroupSerializedState
import { ControlGroup } from './components/control_group';
import { initSelectionsManager } from './selections_manager';
import { initializeControlGroupUnsavedChanges } from './control_group_unsaved_changes_api';
import { openDataControlEditor } from '../controls/data_controls/open_data_control_editor';

export const getControlGroupEmbeddableFactory = (services: {
core: CoreStart;
Expand Down Expand Up @@ -162,25 +163,27 @@ export const getControlGroupEmbeddableFactory = (services: {
i18n.translate('controls.controlGroup.displayName', {
defaultMessage: 'Controls',
}),
openAddDataControlFlyout: () => {
/* openDataControlEditor({
openAddDataControlFlyout: (settings) => {
const { controlInputTransform } = settings ?? {
controlInputTransform: (state) => state,
};
openDataControlEditor({
initialState: {
grow: DEFAULT_CONTROL_GROW,
width: DEFAULT_CONTROL_WIDTH,
dataViewId: parentApi.lastUsedDataViewId.getValue(),
grow: api.grow.getValue(),
width: api.width.getValue(),
},
onSave: ({ type: controlType, state: initialState }) => {
controlsManager.api.addNewPanel({
api.addNewPanel({
panelType: controlType,
initialState,
initialState: controlInputTransform!(
initialState as Partial<ControlGroupSerializedState>,
controlType
),
});
},
controlGroupApi,
services: {
core,
dataViews: dataViewsService,
},
});*/
controlGroupApi: api,
services,
});
},
serializeState: () => {
const { panelsJSON, references } = controlsManager.serializeControls();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Side Public License, v 1.
*/

import { Observable } from 'rxjs';

import { DefaultEmbeddableApi } from '@kbn/embeddable-plugin/public';
import { Filter } from '@kbn/es-query';
import {
Expand All @@ -24,10 +26,11 @@ import {
PublishingSubject,
} from '@kbn/presentation-publishing';
import { PublishesDataViews } from '@kbn/presentation-publishing/interfaces/publishes_data_views';
import { Observable } from 'rxjs';
import { ControlStyle, ControlWidth } from '../../types';

import { ParentIgnoreSettings } from '../..';
import { ControlInputTransform } from '../../../common';
import { ControlGroupChainingSystem } from '../../../common/control_group/types';
import { ControlStyle, ControlWidth } from '../../types';
import { DefaultControlState, PublishesControlDisplaySettings } from '../controls/types';
import { ControlFetchContext } from './control_fetch/control_fetch';

Expand Down Expand Up @@ -66,7 +69,9 @@ export type ControlGroupApi = PresentationContainer &
ignoreParentSettings$: PublishingSubject<ParentIgnoreSettings | undefined>;
allowExpensiveQueries$: PublishingSubject<boolean>;
untilInitialized: () => Promise<void>;
openAddDataControlFlyout: () => void;
openAddDataControlFlyout: (settings?: {
controlInputTransform?: ControlInputTransform;
}) => void;
};

export interface ControlGroupRuntimeState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ControlGroupApi } from '../../control_group/types';
import { DataControlEditor } from './data_control_editor';
import { DefaultDataControlState } from './types';

export type DataControlEditorState = Omit<DefaultDataControlState, 'fieldName'> & {
export type DataControlEditorState = Partial<DefaultDataControlState> & {
fieldName?: string;
controlType?: string;
controlId?: string;
Expand Down

0 comments on commit c3af340

Please sign in to comment.