Skip to content

Commit

Permalink
[Embeddables Rebuild] Allow Save and Return for React Embeddables (#1…
Browse files Browse the repository at this point in the history
…78673)

Allows new embeddables to be added to a Dashboard as Incoming Embeddables.
  • Loading branch information
ThomThomson authored Mar 21, 2024
1 parent 3f1dcff commit 5aaf92f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Reference } from '@kbn/content-management-utils';
*/
export interface SerializedPanelState<RawStateType extends object = object> {
references?: Reference[];
rawState: RawStateType;
rawState: RawStateType | undefined;
version?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ import {
type ControlGroupContainer,
} from '@kbn/controls-plugin/public';
import { GlobalQueryStateFromUrl, syncGlobalQueryStateWithUrl } from '@kbn/data-plugin/public';
import {
EmbeddableFactory,
isErrorEmbeddable,
reactEmbeddableRegistryHasKey,
ViewMode,
} from '@kbn/embeddable-plugin/public';
import { EmbeddableFactory, isErrorEmbeddable, ViewMode } from '@kbn/embeddable-plugin/public';
import { compareFilters, Filter, TimeRange } from '@kbn/es-query';
import { lazyLoadReduxToolsPackage } from '@kbn/presentation-util-plugin/public';
import { cloneDeep, identity, omit, pickBy } from 'lodash';
Expand Down Expand Up @@ -340,10 +335,10 @@ export const initializeDashboard = async ({
const createdEmbeddable = await (async () => {
// if there is no width or height we can add the panel using the default behaviour.
if (!incomingEmbeddable.size) {
return await container.addNewEmbeddable(
incomingEmbeddable.type,
incomingEmbeddable.input
);
return await container.addNewPanel<{ uuid: string }>({
panelType: incomingEmbeddable.type,
initialState: incomingEmbeddable.input,
});
}

// if the incoming embeddable has an explicit width or height we add the panel to the grid directly.
Expand All @@ -370,13 +365,12 @@ export const initializeDashboard = async ({
[newPanelState.explicitInput.id]: newPanelState,
},
});
if (reactEmbeddableRegistryHasKey(incomingEmbeddable.type)) {
return { id: embeddableId };
}

return await container.untilEmbeddableLoaded(embeddableId);
})();
scrolltoIncomingEmbeddable(container, createdEmbeddable.id);
if (createdEmbeddable) {
scrolltoIncomingEmbeddable(container, createdEmbeddable.uuid);
}
});
}
}
Expand Down

0 comments on commit 5aaf92f

Please sign in to comment.