Skip to content

[Embeddables Rebuild] Make Serialize Function Synchronous#203662

Merged
ThomThomson merged 10 commits intoelastic:mainfrom
ThomThomson:embeddableRefactor/synchronousSerialize
Dec 13, 2024
Merged

[Embeddables Rebuild] Make Serialize Function Synchronous#203662
ThomThomson merged 10 commits intoelastic:mainfrom
ThomThomson:embeddableRefactor/synchronousSerialize

Conversation

@ThomThomson
Copy link
Copy Markdown
Contributor

@ThomThomson ThomThomson commented Dec 10, 2024

Summary

This PR changes the signature of the serializeState function so that it no longer returns a MaybePromise. This change is made in preparation for an architectural shift which will align all Dashboard embeddable interactions on serialized state rather than runtime state

Additionally, the one example that used the async version of serializeState has been updated. Previously the book example embeddable would save changes to its reference at Dashboard save time. After this PR, the book example embeddable saves changes to its reference on save in the editor flyout. This matches our pattern for inline editable panels that can be saved by reference which is used in the Links panel.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

@ThomThomson
Copy link
Copy Markdown
Contributor Author

/ci

@ThomThomson ThomThomson added loe:medium Medium Level of Effort impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. project:embeddableRebuild Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// Feature:Embeddables Relating to the Embeddable system labels Dec 11, 2024
@ThomThomson ThomThomson marked this pull request as ready for review December 11, 2024 18:15
@ThomThomson ThomThomson requested review from a team as code owners December 11, 2024 18:15
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@ThomThomson ThomThomson added backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Dec 11, 2024
@nreese nreese self-requested a review December 11, 2024 18:41
setIsSaving(true);
const bookSerializedState = await bookApi.serializeState();
const bookSerializedState = bookApi.serializeState();
if (!isMounted()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isMounted check can be removed since callback is now sync

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed and some other cleanups in 8b0809c

forceRefresh: () => void;
getSettings: () => DashboardStateFromSettingsFlyout;
getDashboardPanelFromId: (id: string) => Promise<DashboardPanelState>;
getDashboardPanelFromId: (id: string) => DashboardPanelState;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/plugins/dashboard/public/dashboard_actions/copy_to_dashboard_modal.tsx still awaits getDashboardPanelFromId.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in 8b0809c

@@ -419,31 +412,18 @@ export function initializePanelsManager(
references: Reference[];
}> => {
const references: Reference[] = [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove async from getState method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in 8b0809c

closeOverlay(overlay);
}}
onSubmit={(addToLibrary: boolean) => {
onSubmit={async (addToLibrary: boolean) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that onSubmit is aysnc, SavedBookEditor should show loading state and disable submit button until onSubmit returns to avoid allowing users to click multiple times

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Updated this in 8b0809c

@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Dec 11, 2024
@ThomThomson
Copy link
Copy Markdown
Contributor Author

/ci

Copy link
Copy Markdown
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kibana-presentation changes LGTM
code review only

@ThomThomson
Copy link
Copy Markdown
Contributor Author

/ci

@ThomThomson
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@ThomThomson
Copy link
Copy Markdown
Contributor Author

/ci

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 668.3KB 668.1KB -206.0B
discover 785.9KB 786.0KB +109.0B
links 48.6KB 48.6KB -5.0B
total -102.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
dashboard 52.3KB 52.3KB -15.0B
discover 44.0KB 44.0KB +56.0B
embeddable 65.4KB 65.3KB -140.0B
total -99.0B

History

Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data Discovery changes LGTM! Tested the saved search embeddable locally and saving panel state seems to still work as expected 👍

...titleComparators,
...timeRange.comparators,
...searchEmbeddable.comparators,
rawSavedObjectAttributes: getUnchangingComparator(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh we have other unchanging state like nonPersistedDisplayOptions where maybe this is useful too (not for this PR, just thinking in general). Is getUnchangingComparator intended to be the standard way to handle this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This is the intended workaround.

@ThomThomson ThomThomson merged commit abfd590 into elastic:main Dec 13, 2024
@ThomThomson ThomThomson added backport:prev-minor and removed backport:skip This PR does not require backporting labels Dec 16, 2024
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12359199165

@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12359199142

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 16, 2024
…3662)

changes the signature of the `serializeState` function so that
it no longer returns MaybePromise

(cherry picked from commit abfd590)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Dec 17, 2024
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

stephmilovic pushed a commit that referenced this pull request Dec 17, 2024
) (#204470)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Embeddables Rebuild] Make Serialize Function Synchronous
(#203662)](#203662)

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

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

<!--BACKPORT [{"author":{"name":"Devon
Thomson","email":"devon.thomson@elastic.co"},"sourceCommit":{"committedDate":"2024-12-13T02:25:03Z","message":"[Embeddables
Rebuild] Make Serialize Function Synchronous (#203662)\n\nchanges the
signature of the `serializeState` function so that\r\nit no longer
returns
MaybePromise","sha":"abfd590d4d6420da63d129757120e08278ac3211","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Embedding","Team:Presentation","loe:medium","release_note:skip","impact:high","v9.0.0","backport:prev-minor","Feature:Embeddables","project:embeddableRebuild"],"title":"[Embeddables
Rebuild] Make Serialize Function
Synchronous","number":203662,"url":"https://github.com/elastic/kibana/pull/203662","mergeCommit":{"message":"[Embeddables
Rebuild] Make Serialize Function Synchronous (#203662)\n\nchanges the
signature of the `serializeState` function so that\r\nit no longer
returns
MaybePromise","sha":"abfd590d4d6420da63d129757120e08278ac3211"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203662","number":203662,"mergeCommit":{"message":"[Embeddables
Rebuild] Make Serialize Function Synchronous (#203662)\n\nchanges the
signature of the `serializeState` function so that\r\nit no longer
returns
MaybePromise","sha":"abfd590d4d6420da63d129757120e08278ac3211"}}]}]
BACKPORT-->

Co-authored-by: Devon Thomson <devon.thomson@elastic.co>
@kibanamachine kibanamachine added v8.18.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Embeddables Relating to the Embeddable system Feature:Embedding Embedding content via iFrame impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v8.18.0 v9.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants