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

fix: MultiEnv switcher visible in view mode in cloud #32333

Merged
merged 3 commits into from Apr 2, 2024

Conversation

brayn003
Copy link
Contributor

@brayn003 brayn003 commented Apr 2, 2024

Description

Issue with ME switcher showing up in cloud

Fixes #32315

Automation

/ok-to-test tags="@tag.MultiEnv"

🔍 Cypress test results

Important

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/8520479330
Commit: 20ae88502963ec88f686ef237d4892886189f088
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

Summary by CodeRabbit

  • New Features
    • Updated logic for displaying the environment switcher based on new feature flags and user roles.
  • Tests
    • Added tests for the updated environment switcher visibility logic.

@github-actions github-actions bot added BE Coders Pod Issues related to users writing code to fetch and update data Bug Something isn't working DailyPromotionBlocker DailyPromotionBlocker Data Platform Pod Issues related to the underlying data platform High This issue blocks a user from building or impacts a lot of users Multiple Environments Issues or tasks related to multiple environments Needs Triaging Needs attention from maintainers to triage Release labels Apr 2, 2024
@brayn003 brayn003 self-assigned this Apr 2, 2024
@brayn003 brayn003 added the ok-to-test Required label for CI label Apr 2, 2024
@brayn003 brayn003 marked this pull request as ready for review April 2, 2024 08:48
Copy link
Contributor

coderabbitai bot commented Apr 2, 2024

Walkthrough

Walkthrough

The updates involve refining the logic within the useShowEnvSwitcher hook to determine the visibility of the environment switcher. This adjustment incorporates a new feature flag isFeatureEnabled, which dictates the switcher's display based on feature availability, environment details, and user mode. Additionally, a test suite has been introduced to ensure the hook's functionality aligns with expected behaviors, particularly concerning user roles and operational modes within a React application.

Changes

File Path Change Summary
.../src/ce/hooks/useShowEnvSwitcher.ts Updated logic to show/hide environment switcher based on isFeatureEnabled flag and other criteria.
.../src/ce/hooks/useShowEnvSwitcher.test.tsx Added tests for useShowEnvSwitcher hook to validate visibility conditions.

Assessment against linked issues

Objective Addressed Explanation
Prevent environment switcher visibility in Preview and View mode (#32315)
Ensure UI reflects deployed components for selected environment (#26367) The changes seem to indirectly address UI consistency by controlling feature visibility, but it's unclear if this directly prevents undeployed widgets from appearing.

Possibly related issues

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

});

const isRampAllowed = useSelector((state) =>
showProductRamps(RAMP_NAME.MULTIPLE_ENV, true)(state),
);

if (!isFeatureEnabled && !isRampAllowed) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this check here then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this is another case

Copy link
Contributor

Choose a reason for hiding this comment

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

But !isFeatureEnabled check will already pass on top so same check won't be needed here right? Also, if it makes sense, we can actually move the entire condition to the top newly added line.

Copy link
Contributor Author

@brayn003 brayn003 Apr 2, 2024

Choose a reason for hiding this comment

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

Umm, isFeatureEnabled in line number 23 is actually getting called inside the isMultiEnvNotPresent selector function. Both of them have different scopes. It is used to make isMultiEnvNotPresent false even if multiple environments are present. Eg - cloud, where the feature flag is false but there are multiple envs

Copy link
Contributor

Choose a reason for hiding this comment

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

oh alright. Didn't open the collapsed lines above. Thanks.

@brayn003 brayn003 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 2, 2024
@brayn003 brayn003 merged commit a23a725 into release Apr 2, 2024
48 checks passed
@brayn003 brayn003 deleted the fix/me-switcher-blocker branch April 2, 2024 09:54
brayn003 added a commit that referenced this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE Coders Pod Issues related to users writing code to fetch and update data Bug Something isn't working DailyPromotionBlocker DailyPromotionBlocker Data Platform Pod Issues related to the underlying data platform High This issue blocks a user from building or impacts a lot of users Multiple Environments Issues or tasks related to multiple environments Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Release
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

[Bug]: Switch environment dropdown is visible in Preview and View mode also
2 participants