Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f8b41df
initial implementation of new embeddable panel component
ThomThomson Apr 20, 2023
29e3b7b
Merge remote-tracking branch 'upstream/main' into embeddable/refactor…
ThomThomson Apr 20, 2023
e1bb98a
initial usage in grid item
ThomThomson Jun 5, 2023
42412a7
Merge remote-tracking branch 'upstream/main' into embeddable/refactor…
ThomThomson Jun 5, 2023
fd53ee6
update all usages to the new Embeddable Panel
ThomThomson Jun 15, 2023
8a5a0e6
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 15, 2023
f9f6e1d
remove unused translations. Update jest tests
ThomThomson Jun 23, 2023
06d8819
Merge remote-tracking branch 'refs/remotes/origin/embeddable/refactor…
ThomThomson Jun 23, 2023
7b4c123
restore open add panel flyout
ThomThomson Jul 5, 2023
f25ecc8
Merge remote-tracking branch 'upstream/main' into embeddable/refactor…
ThomThomson Jul 5, 2023
30055f9
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 5, 2023
d39affe
fix types
ThomThomson Jul 5, 2023
ee7e19e
fix error recoverability, refresh actions when opening action menu
ThomThomson Jul 5, 2023
e64c892
Make add panel flyout use saved object type. Update embeddable panel …
ThomThomson Jul 6, 2023
5dec26b
fix add panel flyout test
ThomThomson Jul 6, 2023
f3a95a4
Merge remote-tracking branch 'upstream/main' into embeddable/refactor…
ThomThomson Jul 6, 2023
50986fd
Merge remote-tracking branch 'upstream/main' into embeddable/refactor…
ThomThomson Jul 7, 2023
1958bd7
re order disabled action filtering to allow universal actions to be d…
ThomThomson Jul 7, 2023
8c3d029
Merge branch 'main' into embeddable/refactorEmbeddablePanel
kibanamachine Jul 7, 2023
8fe88de
Review feedback, remove asyncEmbeddablePanel
ThomThomson Jul 10, 2023
9ae494a
restore onPanelStatusChange
ThomThomson Jul 10, 2023
379a010
Merge remote-tracking branch 'refs/remotes/origin/embeddable/refactor…
ThomThomson Jul 10, 2023
9fca516
Fix type
ThomThomson Jul 10, 2023
f193db7
Fix test types
ThomThomson Jul 10, 2023
da66eac
Merge branch 'main' into embeddable/refactorEmbeddablePanel
kibanamachine Jul 10, 2023
c95b94f
Review feedback, remove unused props
ThomThomson Jul 10, 2023
1bf063f
Merge remote-tracking branch 'refs/remotes/origin/embeddable/refactor…
ThomThomson Jul 10, 2023
c3e247c
Review feedback
ThomThomson Jul 11, 2023
655609a
Merge remote-tracking branch 'upstream/main' into embeddable/refactor…
ThomThomson Jul 11, 2023
af6a9ce
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 11, 2023
f89ab81
panel settings menu loading state.
ThomThomson Jul 13, 2023
7baab41
Merge remote-tracking branch 'refs/remotes/origin/embeddable/refactor…
ThomThomson Jul 13, 2023
8f238d9
Review feedback
ThomThomson Jul 13, 2023
c3caa8c
mounted -> canceled
ThomThomson Jul 14, 2023
260b67c
Merge branch 'main' into embeddable/refactorEmbeddablePanel
kibanamachine Jul 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ListContainer extends Container<{}, ContainerInput> {
public readonly type = LIST_CONTAINER;
private node?: HTMLElement;

constructor(input: ContainerInput, private embeddableServices: EmbeddableStart) {
constructor(input: ContainerInput, embeddableServices: EmbeddableStart) {
super(input, { embeddableLoaded: {} }, embeddableServices.getEmbeddableFactory);
}

Expand All @@ -32,10 +32,7 @@ export class ListContainer extends Container<{}, ContainerInput> {
ReactDOM.unmountComponentAtNode(this.node);
}
this.node = node;
ReactDOM.render(
<ListContainerComponent embeddable={this} embeddableServices={this.embeddableServices} />,
node
);
ReactDOM.render(<ListContainerComponent embeddable={this} />, node);
}

public destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@ import {
withEmbeddableSubscription,
ContainerInput,
ContainerOutput,
EmbeddableStart,
EmbeddableChildPanel,
EmbeddablePanel,
} from '@kbn/embeddable-plugin/public';

interface Props {
embeddable: IContainer;
input: ContainerInput;
output: ContainerOutput;
embeddableServices: EmbeddableStart;
}

function renderList(
embeddable: IContainer,
panels: ContainerInput['panels'],
embeddableServices: EmbeddableStart
) {
function renderList(embeddable: IContainer, panels: ContainerInput['panels']) {
let number = 0;
const list = Object.values(panels).map((panel) => {
number++;
Expand All @@ -42,10 +36,8 @@ function renderList(
</EuiText>
</EuiFlexItem>
<EuiFlexItem>
<EmbeddableChildPanel
PanelComponent={embeddableServices.EmbeddablePanel}
embeddableId={panel.explicitInput.id}
container={embeddable}
<EmbeddablePanel
embeddable={() => embeddable.untilEmbeddableLoaded(panel.explicitInput.id)}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand All @@ -55,12 +47,12 @@ function renderList(
return list;
}

export function ListContainerComponentInner({ embeddable, input, embeddableServices }: Props) {
export function ListContainerComponentInner({ embeddable, input }: Props) {
return (
<div>
<h2 data-test-subj="listContainerTitle">{embeddable.getTitle()}</h2>
<EuiSpacer size="l" />
{renderList(embeddable, input.panels, embeddableServices)}
{renderList(embeddable, input.panels)}
</div>
);
}
Expand All @@ -73,6 +65,5 @@ export function ListContainerComponentInner({ embeddable, input, embeddableServi
export const ListContainerComponent = withEmbeddableSubscription<
ContainerInput,
ContainerOutput,
IContainer,
{ embeddableServices: EmbeddableStart }
IContainer
>(ListContainerComponentInner);
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
ContainerOutput,
EmbeddableOutput,
EmbeddableStart,
EmbeddablePanel,
openAddPanelFlyout,
} from '@kbn/embeddable-plugin/public';
import { SearchableListContainer, SearchableContainerInput } from './searchable_list_container';

Expand Down Expand Up @@ -120,7 +122,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
};

public renderControls() {
const { input } = this.props;
const { input, embeddable } = this.props;
return (
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={false}>
Expand Down Expand Up @@ -150,6 +152,17 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFormRow hasEmptyLabelSpace>
<EuiButton
data-test-subj="addPanelToListContainer"
disabled={input.search === ''}
onClick={() => openAddPanelFlyout({ container: embeddable })}
>
Add panel
</EuiButton>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem />
</EuiFlexGroup>
);
Expand All @@ -171,7 +184,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
}

private renderList() {
const { embeddableServices, input, embeddable } = this.props;
const { input, embeddable } = this.props;
let id = 0;
const list = Object.values(input.panels).map((panel) => {
const childEmbeddable = embeddable.getChild(panel.explicitInput.id);
Expand All @@ -189,7 +202,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
/>
</EuiFlexItem>
<EuiFlexItem>
<embeddableServices.EmbeddablePanel embeddable={childEmbeddable} />
<EmbeddablePanel embeddable={childEmbeddable} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
Expand Down
1 change: 0 additions & 1 deletion examples/embeddable_explorer/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ const EmbeddableExplorerApp = ({
id: 'embeddablePanelExample',
component: (
<EmbeddablePanelExample
embeddableServices={embeddableApi}
searchListContainerFactory={embeddableExamples.factories.getSearchableListContainerEmbeddableFactory()}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React, { useState, useEffect, useRef } from 'react';
import { EuiPanel, EuiText, EuiPageTemplate } from '@elastic/eui';
import { EuiSpacer } from '@elastic/eui';
import { EmbeddableStart, IEmbeddable } from '@kbn/embeddable-plugin/public';
import { IEmbeddable, EmbeddablePanel } from '@kbn/embeddable-plugin/public';
import {
HELLO_WORLD_EMBEDDABLE,
TODO_EMBEDDABLE,
Expand All @@ -19,11 +19,10 @@ import {
} from '@kbn/embeddable-examples-plugin/public';

interface Props {
embeddableServices: EmbeddableStart;
searchListContainerFactory: SearchableListContainerFactory;
}

export function EmbeddablePanelExample({ embeddableServices, searchListContainerFactory }: Props) {
export function EmbeddablePanelExample({ searchListContainerFactory }: Props) {
const searchableInput = {
id: '1',
title: 'My searchable todo list',
Expand Down Expand Up @@ -120,7 +119,7 @@ export function EmbeddablePanelExample({ embeddableServices, searchListContainer
</EuiText>
<EuiPanel data-test-subj="embeddedPanelExample" paddingSize="none" role="figure">
{embeddable ? (
<embeddableServices.EmbeddablePanel embeddable={embeddable} />
<EmbeddablePanel embeddable={embeddable} />
) : (
<EuiText>Loading...</EuiText>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import React, { useState, useRef, useEffect, useLayoutEffect } from 'react';
import { EuiLoadingChart } from '@elastic/eui';
import classNames from 'classnames';

import {
EmbeddableChildPanel,
EmbeddablePhaseEvent,
ViewMode,
} from '@kbn/embeddable-plugin/public';
import { EmbeddablePhaseEvent, EmbeddablePanel, ViewMode } from '@kbn/embeddable-plugin/public';

import { DashboardPanelState } from '../../../../common';
import { pluginServices } from '../../../services/plugin_services';
Expand Down Expand Up @@ -52,9 +48,6 @@ const Item = React.forwardRef<HTMLDivElement, Props>(
},
ref
) => {
const {
embeddable: { EmbeddablePanel: PanelComponent },
} = pluginServices.getServices();
const container = useDashboardContainer();
const scrollToPanelId = container.select((state) => state.componentState.scrollToPanelId);
const highlightPanelId = container.select((state) => state.componentState.highlightPanelId);
Expand Down Expand Up @@ -90,13 +83,13 @@ const Item = React.forwardRef<HTMLDivElement, Props>(
>
{isRenderable ? (
<>
<EmbeddableChildPanel
// This key is used to force rerendering on embeddable type change while the id remains the same
<EmbeddablePanel
key={type}
embeddableId={id}
index={index}
showBadges={true}
showNotifications={true}
onPanelStatusChange={onPanelStatusChange}
{...{ container, PanelComponent }}
embeddable={() => container.untilEmbeddableLoaded(id)}
/>
{children}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,14 @@
* Side Public License, v 1.
*/

import { HttpStart } from '@kbn/core/public';
import { isErrorEmbeddable, openAddPanelFlyout } from '@kbn/embeddable-plugin/public';
import { getSavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public';

import { pluginServices } from '../../../services/plugin_services';
import { DashboardContainer } from '../dashboard_container';

export function addFromLibrary(this: DashboardContainer) {
const {
overlays,
notifications,
usageCollection,
settings: { uiSettings, theme },
embeddable: { getEmbeddableFactories, getEmbeddableFactory },
http,
savedObjectsManagement,
savedObjectsTagging,
} = pluginServices.getServices();

if (isErrorEmbeddable(this)) return;
this.openOverlay(
openAddPanelFlyout({
SavedObjectFinder: getSavedObjectFinder(
uiSettings,
http as HttpStart,
savedObjectsManagement,
savedObjectsTagging.api
),
reportUiCounter: usageCollection.reportUiCounter,
getAllFactories: getEmbeddableFactories,
getFactory: getEmbeddableFactory,
embeddable: this,
notifications,
overlays,
theme,
container: this,
onAddPanel: (id: string) => {
this.setScrollToPanelId(id);
this.setHighlightPanelId(id);
Expand Down
Loading