Skip to content

Commit

Permalink
[8.15] [canvas] fix by-value map embeddables have broken layers (#190996
Browse files Browse the repository at this point in the history
) (#191011)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[canvas] fix by-value map embeddables have broken layers
(#190996)](#190996)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2024-08-21T17:19:35Z","message":"[canvas]
fix by-value map embeddables have broken layers (#190996)\n\nResolves
#190994 Test
instructions\r\n1. create new canvas workpad\r\n2. Click \"Select type\"
and select \"Maps\"\r\n3. Add a documents layer to your map and click
\"Save and return\"\r\n4. Click \"canvas\" bread crumb to go back to
canvas listing page\r\n5. Open you work pad again. Map should still
display
data","sha":"1da096793d775d9dacafc6a744b84caf5cb2a5eb","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","Feature:Maps","project:embeddableRebuild","v8.16.0","v8.15.1"],"title":"[canvas]
fix by-value map embeddables have broken
layers","number":190996,"url":"#190996
fix by-value map embeddables have broken layers (#190996)\n\nResolves
#190994 Test
instructions\r\n1. create new canvas workpad\r\n2. Click \"Select type\"
and select \"Maps\"\r\n3. Add a documents layer to your map and click
\"Save and return\"\r\n4. Click \"canvas\" bread crumb to go back to
canvas listing page\r\n5. Open you work pad again. Map should still
display
data","sha":"1da096793d775d9dacafc6a744b84caf5cb2a5eb"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"#190996
fix by-value map embeddables have broken layers (#190996)\n\nResolves
#190994 Test
instructions\r\n1. create new canvas workpad\r\n2. Click \"Select type\"
and select \"Maps\"\r\n3. Add a documents layer to your map and click
\"Save and return\"\r\n4. Click \"canvas\" bread crumb to go back to
canvas listing page\r\n5. Open you work pad again. Map should still
display
data","sha":"1da096793d775d9dacafc6a744b84caf5cb2a5eb"}},{"branch":"8.15","label":"v8.15.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
  • Loading branch information
kibanamachine and nreese committed Aug 21, 2024
1 parent 5167307 commit 0669c37
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const useCanvasApi: () => CanvasContainerApi = () => {
createNewEmbeddable(panelType, initialState);
},
disableTriggers: true,
type: 'canvas',
/**
* getSerializedStateForChild is left out here because we cannot access the state here. That method
* is injected in `x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx`
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/canvas/types/embeddables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EmbeddableInput as Input } from '@kbn/embeddable-plugin/common';
import {
HasAppContext,
HasDisableTriggers,
HasType,
PublishesViewMode,
PublishesUnifiedSearch,
} from '@kbn/presentation-publishing';
Expand All @@ -25,5 +26,6 @@ export type EmbeddableInput = Input & {
export type CanvasContainerApi = PublishesViewMode &
CanAddNewPanel &
HasDisableTriggers &
HasType &
HasSerializedChildState &
Partial<HasAppContext & PublishesUnifiedSearch>;
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { APPLY_FILTER_TRIGGER } from '@kbn/data-plugin/public';
import { ReactEmbeddableFactory, VALUE_CLICK_TRIGGER } from '@kbn/embeddable-plugin/public';
import { EmbeddableStateWithType } from '@kbn/embeddable-plugin/common';
import {
apiIsOfType,
areTriggersDisabled,
getUnchangingComparator,
initializeTimeRange,
Expand Down Expand Up @@ -125,6 +126,16 @@ export const mapEmbeddableFactory: ReactEmbeddableFactory<
};
}

/**
* Canvas by-value embeddables do not support references
*/
if (apiIsOfType(parentApi, 'canvas')) {
return {
rawState: getByValueState(rawState, savedMap.getAttributes()),
references: [],
};
}

// by-value embeddable
const { attributes, references } = extractReferences({
attributes: savedMap.getAttributes(),
Expand Down

0 comments on commit 0669c37

Please sign in to comment.