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

Add basic support for experimental theme switching #199748

Merged
merged 26 commits into from
Nov 18, 2024

Conversation

tkajtoch
Copy link
Member

@tkajtoch tkajtoch commented Nov 12, 2024

Summary

This PR adds basic support for theme switching to test experimental themes internally. It defines a new theme:name setting which is read-only (and thus hidden) by default, and needs uiSettings.experimental.themeSwitcherEnabled: true config setting to become visible. The implementation and the way the theme switcher feature is enabled will likely change in the upcoming weeks when we iron out the details, but the way it works right now is sufficient for testing and that's what the immediate goal is.

Please note this PR includes mostly setup work, and no additional themes have been added here. To make reviewing slightly easier, these will be added separately.

The feature and settings should be undocumented for the time being and disabled by default.


As you might notice, there's a new setting added despite already having theme:version. We decided to introduce a new setting instead of resurrecting an existing one for better naming and flexibility and to reduce the risk of breaking things that might still use the old setting value (hardcoded to v8 at the moment). The current plan is to remove theme:version in 9.0.

The theme_loader got refactored to only bundle active themes coming from KBN_OPTIMIZER_THEMES (defaulting to v8light and v8dark) instead of ALL_THEMES that would significantly increase bundle sizes even when the experimental themes were not enabled. Considering there's a SASS to CSS-in-JS migration happening right now, we don't need to worry about Kibana bundles growing in size when a new theme is officially added.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@tkajtoch tkajtoch added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v9.0.0 labels Nov 12, 2024
@tkajtoch tkajtoch self-assigned this Nov 12, 2024
…der to only load themes that are supposed to be bundled
@tkajtoch tkajtoch marked this pull request as ready for review November 13, 2024 12:33
@tkajtoch tkajtoch requested review from a team as code owners November 13, 2024 12:33
tkajtoch and others added 2 commits November 13, 2024 23:48
…tstrap/get_theme_tag.test.ts

Co-authored-by: Rudolf Meijering <[email protected]>
…tstrap/get_theme_tag.test.ts

Co-authored-by: Rudolf Meijering <[email protected]>
Copy link
Contributor

@yngrdyn yngrdyn left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

LGTM for the Threat Hunting Investigations team

Copy link
Member

@mistic mistic left a comment

Choose a reason for hiding this comment

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

Good job on this one @tkajtoch . Bundles do now LGTM and the changes were tested on top of the webpack v5 upgrade PR

Copy link
Contributor

@tommyers-elastic tommyers-elastic left a comment

Choose a reason for hiding this comment

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

reviewed x-pack/plugins/observability_solution/metrics_data_access/public/test_utils/use_global_storybook_theme.tsx on behalf of @elastic/obs-knowledge-team. LGTM.

@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 18, 2024

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
advancedSettings 110 111 +1
aiops 627 625 -2
alerting 239 241 +2
apm 1872 1870 -2
banners 33 34 +1
canvas 1291 1292 +1
cases 820 821 +1
cloudDataMigration 22 23 +1
cloudLinks 78 79 +1
cloudSecurityPosture 662 663 +1
console 238 236 -2
controls 357 358 +1
core 447 445 -2
crossClusterReplication 133 134 +1
dashboard 679 680 +1
dashboardEnhanced 96 97 +1
data 517 518 +1
dataQuality 89 90 +1
dataUsage 133 134 +1
dataViewEditor 86 87 +1
dataViewFieldEditor 162 163 +1
dataViewManagement 241 242 +1
dataVisualizer 735 733 -2
devTools 43 44 +1
discover 977 978 +1
embeddable 143 144 +1
enterpriseSearch 2321 2319 -2
eventAnnotationListing 585 586 +1
exploratoryView 182 183 +1
expressionError 40 26 -14
expressionGauge 107 108 +1
expressionHeatmap 182 183 +1
expressionImage 26 12 -14
expressionLegacyMetricVis 47 48 +1
expressionMetric 24 10 -14
expressionMetricVis 115 116 +1
expressionPartitionVis 196 197 +1
expressionRepeatImage 24 10 -14
expressionRevealImage 27 13 -14
expressionShape 70 56 -14
expressionTagcloud 170 171 +1
expressionXY 257 258 +1
filesManagement 191 192 +1
fleet 1238 1239 +1
globalSearchBar 48 49 +1
graph 303 304 +1
grokdebugger 41 42 +1
guidedOnboarding 42 43 +1
home 267 268 +1
imageEmbeddable 141 142 +1
indexLifecycleManagement 261 262 +1
indexManagement 696 697 +1
infra 1526 1527 +1
ingestPipelines 358 356 -2
inputControlVis 94 95 +1
inspector 78 79 +1
interactiveSetup 58 59 +1
inventory 276 277 +1
investigateApp 583 571 -12
kibanaOverview 137 138 +1
kibanaReact 214 212 -2
kibanaUtils 176 164 -12
lens 1471 1472 +1
licenseManagement 125 126 +1
licensing 29 30 +1
links 131 132 +1
logstash 75 76 +1
management 130 131 +1
maps 1244 1245 +1
metricsDataAccess 293 294 +1
ml 2139 2140 +1
mockIdpPlugin 38 36 -2
monitoring 494 495 +1
navigation 77 78 +1
newsfeed 27 28 +1
observability 1069 1067 -2
observabilityAIAssistantApp 385 373 -12
observabilityLogsExplorer 208 209 +1
observabilityOnboarding 255 253 -2
osquery 345 346 +1
painlessLab 45 46 +1
presentationPanel 105 106 +1
profiling 305 306 +1
remoteClusters 125 126 +1
reporting 152 153 +1
rollup 146 147 +1
runtimeFields 34 35 +1
savedObjects 42 43 +1
savedObjectsManagement 115 116 +1
savedObjectsTagging 106 107 +1
searchAssistant 253 241 -12
searchHomepage 152 153 +1
searchIndices 235 236 +1
searchInferenceEndpoints 103 104 +1
searchNotebooks 55 41 -14
searchPlayground 269 270 +1
searchprofiler 78 79 +1
security 527 528 +1
securitySolution 6202 6203 +1
serverless 78 79 +1
serverlessSearch 290 291 +1
share 93 91 -2
slo 869 867 -2
snapshotRestore 211 212 +1
spaces 338 339 +1
synthetics 1039 1037 -2
telemetry 54 55 +1
timelines 140 141 +1
transform 487 488 +1
triggersActionsUi 853 855 +2
uiActions 40 41 +1
unifiedSearch 376 377 +1
upgradeAssistant 178 179 +1
uptime 590 588 -2
ux 201 199 -2
visDefaultEditor 206 207 +1
visTypeMarkdown 32 33 +1
visTypeTable 50 51 +1
visTypeTimelion 66 67 +1
visTypeTimeseries 462 463 +1
visTypeVega 280 281 +1
visTypeVislib 126 127 +1
visualizations 478 479 +1
watcher 189 190 +1
total -79

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/core-ui-settings-common 8 20 +12
@kbn/management-settings-ids 138 139 +1
@kbn/react-kibana-context-common 2 8 +6
@kbn/react-kibana-context-theme 2 3 +1
@kbn/ui-shared-deps-src 50 51 +1
total +21

Async chunks

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

id before after diff
aiops 587.1KB 586.1KB -1011.0B
alerting 93.8KB 94.0KB +166.0B
apm 3.4MB 3.4MB -3.4KB
canvas 1.1MB 1.1MB +162.0B
cloudDataMigration 5.9KB 6.0KB +162.0B
cloudSecurityPosture 509.4KB 509.6KB +167.0B
console 205.6KB 205.6KB -3.0B
controls 458.6KB 458.8KB +162.0B
crossClusterReplication 146.2KB 146.5KB +249.0B
dashboard 645.3KB 645.3KB -12.0B
dataQuality 28.2KB 28.3KB +168.0B
dataUsage 237.9KB 238.1KB +191.0B
dataViewManagement 137.1KB 137.2KB +163.0B
dataVisualizer 615.1KB 614.0KB -1.1KB
devTools 7.7KB 7.9KB +162.0B
discover 809.9KB 810.0KB +162.0B
enterpriseSearch 2.6MB 2.6MB -1.7KB
eventAnnotationListing 227.7KB 227.8KB +167.0B
exploratoryView 182.7KB 182.9KB +162.0B
expressionError 14.3KB 14.3KB -11.0B
expressionPartitionVis 35.5KB 35.5KB -1.0B
expressionRevealImage 1.6KB 1.6KB +1.0B
filesManagement 121.4KB 121.6KB +166.0B
graph 414.0KB 414.2KB +167.0B
grokdebugger 11.0KB 11.1KB +162.0B
home 151.9KB 152.1KB +173.0B
imageEmbeddable 69.0KB 69.3KB +324.0B
indexLifecycleManagement 166.0KB 166.1KB +169.0B
infra 1.7MB 1.7MB +341.0B
ingestPipelines 405.2KB 405.2KB +1.0B
inputControlVis 52.1KB 52.2KB +162.0B
inventory 236.5KB 236.7KB +169.0B
investigateApp 483.6KB 481.8KB -1.8KB
kibanaOverview 54.7KB 54.8KB +186.0B
kibanaReact 197.1KB 197.1KB +1.0B
kibanaUtils 60.8KB 60.8KB -3.0B
lens 1.5MB 1.5MB +102.0B
licenseManagement 46.5KB 46.7KB +167.0B
links 52.6KB 52.9KB +324.0B
logstash 33.4KB 33.6KB +166.0B
management 48.3KB 48.5KB +166.0B
metricsDataAccess 99.5KB 99.6KB +162.0B
ml 4.7MB 4.7MB +1.4KB
monitoring 533.4KB 533.6KB +201.0B
observability 471.3KB 470.6KB -629.0B
observabilityAIAssistantApp 239.2KB 237.5KB -1.7KB
observabilityLogsExplorer 147.1KB 147.3KB +162.0B
observabilityOnboarding 271.7KB 271.4KB -322.0B
painlessLab 18.6KB 18.8KB +167.0B
profiling 406.0KB 406.1KB +167.0B
remoteClusters 79.2KB 79.3KB +168.0B
rollup 115.5KB 115.7KB +167.0B
savedObjectsManagement 84.6KB 84.8KB +162.0B
searchAssistant 161.9KB 160.2KB -1.7KB
searchHomepage 54.8KB 55.0KB +162.0B
searchIndices 166.7KB 166.9KB +162.0B
searchInferenceEndpoints 77.5KB 77.7KB +162.0B
searchNotebooks 14.2KB 12.0KB -2.2KB
searchPlayground 167.3KB 167.4KB +162.0B
searchprofiler 48.2KB 48.4KB +174.0B
securitySolution 13.4MB 13.4MB +798.0B
serverlessSearch 338.5KB 338.8KB +324.0B
share 4.2KB 3.6KB -545.0B
slo 854.4KB 865.3KB +11.0KB
snapshotRestore 262.7KB 262.8KB +163.0B
synthetics 1.1MB 1.1MB -805.0B
timelines 32.8KB 32.9KB +162.0B
transform 473.1KB 473.3KB +162.0B
triggersActionsUi 1.7MB 1.7MB +1.1KB
uptime 468.1KB 467.4KB -736.0B
ux 167.6KB 167.3KB -335.0B
watcher 166.2KB 166.4KB +175.0B
total +4.6KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/optimizer 10 9 -1

Page load bundle

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

id before after diff
advancedSettings 7.4KB 7.6KB +162.0B
aiops 16.1KB 16.2KB +70.0B
apm 37.9KB 38.0KB +70.0B
banners 10.4KB 10.6KB +162.0B
cases 158.2KB 158.3KB +162.0B
cloudLinks 30.2KB 30.4KB +168.0B
console 38.3KB 38.2KB -63.0B
core 454.0KB 453.9KB -199.0B
dashboard 51.8KB 52.0KB +163.0B
dashboardEnhanced 17.9KB 18.0KB +167.0B
data 421.5KB 421.7KB +162.0B
dataViewEditor 13.5KB 13.7KB +162.0B
dataViewFieldEditor 26.8KB 26.9KB +162.0B
dataVisualizer 24.5KB 24.5KB +70.0B
embeddable 72.1KB 72.2KB +162.0B
enterpriseSearch 53.8KB 53.8KB +70.0B
expressionError 7.5KB 5.2KB -2.3KB
expressionGauge 16.3KB 16.4KB +162.0B
expressionHeatmap 17.2KB 17.3KB +162.0B
expressionImage 6.8KB 4.4KB -2.4KB
expressionLegacyMetricVis 12.5KB 12.7KB +162.0B
expressionMetric 8.1KB 5.7KB -2.4KB
expressionMetricVis 16.9KB 17.1KB +162.0B
expressionPartitionVis 29.1KB 29.3KB +163.0B
expressionRepeatImage 8.6KB 6.2KB -2.3KB
expressionRevealImage 8.5KB 6.3KB -2.3KB
expressionShape 23.1KB 20.8KB -2.3KB
expressionTagcloud 13.2KB 13.4KB +162.0B
expressionXY 42.0KB 42.1KB +167.0B
fleet 173.9KB 174.1KB +162.0B
globalSearchBar 29.9KB 30.0KB +162.0B
guidedOnboarding 29.6KB 29.7KB +183.0B
indexManagement 46.3KB 46.5KB +162.0B
ingestPipelines 17.5KB 17.7KB +238.0B
inspector 24.9KB 25.1KB +162.0B
interactiveSetup 59.6KB 59.7KB +169.0B
investigateApp 6.7KB 6.7KB -19.0B
kbnUiSharedDeps-srcJs 3.4MB 3.4MB +4.1KB
kibanaReact 39.4KB 39.1KB -266.0B
kibanaUtils 68.7KB 66.9KB -1.9KB
lens 50.8KB 51.0KB +162.0B
licensing 11.7KB 11.9KB +162.0B
maps 54.4KB 54.5KB +162.0B
mockIdpPlugin 10.6KB 10.0KB -601.0B
navigation 18.1KB 18.2KB +20.0B
newsfeed 12.7KB 12.9KB +162.0B
observability 103.6KB 103.6KB -28.0B
observabilityAIAssistantApp 8.7KB 8.7KB -19.0B
observabilityOnboarding 10.4KB 10.5KB +70.0B
osquery 46.9KB 47.1KB +162.0B
presentationPanel 43.1KB 43.3KB +162.0B
reporting 50.7KB 50.8KB +162.0B
runtimeFields 13.9KB 14.0KB +162.0B
savedObjects 19.6KB 19.8KB +162.0B
savedObjectsTagging 22.6KB 22.8KB +162.0B
searchAssistant 4.8KB 4.7KB -19.0B
searchNotebooks 16.4KB 16.2KB -124.0B
security 67.8KB 68.0KB +162.0B
serverless 14.4KB 14.6KB +162.0B
share 57.6KB 57.6KB +7.0B
slo 28.6KB 28.7KB +77.0B
spaces 34.3KB 34.4KB +162.0B
synthetics 37.5KB 37.5KB +70.0B
telemetry 24.8KB 25.0KB +162.0B
uiActions 23.5KB 23.6KB +166.0B
unifiedSearch 38.6KB 38.7KB +162.0B
upgradeAssistant 24.6KB 24.7KB +162.0B
uptime 22.8KB 22.9KB +70.0B
ux 6.9KB 6.9KB +70.0B
visDefaultEditor 24.0KB 24.1KB +162.0B
visTypeMarkdown 9.7KB 9.8KB +162.0B
visTypeTable 19.2KB 19.4KB +162.0B
visTypeTimelion 13.4KB 13.6KB +162.0B
visTypeTimeseries 20.4KB 20.6KB +162.0B
visTypeVega 36.1KB 36.3KB +167.0B
visTypeVislib 15.3KB 15.5KB +162.0B
visualizations 70.9KB 71.1KB +162.0B
total -4.5KB
Unknown metric groups

API count

id before after diff
@kbn/core-theme-browser 6 7 +1
@kbn/core-ui-settings-common 34 48 +14
@kbn/management-settings-ids 139 140 +1
@kbn/react-kibana-context-common 8 15 +7
@kbn/react-kibana-context-theme 11 13 +2
@kbn/ui-shared-deps-src 59 60 +1
total +26

async chunk count

id before after diff
slo 30 31 +1

History

cc @tkajtoch

@tkajtoch tkajtoch enabled auto-merge (squash) November 18, 2024 11:15
@tkajtoch tkajtoch merged commit 5b77b7e into elastic:main Nov 18, 2024
34 checks passed
jesuswr pushed a commit to jesuswr/kibana that referenced this pull request Nov 18, 2024
## Summary

This PR adds basic support for theme switching to test experimental
themes internally. It defines a new `theme:name` setting which is
read-only (and thus hidden) by default, and needs
`uiSettings.experimental.themeSwitcherEnabled: true` config setting to
become visible. The implementation and the way the theme switcher
feature is enabled will likely change in the upcoming weeks when we iron
out the details, but the way it works right now is sufficient for
testing and that's what the immediate goal is.

Please note this PR includes mostly setup work, and no additional themes
have been added here. To make reviewing slightly easier, these will be
added separately.

The feature and settings should be undocumented for the time being and
disabled by default.

---

As you might notice, there's a new setting added despite already having
`theme:version`. We decided to introduce a new setting instead of
resurrecting an existing one for better naming and flexibility and to
reduce the risk of breaking things that might still use the old setting
value (hardcoded to `v8` at the moment). The current plan is to remove
`theme:version` in 9.0.

The theme_loader got refactored to only bundle active themes coming from
`KBN_OPTIMIZER_THEMES` (defaulting to `v8light` and `v8dark`) instead of
`ALL_THEMES` that would significantly increase bundle sizes even when
the experimental themes were not enabled. Considering there's a SASS to
CSS-in-JS migration happening right now, we don't need to worry about
Kibana bundles growing in size when a new theme is officially added.

### Checklist

Delete any items that are not applicable to this PR.

- [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#_add_your_labels)
- [ ] This will appear in the **Release Notes** and follow the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Clint Andrew Hall <[email protected]>
Co-authored-by: Rudolf Meijering <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Tiago Costa <[email protected]>
tsullivan added a commit to tsullivan/kibana that referenced this pull request Nov 21, 2024
maryam-saeidi added a commit to maryam-saeidi/kibana that referenced this pull request Nov 26, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## Summary

This PR adds basic support for theme switching to test experimental
themes internally. It defines a new `theme:name` setting which is
read-only (and thus hidden) by default, and needs
`uiSettings.experimental.themeSwitcherEnabled: true` config setting to
become visible. The implementation and the way the theme switcher
feature is enabled will likely change in the upcoming weeks when we iron
out the details, but the way it works right now is sufficient for
testing and that's what the immediate goal is.

Please note this PR includes mostly setup work, and no additional themes
have been added here. To make reviewing slightly easier, these will be
added separately.

The feature and settings should be undocumented for the time being and
disabled by default.

---

As you might notice, there's a new setting added despite already having
`theme:version`. We decided to introduce a new setting instead of
resurrecting an existing one for better naming and flexibility and to
reduce the risk of breaking things that might still use the old setting
value (hardcoded to `v8` at the moment). The current plan is to remove
`theme:version` in 9.0.

The theme_loader got refactored to only bundle active themes coming from
`KBN_OPTIMIZER_THEMES` (defaulting to `v8light` and `v8dark`) instead of
`ALL_THEMES` that would significantly increase bundle sizes even when
the experimental themes were not enabled. Considering there's a SASS to
CSS-in-JS migration happening right now, we don't need to worry about
Kibana bundles growing in size when a new theme is officially added.

### Checklist

Delete any items that are not applicable to this PR.

- [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#_add_your_labels)
- [ ] This will appear in the **Release Notes** and follow the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Clint Andrew Hall <[email protected]>
Co-authored-by: Rudolf Meijering <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Tiago Costa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.