Skip to content

[9.0] Upgrade to Storybook 8 (#195148)#214680

Merged
Ikuni17 merged 14 commits intoelastic:9.0from
Ikuni17:backport/9.0/pr-195148
Mar 19, 2025
Merged

[9.0] Upgrade to Storybook 8 (#195148)#214680
Ikuni17 merged 14 commits intoelastic:9.0from
Ikuni17:backport/9.0/pr-195148

Conversation

@Ikuni17
Copy link
Contributor

@Ikuni17 Ikuni17 commented Mar 15, 2025

Backport

This will backport the following commits from main to 9.0:

Questions ?

Please refer to the Backport tool documentation

## 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 requested a review from kibanamachine as a code owner March 15, 2025 00:10
@botelastic botelastic bot added Team:Fleet Team label for Observability Data Collection Fleet team Team:Obs AI Assistant Observability AI Assistant labels Mar 15, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@Ikuni17 Ikuni17 added the backport This PR is a backport of another PR label Mar 15, 2025
@Ikuni17 Ikuni17 enabled auto-merge (squash) March 15, 2025 00:11
@Ikuni17 Ikuni17 added Team:Operations Kibana-Operations Team and removed Team:Fleet Team label for Observability Data Collection Fleet team Team:Obs AI Assistant Observability AI Assistant labels Mar 15, 2025
@Ikuni17 Ikuni17 self-assigned this Mar 15, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@Ikuni17 Ikuni17 mentioned this pull request Mar 15, 2025
17 tasks
@botelastic botelastic bot added Team:Fleet Team label for Observability Data Collection Fleet team Team:Obs AI Assistant Observability AI Assistant labels Mar 15, 2025
@Ikuni17 Ikuni17 requested a review from a team March 17, 2025 21:57
@Ikuni17 Ikuni17 enabled auto-merge (squash) March 18, 2025 19:34
@Ikuni17 Ikuni17 merged commit 1c41d89 into elastic:9.0 Mar 19, 2025
10 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 1309 1329 +20
home 224 205 -19
total +1

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 260.2KB 260.2KB +10.0B
enterpriseSearch 1.3MB 1.3MB +3.8KB
fleet 1.7MB 1.7MB +3.0B
maps 2.9MB 2.9MB +4.0B
observabilityAIAssistant 19.6KB 19.7KB +94.0B
observabilityAiAssistantManagement 107.1KB 107.2KB +96.0B
searchAssistant 146.2KB 146.4KB +105.0B
securitySolution 8.8MB 8.8MB +114.0B
securitySolutionEss 36.0KB 36.1KB +96.0B
securitySolutionServerless 57.2KB 57.3KB +96.0B
total +4.5KB

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.3KB 15.4KB +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 Ikuni17 deleted the backport/9.0/pr-195148 branch March 19, 2025 20:20
Ikuni17 added a commit that referenced this pull request Mar 24, 2025
## Summary

These Stories were missed in [Upgrade to Storybook 8
(#195148)](#195148) and should be
migrated to the same format as other stories for consistency and to make
future migrations easier. They technically work in SB8, I forgot to run
the migration script again later on while working on the original PR.

The changes have already been backported to #214680 and #214681
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
## Summary

These Stories were missed in [Upgrade to Storybook 8
(elastic#195148)](elastic#195148) and should be
migrated to the same format as other stories for consistency and to make
future migrations easier. They technically work in SB8, I forgot to run
the migration script again later on while working on the original PR.

The changes have already been backported to elastic#214680 and elastic#214681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR ci:build-storybooks Team:Fleet Team label for Observability Data Collection Fleet team Team:Obs AI Assistant Observability AI Assistant Team:Operations Kibana-Operations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants