Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
961871f
added dndKit to package.json
ThomThomson Aug 12, 2021
82dc233
Merge branch 'master' of github.com:elastic/kibana into controls/dndK…
ThomThomson Aug 31, 2021
672b4b2
fix package json
ThomThomson Aug 31, 2021
0cdf909
Control group editing experience V2
ThomThomson Sep 2, 2021
36e21df
Merge branch 'master' of github.com:elastic/kibana into controls/dndK…
ThomThomson Sep 7, 2021
1cfb999
built control group embeddable, stubbed controls service, stubbed add…
ThomThomson Sep 10, 2021
121c104
Control group embeddable creation and deletion working. Inline editin…
ThomThomson Sep 14, 2021
e50493c
Management, validation, restore previous input on cancel
ThomThomson Sep 15, 2021
09236b5
Fix types, fix file capitilization, reenable set all widths function
ThomThomson Sep 20, 2021
983229c
working on clones
andreadelrio Sep 21, 2021
93344cb
Merge branch 'master' of github.com:elastic/kibana into controls/dndK…
ThomThomson Sep 21, 2021
695a657
fix truncation
andreadelrio Sep 21, 2021
aef2049
renamed element
andreadelrio Sep 21, 2021
cdb50c1
Fix i18n, package.json merge conflict, fix embeddable parenting.
ThomThomson Sep 21, 2021
6488ebd
Reorganize controls file structure
ThomThomson Sep 21, 2021
7231eca
small style changes
andreadelrio Sep 21, 2021
0e52eba
Add confirmation modals for canceling creation and edits of controls.…
ThomThomson Sep 22, 2021
8ae7d29
prevent jumping in twoLine dragging
andreadelrio Sep 22, 2021
26076b7
type fix
ThomThomson Sep 27, 2021
6aba47e
Merge branch 'master' of github.com:elastic/kibana into controls/dndK…
ThomThomson Sep 27, 2021
3fce9cf
Merge branch 'controls/dndKitDragDrop' of https://github.com/ThomThom…
ThomThomson Sep 28, 2021
1aaae93
Merge pull request #11 from andreadelrio/dndControls-design-1
ThomThomson Sep 28, 2021
e87794b
fix style lint and types
ThomThomson Sep 28, 2021
17a64e5
Id updates from review feedback
ThomThomson Sep 29, 2021
08f8c71
Merge branch 'master' of github.com:elastic/kibana into controls/dndK…
ThomThomson Sep 29, 2021
75d8fb3
Apply suggestions from code review
ThomThomson Oct 1, 2021
ca581a3
Merge branch 'master' of github.com:elastic/kibana into controls/redu…
ThomThomson Oct 4, 2021
279741c
Merge branch 'master' of github.com:elastic/kibana into controls/dndK…
ThomThomson Oct 4, 2021
930e551
Merge branch 'master' into controls/dndKitDragDrop
kibanamachine Oct 4, 2021
c8a0b53
fix package.json
ThomThomson Oct 4, 2021
8a99e89
Merge branch 'controls/dndKitDragDrop' of https://github.com/ThomThom…
ThomThomson Oct 4, 2021
7dbb64a
Merge branch 'controls/dndKitDragDrop' of https://github.com/ThomThom…
ThomThomson Oct 4, 2021
2bec309
clean up flyouts
andreadelrio Oct 4, 2021
e90f201
Merge pull request #12 from andreadelrio/dndFlyouts
ThomThomson Oct 4, 2021
b7a328f
Type fixes
ThomThomson Oct 4, 2021
5415e48
Use new redux wrapper for control group management
ThomThomson Oct 4, 2021
c9658fc
Merge branch 'controls/dndKitDragDrop' of https://github.com/ThomThom…
ThomThomson Oct 4, 2021
9a7cc9e
upgrade all control group methods to use redux wrapper
ThomThomson Oct 6, 2021
ef1eb14
get order of controls from embeddable input, set up preconfigured story
ThomThomson Oct 7, 2021
e84c887
More comments for redux embeddable context
ThomThomson Oct 7, 2021
33881e7
Merge branch 'master' of github.com:elastic/kibana into controls/redu…
ThomThomson Oct 7, 2021
7663227
remove duplicated files
ThomThomson Oct 12, 2021
bfb30ac
Merge branch 'master' of github.com:elastic/kibana into controls/redu…
ThomThomson Oct 12, 2021
d91eac6
fix types
ThomThomson Oct 12, 2021
b0dc3cf
Merge branch 'master' into controls/reduxToolkit
kibanamachine Oct 13, 2021
c3f80f9
fix missing spread
ThomThomson Oct 13, 2021
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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
"yarn": "^1.21.1"
},
"dependencies": {
"@dnd-kit/core": "^3.1.1",
"@dnd-kit/sortable": "^4.0.0",
"@dnd-kit/utilities": "^2.0.0",
"@babel/runtime": "^7.15.4",
"@dnd-kit/core": "^3.1.1",
"@dnd-kit/sortable": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/

import { InputControlFactory } from '../types';
import { ControlsService } from '../controls_service';
import { InputControlFactory } from '../../../services/controls';
import { flightFields, getEuiSelectableOptions } from './flights';
import { OptionsListEmbeddableFactory } from '../control_types/options_list';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,88 @@ import React, { useEffect, useMemo } from 'react';
import uuid from 'uuid';

import { decorators } from './decorators';
import { providers } from '../../../services/storybook';
import { getControlsServiceStub } from './controls_service_stub';
import { ControlGroupContainerFactory } from '../control_group/control_group_container_factory';
import { pluginServices, registry } from '../../../services/storybook';
import { populateStorybookControlFactories } from './storybook_control_factories';
import { ControlGroupContainerFactory } from '../control_group/embeddable/control_group_container_factory';
import { ControlsPanels } from '../control_group/types';
import {
OptionsListEmbeddableInput,
OPTIONS_LIST_CONTROL,
} from '../control_types/options_list/options_list_embeddable';

export default {
title: 'Controls',
description: '',
decorators,
};

const ControlGroupStoryComponent = () => {
const EmptyControlGroupStoryComponent = ({ panels }: { panels?: ControlsPanels }) => {
const embeddableRoot: React.RefObject<HTMLDivElement> = useMemo(() => React.createRef(), []);

providers.overlays.start({});
const overlays = providers.overlays.getService();

const controlsServiceStub = getControlsServiceStub();
pluginServices.setRegistry(registry.start({}));
populateStorybookControlFactories(pluginServices.getServices().controls);

useEffect(() => {
(async () => {
const factory = new ControlGroupContainerFactory(controlsServiceStub, overlays);
const factory = new ControlGroupContainerFactory();
const controlGroupContainerEmbeddable = await factory.create({
inheritParentState: {
useQuery: false,
useFilters: false,
useTimerange: false,
},
controlStyle: 'oneLine',
panels: panels ?? {},
id: uuid.v4(),
panels: {},
});
if (controlGroupContainerEmbeddable && embeddableRoot.current) {
controlGroupContainerEmbeddable.render(embeddableRoot.current);
}
})();
}, [embeddableRoot, controlsServiceStub, overlays]);
}, [embeddableRoot, panels]);

return <div ref={embeddableRoot} />;
};

export const ControlGroupStory = () => <ControlGroupStoryComponent />;
export const EmptyControlGroupStory = () => <EmptyControlGroupStoryComponent />;
export const ConfiguredControlGroupStory = () => (
<EmptyControlGroupStoryComponent
panels={{
optionsList1: {
type: OPTIONS_LIST_CONTROL,
order: 1,
width: 'auto',
explicitInput: {
title: 'Origin City',
id: 'optionsList1',
indexPattern: 'demo data flights',
field: 'OriginCityName',
defaultSelections: ['Toronto'],
} as OptionsListEmbeddableInput,
},
optionsList2: {
type: OPTIONS_LIST_CONTROL,
order: 2,
width: 'auto',
explicitInput: {
title: 'Destination City',
id: 'optionsList2',
indexPattern: 'demo data flights',
field: 'DestCityName',
defaultSelections: ['London'],
} as OptionsListEmbeddableInput,
},
optionsList3: {
type: OPTIONS_LIST_CONTROL,
order: 3,
width: 'auto',
explicitInput: {
title: 'Carrier',
id: 'optionsList3',
indexPattern: 'demo data flights',
field: 'Carrier',
} as OptionsListEmbeddableInput,
},
}}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { flightFields, getEuiSelectableOptions } from './flights';
import { OptionsListEmbeddableFactory } from '../control_types/options_list';
import { InputControlFactory, PresentationControlsService } from '../../../services/controls';

export const populateStorybookControlFactories = (
controlsServiceStub: PresentationControlsService
) => {
const optionsListFactoryStub = new OptionsListEmbeddableFactory(
({ field, search }) =>
new Promise((r) => setTimeout(() => r(getEuiSelectableOptions(field, search)), 500)),
() => Promise.resolve(['demo data flights']),
() => Promise.resolve(flightFields)
);

// cast to unknown because the stub cannot use the embeddable start contract to transform the EmbeddableFactoryDefinition into an EmbeddableFactory
const optionsListControlFactory = optionsListFactoryStub as unknown as InputControlFactory;
optionsListControlFactory.getDefaultInput = () => ({});
controlsServiceStub.registerInputControlType(optionsListControlFactory);
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,28 @@ import {
EuiFormRow,
EuiToolTip,
} from '@elastic/eui';
import { ControlGroupContainer } from '../control_group/control_group_container';
import { useChildEmbeddable } from '../hooks/use_child_embeddable';
import { ControlStyle } from '../types';
import { ControlFrameStrings } from './control_frame_strings';

import { ControlGroupInput } from '../types';
import { EditControlButton } from '../editor/edit_control';
import { useChildEmbeddable } from '../../hooks/use_child_embeddable';
import { useReduxContainerContext } from '../../../redux_embeddables/redux_embeddable_context';
import { ControlGroupStrings } from '../control_group_strings';

export interface ControlFrameProps {
container: ControlGroupContainer;
customPrepend?: JSX.Element;
controlStyle: ControlStyle;
enableActions?: boolean;
onRemove?: () => void;
embeddableId: string;
onEdit?: () => void;
}

export const ControlFrame = ({
customPrepend,
enableActions,
embeddableId,
controlStyle,
container,
onRemove,
onEdit,
}: ControlFrameProps) => {
export const ControlFrame = ({ customPrepend, enableActions, embeddableId }: ControlFrameProps) => {
const embeddableRoot: React.RefObject<HTMLDivElement> = useMemo(() => React.createRef(), []);
const embeddable = useChildEmbeddable({ container, embeddableId });
const {
useEmbeddableSelector,
containerActions: { untilEmbeddableLoaded, removeEmbeddable },
} = useReduxContainerContext<ControlGroupInput>();
const { controlStyle } = useEmbeddableSelector((state) => state);

const embeddable = useChildEmbeddable({ untilEmbeddableLoaded, embeddableId });

const [title, setTitle] = useState<string>();

Expand All @@ -61,18 +57,13 @@ export const ControlFrame = ({
'controlFrame--floatingActions-oneLine': !usingTwoLineLayout,
})}
>
<EuiToolTip content={ControlFrameStrings.floatingActions.getEditButtonTitle()}>
<EuiButtonIcon
aria-label={ControlFrameStrings.floatingActions.getEditButtonTitle()}
iconType="pencil"
onClick={onEdit}
color="text"
/>
<EuiToolTip content={ControlGroupStrings.floatingActions.getEditButtonTitle()}>
<EditControlButton embeddableId={embeddableId} />
</EuiToolTip>
<EuiToolTip content={ControlFrameStrings.floatingActions.getRemoveButtonTitle()}>
<EuiToolTip content={ControlGroupStrings.floatingActions.getRemoveButtonTitle()}>
<EuiButtonIcon
aria-label={ControlFrameStrings.floatingActions.getRemoveButtonTitle()}
onClick={onRemove}
aria-label={ControlGroupStrings.floatingActions.getRemoveButtonTitle()}
onClick={() => removeEmbeddable(embeddableId)}
iconType="cross"
color="danger"
/>
Expand Down
Loading