Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Embeddable Rebuild] [Controls] Clean up services + TODOs #193180

Conversation

Heenawter
Copy link
Contributor

@Heenawter Heenawter commented Sep 17, 2024

Part of #192005
Closes #167438

Summary

Summary

This PR represents the second major cleanup task for the control group embeddable refactor. The tasks included in this PR can be loosely summarized as follows:

  1. It removes the old, cumbersome services implementation and replaces it with a much simpler system (which is the same one used in the links + presentation_panel plugins).
    • This it the main reason for the decrease in lines - the old system required a huge amount of boilerplate code, which is no longer necessary with the new method for storing services.
  2. It addresses and/or removes any remaining TODO comments in the controls plugin
    • This includes renaming ControlStyle and DEFAULT_CONTROL_STYLE to ControlLabelPosition and DEFAULT_CONTROL_LABEL_POSITION respectively, which represents a bulk of the changes.
  3. It moves all compatibility checks for all control actions to be async imported.
  4. It removes the ability to register controls from the controls plugin setup contract.

Checklist

For maintainers

@Heenawter Heenawter added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas release_note:skip Skip the PR/issue when compiling release notes impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Sep 17, 2024
@Heenawter Heenawter self-assigned this Sep 17, 2024
@Heenawter Heenawter force-pushed the embeddableRebuild_controls_cleanup-todos-and-services_2024-09-12 branch from 6269f45 to c71bfeb Compare September 17, 2024 17:23
@@ -15,8 +15,6 @@ import { OptionsListSortingType } from './suggestions_sorting';
import { DefaultDataControlState } from '../types';
import { OptionsListSearchTechnique } from './suggestions_searching';

export const OPTIONS_LIST_CONTROL = 'optionsListControl'; // TODO: Replace with OPTIONS_LIST_CONTROL_TYPE
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After #192017, this was not actually used - so removing it now.

allowExpensiveQueries: boolean;
// TODO: Rename this route as part of https://github.com/elastic/kibana/issues/174961
}>('/internal/controls/optionsList/getExpensiveQueriesSetting', {
}>('/internal/controls/getExpensiveQueriesSetting', {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed this route since it's no longer specific to the options list - the control group now does the fetching.

// HasSerializableState types serializeState as function returning 'MaybePromise'
// Controls serializeState is sync
serializeState: () => SerializedPanelState<DefaultControlState>;
/** TODO: Make these non-public as part of https://github.com/elastic/kibana/issues/174961 */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided there is no reason to lock down the API at this point in time, especially since we are no longer allowing external plugins to register their own control types. It honestly felt like overcomplicating to split this into "public" and "private" APIs 😅 So I just removed this TODO

@@ -62,7 +62,6 @@ export type ControlApiInitialization<ControlApi extends DefaultControlApi = Defa
'serializeState' | 'getTypeDisplayName' | 'clearSelections'
>;

// TODO: Move this to the Control plugin's setup contract
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided to not allow registering controls via the Control plugin's setup contract, so I removed this TODO

@@ -113,14 +111,15 @@ export const getRangesliderControlFactory = (

const dataLoadingSubscription = combineLatest([loadingMinMax$, loadingHasNoResults$])
.pipe(
debounceTime(100),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a small debounce here to prevent the loading state from "flashing" as often as it did before.

@Heenawter Heenawter marked this pull request as ready for review September 17, 2024 21:07
@Heenawter Heenawter requested review from a team as code owners September 17, 2024 21:07
@elasticmachine
Copy link
Contributor

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

@nreese nreese self-requested a review September 18, 2024 13:23
Copy link
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.

LGTM - thanks for cleaning up the services
code review only

@Heenawter Heenawter enabled auto-merge (squash) September 18, 2024 18:17
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
controls 362 353 -9

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
controls 134 130 -4

Async chunks

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

id before after diff
controls 459.4KB 455.7KB -3.7KB

Page load bundle

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

id before after diff
controls 12.9KB 13.3KB +401.0B
Unknown metric groups

API count

id before after diff
controls 138 134 -4

async chunk count

id before after diff
controls 11 10 -1

References to deprecated APIs

id before after diff
controls 17 13 -4

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @Heenawter

@Heenawter Heenawter merged commit db55574 into elastic:main Sep 19, 2024
19 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 19, 2024
…3180)

Part of elastic#192005
Closes elastic#167438

## Summary

## Summary

This PR represents the second major cleanup task for the control group
embeddable refactor. The tasks included in this PR can be loosely
summarized as follows:
1. It removes the old, cumbersome services implementation and replaces
it with a much simpler system (which is the same one used in the `links`
+ `presentation_panel` plugins).
- This it the main reason for the decrease in lines - the old system
required a **huge** amount of boilerplate code, which is no longer
necessary with the new method for storing services.
2. It addresses and/or removes any remaining TODO comments in the
`controls` plugin
- This includes renaming `ControlStyle` and `DEFAULT_CONTROL_STYLE` to
`ControlLabelPosition` and `DEFAULT_CONTROL_LABEL_POSITION`
respectively, which represents a bulk of the changes.
3. It moves all compatibility checks for all control actions to be async
imported.
4. It removes the ability to register controls from the `controls`
plugin setup contract.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit db55574)
@kibanamachine
Copy link
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

@Heenawter Heenawter deleted the embeddableRebuild_controls_cleanup-todos-and-services_2024-09-12 branch September 19, 2024 14:10
kibanamachine added a commit that referenced this pull request Sep 19, 2024
) (#193429)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Embeddable Rebuild] [Controls] Clean up services + TODOs
(#193180)](#193180)

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

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

<!--BACKPORT [{"author":{"name":"Hannah
Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-19T14:02:49Z","message":"[Embeddable
Rebuild] [Controls] Clean up services + TODOs (#193180)\n\nPart of
#192005
#167438
Summary\r\n\r\n\r\n## Summary\r\n\r\nThis PR represents the second major
cleanup task for the control group\r\nembeddable refactor. The tasks
included in this PR can be loosely\r\nsummarized as follows:\r\n1. It
removes the old, cumbersome services implementation and replaces\r\nit
with a much simpler system (which is the same one used in the
`links`\r\n+ `presentation_panel` plugins).\r\n- This it the main reason
for the decrease in lines - the old system\r\nrequired a **huge** amount
of boilerplate code, which is no longer\r\nnecessary with the new method
for storing services.\r\n2. It addresses and/or removes any remaining
TODO comments in the\r\n`controls` plugin\r\n- This includes renaming
`ControlStyle` and `DEFAULT_CONTROL_STYLE` to\r\n`ControlLabelPosition`
and `DEFAULT_CONTROL_LABEL_POSITION`\r\nrespectively, which represents a
bulk of the changes.\r\n3. It moves all compatibility checks for all
control actions to be async\r\nimported.\r\n4. It removes the ability to
register controls from the `controls`\r\nplugin setup
contract.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"db5557429979b9a0f3420a50a06c7fd69cbdf5b2","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","release_note:skip","impact:high","v9.0.0","backport:prev-minor"],"title":"[Embeddable
Rebuild] [Controls] Clean up services +
TODOs","number":193180,"url":"#193180
Rebuild] [Controls] Clean up services + TODOs (#193180)\n\nPart of
#192005
#167438
Summary\r\n\r\n\r\n## Summary\r\n\r\nThis PR represents the second major
cleanup task for the control group\r\nembeddable refactor. The tasks
included in this PR can be loosely\r\nsummarized as follows:\r\n1. It
removes the old, cumbersome services implementation and replaces\r\nit
with a much simpler system (which is the same one used in the
`links`\r\n+ `presentation_panel` plugins).\r\n- This it the main reason
for the decrease in lines - the old system\r\nrequired a **huge** amount
of boilerplate code, which is no longer\r\nnecessary with the new method
for storing services.\r\n2. It addresses and/or removes any remaining
TODO comments in the\r\n`controls` plugin\r\n- This includes renaming
`ControlStyle` and `DEFAULT_CONTROL_STYLE` to\r\n`ControlLabelPosition`
and `DEFAULT_CONTROL_LABEL_POSITION`\r\nrespectively, which represents a
bulk of the changes.\r\n3. It moves all compatibility checks for all
control actions to be async\r\nimported.\r\n4. It removes the ability to
register controls from the `controls`\r\nplugin setup
contract.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"db5557429979b9a0f3420a50a06c7fd69cbdf5b2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"#193180
Rebuild] [Controls] Clean up services + TODOs (#193180)\n\nPart of
#192005
#167438
Summary\r\n\r\n\r\n## Summary\r\n\r\nThis PR represents the second major
cleanup task for the control group\r\nembeddable refactor. The tasks
included in this PR can be loosely\r\nsummarized as follows:\r\n1. It
removes the old, cumbersome services implementation and replaces\r\nit
with a much simpler system (which is the same one used in the
`links`\r\n+ `presentation_panel` plugins).\r\n- This it the main reason
for the decrease in lines - the old system\r\nrequired a **huge** amount
of boilerplate code, which is no longer\r\nnecessary with the new method
for storing services.\r\n2. It addresses and/or removes any remaining
TODO comments in the\r\n`controls` plugin\r\n- This includes renaming
`ControlStyle` and `DEFAULT_CONTROL_STYLE` to\r\n`ControlLabelPosition`
and `DEFAULT_CONTROL_LABEL_POSITION`\r\nrespectively, which represents a
bulk of the changes.\r\n3. It moves all compatibility checks for all
control actions to be async\r\nimported.\r\n4. It removes the ability to
register controls from the `controls`\r\nplugin setup
contract.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"db5557429979b9a0f3420a50a06c7fd69cbdf5b2"}}]}]
BACKPORT-->

Co-authored-by: Hannah Mudge <Heenawter@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Controls] Simplify module level services
6 participants