Skip to content

Upgrade to Storybook 8#195148

Merged
Ikuni17 merged 58 commits intoelastic:mainfrom
Ikuni17:chore/171591/upgrade-storybook
Mar 14, 2025
Merged

Upgrade to Storybook 8#195148
Ikuni17 merged 58 commits intoelastic:mainfrom
Ikuni17:chore/171591/upgrade-storybook

Conversation

@Ikuni17
Copy link
Contributor

@Ikuni17 Ikuni17 commented Oct 4, 2024

Summary

Depends on #191106
Closes #171591

This PR migrates Storybook from 6.x to 8.x. Please see the migration guide for an overview of the changes because there are many breaking changes which effect Kibana. The TODO list below is not inclusive of all the changes.

Reviewers

Each commit contains all files changed for a specific codeowner, please find your respective commit to make review easier.

A first step before code review should be checking the Storybooks Preview from CI for any runtime or style issues which were missed. The preview can be compared to a build from main here. It is worth noting that some stories have runtime issues which existed before this migration.

Most stories appear to have been migrated properly, but the Operations team does not have prior knowledge into every story. Some of the migration was able to be automated through Storybook provided scripts. It is possible this wasn't entirely correct due to the structure of some stories. Additionally, part of this migration is moving Storybook to Webpack 5 which changed how styles are being loaded.

TODO

  • Migrate stories.mdx
  • storyshots
  • Migrate packages which were removed in 8.0
  • react-doc-gen resolution
  • Migrate blocks
  • Migrate deprecated addon-knobs to addon-controls
  • React Fast Refresh support
  • Watch flag callback
  • canvas webpack
  • Rerun CSF migrations for new stories
  • Handle ESM import for addon-docs
  • '@storybook/addon-actions' should be listed in the project's dependencies. Run 'npm i -S @storybook/addon-actions' to add iteslint[import/no-extraneous-dependencies](https://github.com/import-js/eslint-plugin-import/blob/v2.28.0/docs/rules/no-extraneous-dependencies.md)
  • addDecorator migration
  • addParameter migration
  • static build
  • determine if Speed up storybook builds #176500 is solved or push to followup PR
    • This will need to be fixed separately
  • revert .buildkite/pipelines/pull_request/base.yml & .buildkite/scripts/pipelines/pull_request/pipeline.ts to main

@Ikuni17 Ikuni17 added Team:Operations Kibana-Operations Team release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor ci:build-storybooks labels Oct 4, 2024
@Ikuni17 Ikuni17 self-assigned this Oct 4, 2024
@Ikuni17 Ikuni17 force-pushed the chore/171591/upgrade-storybook branch from bbd64e6 to 8217931 Compare October 9, 2024 19:44
@Ikuni17 Ikuni17 force-pushed the chore/171591/upgrade-storybook branch from f24ed40 to 6c60b38 Compare December 13, 2024 20:59
@elastic elastic deleted a comment from elasticmachine Dec 26, 2024
@elastic elastic deleted a comment from elasticmachine Dec 26, 2024
@Ikuni17 Ikuni17 force-pushed the chore/171591/upgrade-storybook branch from a8609e9 to d82849f Compare January 7, 2025 01:47
@elastic elastic deleted a comment from elasticmachine Jan 9, 2025
@elastic elastic deleted a comment from elasticmachine Jan 13, 2025
@elastic elastic deleted a comment from elasticmachine Jan 14, 2025
@elastic elastic deleted a comment from elasticmachine Jan 15, 2025
@Ikuni17 Ikuni17 force-pushed the chore/171591/upgrade-storybook branch from b70c1fb to 8f17c2d Compare February 18, 2025 23:06
@Ikuni17 Ikuni17 changed the title [WIP] Upgrade to Storybook 8 Upgrade to Storybook 8 Feb 21, 2025
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #45 / dashboard app - esql controls dashboard - add a value type ES|QL control should update the Lens chart accordingly

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 1329 1331 +2
home 221 202 -19
total -17

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
@kbn/shared-ux-card-no-data-mocks 28 29 +1
@kbn/shared-ux-markdown-mocks 40 45 +5
@kbn/shared-ux-page-analytics-no-data-mocks 20 23 +3
@kbn/shared-ux-page-kibana-no-data-mocks 24 27 +3
@kbn/shared-ux-page-no-data-config-mocks 24 27 +3
@kbn/shared-ux-page-no-data-mocks 26 29 +3
@kbn/shared-ux-prompt-no-data-views-mocks 25 27 +2
@kbn/storybook 25 27 +2
total +22

Async chunks

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

id before after diff
automaticImport 1.1MB 1.1MB +110.0B
dataUsage 259.9KB 259.9KB +10.0B
enterpriseSearch 1.3MB 1.3MB +1.9KB
fleet 1.7MB 1.7MB +3.0B
maps 3.0MB 3.0MB +4.0B
observabilityAIAssistant 19.6KB 19.7KB +94.0B
observabilityAiAssistantManagement 107.1KB 107.2KB +96.0B
searchAssistant 158.7KB 158.8KB +103.0B
securitySolution 8.9MB 8.9MB +114.0B
securitySolutionEss 36.0KB 36.1KB +96.0B
securitySolutionServerless 57.2KB 57.3KB +96.0B
total +2.7KB

Page load bundle

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

id before after diff
enterpriseSearch 38.7KB 38.8KB +91.0B
kbnUiSharedDeps-npmDll 6.0MB 6.0MB -6.3KB
observabilityAIAssistantApp 15.7KB 15.8KB +113.0B
total -6.1KB
Unknown metric groups

API count

id before after diff
@kbn/shared-ux-card-no-data-mocks 32 33 +1
@kbn/shared-ux-markdown-mocks 41 46 +5
@kbn/shared-ux-page-analytics-no-data-mocks 21 24 +3
@kbn/shared-ux-page-kibana-no-data-mocks 25 28 +3
@kbn/shared-ux-page-no-data-config-mocks 24 27 +3
@kbn/shared-ux-page-no-data-mocks 27 30 +3
@kbn/shared-ux-prompt-no-data-views-mocks 26 28 +2
@kbn/storybook 45 27 -18
total +2

ESLint disabled in files

id before after diff
@kbn/storybook 1 2 +1

ESLint disabled line counts

id before after diff
uiActionsEnhanced 16 17 +1

Total ESLint disabled count

id before after diff
@kbn/storybook 2 3 +1
uiActionsEnhanced 20 21 +1
total +2

Unreferenced deprecated APIs

id before after diff
@kbn/storybook 1 0 -1

History

cc @Ikuni17

@Ikuni17
Copy link
Contributor Author

Ikuni17 commented Mar 14, 2025

We're going to merge this without all reviews due to merge conflicts often and migrating new/updated stories from other PRs. Feel free to comment still if needed.

@Ikuni17 Ikuni17 merged commit 403b5f2 into elastic:main Mar 14, 2025
10 checks passed
@Ikuni17 Ikuni17 deleted the chore/171591/upgrade-storybook branch March 14, 2025 22:41
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x, 9.0

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

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts
9.0 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.0:
- [Space time] extending Scout with perfTracker fixture (#212397)
- Update dependency @redocly/cli to ^1.32.0 (main) (#212624)
- [Streams] Replay loghub data with synthtrace (#212120)

Manual backport

To create the backport manually run:

node scripts/backport --pr 195148

Questions ?

Please refer to the Backport tool documentation

Ikuni17 added a commit to Ikuni17/kibana that referenced this pull request Mar 15, 2025
## Summary

Depends on elastic#191106
Closes elastic#171591

This PR migrates Storybook from `6.x` to `8.x`. Please see the
[migration
guide](https://storybook.js.org/docs/migration-guide/from-older-version)
for an overview of the changes because there are many breaking changes
which effect Kibana. The TODO list below is not inclusive of all the
changes.

## Reviewers
### Each commit contains all files changed for a specific codeowner,
please find your respective commit to make review easier.

A **first step before code review** should be checking the [`Storybooks
Preview`](https://ci-artifacts.kibana.dev/storybooks/pr-195148/index.html)
from CI for any runtime or style issues which were missed. The preview
can be compared to a build from `main`
[here](https://ci-artifacts.kibana.dev/storybooks/pr-212585/index.html).
It is worth noting that some stories have runtime issues which existed
before this migration.

Most stories appear to have been migrated properly, but the Operations
team does not have prior knowledge into every story. Some of the
migration was able to be automated through Storybook provided scripts.
It is possible this wasn't entirely correct due to the structure of some
stories. Additionally, part of this migration is moving Storybook to
Webpack 5 which changed how styles are being loaded.

#### TODO
- [x] Migrate `stories.mdx`
- [x] storyshots
- [x] [Migrate
packages](https://storybook.js.org/docs/migration-guide/from-older-version#package-structure-changes)
which were removed in `8.0`
- [x] `react-doc-gen` resolution
- [x] [Migrate
blocks](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#addon-docs-removed-deprecated-blocksjs-entry)
- [x] Migrate deprecated `addon-knobs` to
[addon-controls](https://www.npmjs.com/package/@storybook/addon-controls)
- [x] React Fast Refresh support
- [x] Watch flag callback
- [x] `canvas` webpack
- [x] Rerun CSF migrations for new stories
- [x] Handle ESM import for `addon-docs`
- [x] `'@storybook/addon-actions' should be listed in the project's
dependencies. Run 'npm i -S @storybook/addon-actions' to add
iteslint[import/no-extraneous-dependencies](https://github.com/import-js/eslint-plugin-import/blob/v2.28.0/docs/rules/no-extraneous-dependencies.md)`
- [x] `addDecorator` migration
- [x] `addParameter` migration
- [x] static build
- [ ] determine if elastic#176500 is solved or push to followup PR
  - This will need to be fixed separately
- [x] revert `.buildkite/pipelines/pull_request/base.yml` &
`.buildkite/scripts/pipelines/pull_request/pipeline.ts` to `main`

---------

Co-authored-by: Tiago Costa <tiago.costa@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Jacek Kolezynski <jacek.kolezynski@elastic.co>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Clint Andrew Hall <clint@clintandrewhall.com>
(cherry picked from commit 403b5f2)

# Conflicts:
#	package.json
#	src/dev/storybook/aliases.ts
#	src/platform/packages/shared/kbn-ambient-storybook-types/index.d.ts
#	src/platform/packages/shared/kbn-monaco/src/painless/constants.ts
#	src/platform/packages/shared/kbn-unified-tabs/src/components/__stories__/storybook_constants.ts
#	src/platform/packages/shared/kbn-unified-tabs/src/components/__stories__/tab.stories.tsx
#	src/platform/packages/shared/kbn-unified-tabs/src/components/__stories__/tabs.stories.tsx
#	src/platform/packages/shared/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx
#	src/platform/plugins/shared/discover/.storybook/main.ts
#	src/platform/plugins/shared/expression_image/public/expression_renderers/__stories__/image_renderer.stories.tsx
#	src/platform/plugins/shared/expression_repeat_image/public/expression_renderers/__stories__/repeat_image_renderer.stories.tsx
#	src/platform/plugins/shared/expression_reveal_image/public/expression_renderers/__stories__/reveal_image_renderer.stories.tsx
#	x-pack/platform/plugins/private/canvas/public/components/custom_element_modal/__stories__/custom_element_modal.stories.tsx
#	x-pack/platform/plugins/private/canvas/public/components/element_card/__stories__/element_card.stories.tsx
#	x-pack/platform/plugins/private/canvas/public/components/workpad_header/editor_menu/__stories__/editor_menu.stories.tsx
#	x-pack/platform/plugins/shared/triggers_actions_ui/.storybook/context/http.ts
#	x-pack/solutions/observability/plugins/apm/public/components/app/service_map/__stories__/cytoscape_example_data.stories.tsx
#	x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/asset_criticality_file_uploader.stories.tsx
#	yarn.lock
@Ikuni17 Ikuni17 removed Team:Fleet Team label for Observability Data Collection Fleet team Team:Obs AI Assistant Observability AI Assistant labels Mar 15, 2025
@Ikuni17
Copy link
Contributor Author

Ikuni17 commented Mar 15, 2025

💚 All backports created successfully

Status Branch Result
9.0
8.x

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

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels ci:build-storybooks release_note:skip Skip the PR/issue when compiling release notes Team:Operations Kibana-Operations Team v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade Storybook to 8.x