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

Core: Disable SidebarContextMenu in static builds #29743

Merged
merged 7 commits into from
Dec 2, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Nov 29, 2024

Closes #29741

What I did

I disabled the SidebarContextMenu in static builds

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

QA should include generating a static storybook, and verifying the context menu are not available

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 2.5 kB 1.61 0%
initSize 130 MB 130 MB 2.63 kB -1 0%
diffSize 52.4 MB 52.4 MB 133 B -1 0%
buildSize 6.83 MB 6.83 MB 133 B 1.26 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B -0.74 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 133 B 1.63 0%
buildSbPreviewSize 271 kB 271 kB 0 B -1.11 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.84 MB 3.84 MB 133 B 1.62 0%
buildPreviewSize 3 MB 3 MB 0 B 1 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 7s 25.5s 18.5s 1.55 🔺72.4%
generateTime 22.7s 20.9s -1s -850ms -0.47 -8.9%
initTime 15.8s 13.5s -2s -259ms -0.56 -16.6%
buildTime 9s 8.1s -912ms -0.92 -11.2%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.8s 4.4s -337ms -1.09 -7.5%
devManagerResponsive 3.4s 3.2s -177ms -0.91 -5.4%
devManagerHeaderVisible 590ms 569ms -21ms 0.37 -3.7%
devManagerIndexVisible 590ms 646ms 56ms 0.86 8.7%
devStoryVisibleUncached 1.8s 1.6s -117ms 0.87 -6.9%
devStoryVisible 748ms 644ms -104ms 0.69 -16.1%
devAutodocsVisible 548ms 378ms -170ms -1.89 🔰-45%
devMDXVisible 497ms 492ms -5ms 0.08 -1%
buildManagerHeaderVisible 566ms 567ms 1ms 0.45 0.2%
buildManagerIndexVisible 577ms 590ms 13ms 0.54 2.2%
buildStoryVisible 560ms 566ms 6ms 0.51 1.1%
buildAutodocsVisible 465ms 459ms -6ms 0.41 -1.3%
buildMDXVisible 562ms 407ms -155ms -0.43 -38.1%

Greptile Summary

Implements conditional rendering of the SidebarContextMenu to prevent the focused test run tooltip from appearing in static/production builds of Storybook.

  • Modified code/.storybook/preview.tsx to set globalThis.CONFIG_TYPE = 'DEVELOPMENT'
  • Updated code/core/src/manager/components/sidebar/ContextMenu.tsx to disable menu in production builds
  • Fixes issue [Bug]: Focused test run tooltip is present in static builds #29741 where test run tooltip incorrectly appeared in static builds
  • Menu functionality remains available in development mode only

@ndelangen ndelangen changed the title disable SidebarContextMenu in static build Core: Disable SidebarContextMenu in static builds Nov 29, 2024
@ndelangen ndelangen self-assigned this Nov 29, 2024
@ndelangen ndelangen requested a review from JReinhold November 29, 2024 08:26
Copy link

nx-cloud bot commented Nov 29, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0768cd1. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@ndelangen ndelangen marked this pull request as ready for review December 2, 2024 13:09
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -22,6 +22,7 @@ import { DocsPageWrapper } from '../lib/blocks/src/components';
import { isChromatic } from './isChromatic';

const { document } = global;
globalThis.CONFIG_TYPE = 'DEVELOPMENT';
Copy link
Contributor

Choose a reason for hiding this comment

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

style: setting CONFIG_TYPE globally could affect other parts of the codebase that rely on this value. Consider using an environment variable or configuration option instead

Comment on lines 24 to +25
const { document } = global;
globalThis.CONFIG_TYPE = 'DEVELOPMENT';
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: this change forces development mode for all preview environments, which may have unintended consequences for production builds

Comment on lines +59 to +61
if (globalThis.CONFIG_TYPE !== 'DEVELOPMENT') {
return empty;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using process.env.NODE_ENV instead of globalThis.CONFIG_TYPE for more reliable environment detection

@ndelangen ndelangen merged commit 35afa71 into next Dec 2, 2024
60 of 61 checks passed
@ndelangen ndelangen deleted the norbert/no-context-in-prod branch December 2, 2024 13:57
@github-actions github-actions bot mentioned this pull request Dec 2, 2024
11 tasks
@ndelangen ndelangen added the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Dec 20, 2024
@yannbf yannbf removed the needs qa Indicates that this needs manual QA during the upcoming minor/major release label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Focused test run tooltip is present in static builds
3 participants