mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 03:01:21 -04:00
[lens] update LensEmbeddable.getSavedVis to return LensSavedObjectAttributes (#177064)
Blocking https://github.com/elastic/kibana/pull/176869 While working on https://github.com/elastic/kibana/pull/176869, I discovered there is a type mismatch between `LensEmbeddable.getSavedVis` internal implementation and consumers of `LensEmbeddable.getSavedVis` results. LensEmbeddable.getSavedVis returns `Readonly<Document | undefined>`. LensEmbeddable.getSavedVis consumers are typing the response as `LensSavedObjectAttributes`. This PR updates `LensEmbeddable.getSavedVis` to return `Readonly<LensSavedObjectAttributes | undefined>` since that is how its being used. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4d96654756
commit
82d7244582
2 changed files with 15 additions and 4 deletions
|
@ -1591,8 +1591,19 @@ export class Embeddable
|
||||||
return this.savedVis?.state.query;
|
return this.savedVis?.state.query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSavedVis(): Readonly<Document | undefined> {
|
public getSavedVis(): Readonly<LensSavedObjectAttributes | undefined> {
|
||||||
return this.savedVis;
|
if (!this.savedVis) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Why are 'type' and 'savedObjectId' keys being removed?
|
||||||
|
// Prior to removing them,
|
||||||
|
// this method returned 'Readonly<Document | undefined>' while consumers typed the results as 'LensSavedObjectAttributes'.
|
||||||
|
// Removing 'type' and 'savedObjectId' keys to align method results with consumer typing.
|
||||||
|
const savedVis = { ...this.savedVis };
|
||||||
|
delete savedVis.type;
|
||||||
|
delete savedVis.savedObjectId;
|
||||||
|
return savedVis;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { type HasType, apiIsOfType } from '@kbn/presentation-publishing';
|
import { type HasType, apiIsOfType } from '@kbn/presentation-publishing';
|
||||||
import { Document } from '../../persistence';
|
import { LensSavedObjectAttributes } from '../embeddable';
|
||||||
|
|
||||||
export type HasLensConfig = HasType<'lens'> & {
|
export type HasLensConfig = HasType<'lens'> & {
|
||||||
getSavedVis: () => Readonly<Document | undefined>;
|
getSavedVis: () => Readonly<LensSavedObjectAttributes | undefined>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiHasLensConfig = (api: unknown): api is HasLensConfig => {
|
export const apiHasLensConfig = (api: unknown): api is HasLensConfig => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue