From 89731ada4541f75371e7a3bb720dddbd24c28c43 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Tue, 16 Jul 2024 13:02:23 -0600 Subject: [PATCH] eslint --- .../control_fetch/chaining.test.ts | 2 +- .../control_group/control_fetch/chaining.ts | 2 +- .../get_control_group_factory.tsx | 7 ++- .../control_group/init_controls_manager.ts | 44 ++++++++++++------- .../control_group/serialization_utils.ts | 2 +- 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.test.ts b/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.test.ts index e5a01ed6ba422..8466bf5cbbb7a 100644 --- a/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.test.ts +++ b/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.test.ts @@ -10,7 +10,7 @@ import { ControlGroupChainingSystem } from '@kbn/controls-plugin/common'; import { Filter } from '@kbn/es-query'; import { BehaviorSubject, skip } from 'rxjs'; import { chaining$ } from './chaining'; -import { ControlPanelState } from "../types"; +import { ControlPanelState } from '../types'; const FILTER_ALPHA = { meta: { diff --git a/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.ts b/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.ts index aadd1542fd390..c058c79f2c0eb 100644 --- a/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.ts +++ b/examples/controls_example/public/react_controls/control_group/control_fetch/chaining.ts @@ -14,7 +14,7 @@ import { PublishingSubject, } from '@kbn/presentation-publishing'; import { BehaviorSubject, combineLatest, debounceTime, map, Observable, switchMap } from 'rxjs'; -import { ControlPanelState } from "../types"; +import { ControlPanelState } from '../types'; export interface ChainingContext { chainingFilters?: Filter[] | undefined; diff --git a/examples/controls_example/public/react_controls/control_group/get_control_group_factory.tsx b/examples/controls_example/public/react_controls/control_group/get_control_group_factory.tsx index 5ed825ab9065e..8814dbd33881b 100644 --- a/examples/controls_example/public/react_controls/control_group/get_control_group_factory.tsx +++ b/examples/controls_example/public/react_controls/control_group/get_control_group_factory.tsx @@ -107,7 +107,12 @@ export const getControlGroupEmbeddableFactory = (services: { ...controlsManager.api, controlFetch$: (controlUuid: string) => controlFetch$( - chaining$(controlUuid, chainingSystem$, controlsManager.controlsInOrder$, controlsManager.getControlApi), + chaining$( + controlUuid, + chainingSystem$, + controlsManager.controlsInOrder$, + controlsManager.getControlApi + ), controlGroupFetch$(ignoreParentSettings$, parentApi ? parentApi : {}) ), ignoreParentSettings$, diff --git a/examples/controls_example/public/react_controls/control_group/init_controls_manager.ts b/examples/controls_example/public/react_controls/control_group/init_controls_manager.ts index 6efe3fe56ac13..2e590001bb1ca 100644 --- a/examples/controls_example/public/react_controls/control_group/init_controls_manager.ts +++ b/examples/controls_example/public/react_controls/control_group/init_controls_manager.ts @@ -7,13 +7,17 @@ */ import { v4 as generateId } from 'uuid'; -import { HasSerializedChildState, PanelPackage, PresentationContainer } from "@kbn/presentation-containers"; +import { + HasSerializedChildState, + PanelPackage, + PresentationContainer, +} from '@kbn/presentation-containers'; import { Reference } from '@kbn/content-management-utils'; -import { BehaviorSubject, merge } from "rxjs"; -import { ControlPanelsState, ControlPanelState } from "./types"; -import { DefaultControlApi } from '../types'; +import { BehaviorSubject, merge } from 'rxjs'; import { PublishingSubject } from '@kbn/presentation-publishing'; import { omit } from 'lodash'; +import { ControlPanelsState, ControlPanelState } from './types'; +import { DefaultControlApi } from '../types'; export function initControlsManager(controlPanelsState: ControlPanelsState) { const children$ = new BehaviorSubject<{ [key: string]: DefaultControlApi }>({}); @@ -21,12 +25,14 @@ export function initControlsManager(controlPanelsState: ControlPanelsState) { Object.keys(controlPanelsState) .map((key) => ({ id: key, - ...controlPanelsState[key] + ...controlPanelsState[key], })) .sort((a, b) => (a.order > b.order ? 1 : -1)) ); - function untilControlLoaded(id: string): DefaultControlApi | Promise { + function untilControlLoaded( + id: string + ): DefaultControlApi | Promise { if (children$.value[id]) { return children$.value[id]; } @@ -40,7 +46,9 @@ export function initControlsManager(controlPanelsState: ControlPanelsState) { } // control removed before the control finished loading. - const controlState = controlsInOrder$.value.find(controlPanelState => controlPanelState.id === id); + const controlState = controlsInOrder$.value.find( + (controlPanelState) => controlPanelState.id === id + ); if (!controlState) { subscription.unsubscribe(); resolve(undefined); @@ -63,18 +71,20 @@ export function initControlsManager(controlPanelsState: ControlPanelsState) { type: panelType, order: controlsInOrder.length, ...(initialState ?? {}), - } + }, ]); return await untilControlLoaded(id); } function removePanel(panelId: string) { - controlsInOrder$.next(controlsInOrder$.value.filter(({ id }) => id !==panelId)); + controlsInOrder$.next(controlsInOrder$.value.filter(({ id }) => id !== panelId)); children$.next(omit(children$.value, panelId)); } return { - controlsInOrder$: controlsInOrder$ as PublishingSubject>, + controlsInOrder$: controlsInOrder$ as PublishingSubject< + Array + >, getControlApi, setControlApi: (uuid: string, controlApi: DefaultControlApi) => { children$.next({ @@ -106,10 +116,10 @@ export function initControlsManager(controlPanelsState: ControlPanelsState) { explicitInputPanels[id] = { grow, order: index, - type: controlApi.type, + type: controlApi.type, width, /** Re-add the `explicitInput` layer on serialize so control group saved object retains shape */ - explicitInput: rest + explicitInput: rest, }; }); @@ -120,14 +130,16 @@ export function initControlsManager(controlPanelsState: ControlPanelsState) { }, api: { getSerializedStateForChild: (childId: string) => { - const controlPanelState = controlsInOrder$.getValue().find(controlPanelState => controlPanelState.id === childId); + const controlPanelState = controlsInOrder$ + .getValue() + .find((element) => element.id === childId); return controlPanelState ? { rawState: controlPanelState } : undefined; }, children$: children$ as PublishingSubject<{ [key: string]: DefaultControlApi; }>, getPanelCount: () => { - return controlsInOrder$.value.length + return controlsInOrder$.value.length; }, addNewPanel, removePanel, @@ -137,5 +149,5 @@ export function initControlsManager(controlPanelsState: ControlPanelsState) { return controlApi ? controlApi.uuid : ''; }, } as PresentationContainer & HasSerializedChildState, - } -} \ No newline at end of file + }; +} diff --git a/examples/controls_example/public/react_controls/control_group/serialization_utils.ts b/examples/controls_example/public/react_controls/control_group/serialization_utils.ts index b52ba59fe62d2..b38b22fc04249 100644 --- a/examples/controls_example/public/react_controls/control_group/serialization_utils.ts +++ b/examples/controls_example/public/react_controls/control_group/serialization_utils.ts @@ -49,4 +49,4 @@ export const deserializeControlGroup = ( defaultControlGrow: DEFAULT_CONTROL_GROW, defaultControlWidth: DEFAULT_CONTROL_WIDTH, }; -}; \ No newline at end of file +};