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

feat: Move conversion flow under feature flag. #32490

Merged
merged 11 commits into from
Apr 11, 2024

Conversation

marks0351
Copy link
Contributor

@marks0351 marks0351 commented Apr 8, 2024

workerB

Description

Auto Layout System is being deprecated in favor of Anvil.
So we will no longer update Auto Layout and hence we are removing conversion flow to make sure no new Auto Layout Apps are created.

However we still want to be able to help users who really have mission critical use cases to convert.
two ways to do this

  • ask Support and they will enable the feature flag to enable conversion.(for cloud users)
  • ask Support and they will reveal the global function(overrideFeatureFlag({release_layout_conversion_enabled: true})) to enable conversion.(for users not connected to internet)

Implementation:

  • current feature flags are supplied from the consolidated api and widgets consume them via selectFeatureFlags selector.
  • to override these flags locally, we provide a global function(accessible from console) overrideFeatureFlag which can take an object of featureflags and save them to indexed db.
  • then we use these saved values to override feature flag values supplied by the consolidated api.
  • selectFeatureFlags is where the values are combined and consumed by all components.

Fixes #32140
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Tip

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

@marks0351 marks0351 changed the title task: Move conversion flow under feature flag. feat: Move conversion flow under feature flag. Apr 8, 2024
@github-actions github-actions bot added Anvil Pod Issue related to Anvil project Anvil team issues related to the new layout system anvil labels Apr 8, 2024
@marks0351
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Apr 8, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8598589473.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 32490.
recreate: .

@github-actions github-actions bot added the Enhancement New feature or request label Apr 8, 2024
Copy link

github-actions bot commented Apr 8, 2024

Deploy-Preview-URL: https://ce-32490.dp.appsmith.com

@marks0351 marks0351 added ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Apr 9, 2024
@github-actions github-actions bot removed the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 9, 2024
@marks0351 marks0351 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 9, 2024
@marks0351
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Apr 9, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8613961803.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 32490.
recreate: .

Copy link

github-actions bot commented Apr 9, 2024

Deploy-Preview-URL: https://ce-32490.dp.appsmith.com

@@ -87,6 +87,13 @@ export const setConversionStop = () => {
};
};

export const setConversionFlowOverrideFlagAction = (flag: boolean) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make a common abstract method. We can pass the flag name and values to the payload, right? That if we need to do something similar for other flags, then we can use this method.

@marks0351 marks0351 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 10, 2024
@marks0351
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8627358585.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 32490.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-32490.dp.appsmith.com

@marks0351
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@marks0351 marks0351 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 10, 2024
@marks0351
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8628081747.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 32490.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-32490.dp.appsmith.com

setFeatureFlagOverrideValues,
} from "utils/storage";

export const FeaturesToOverride: FeatureFlag[] = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export const FeaturesToOverride: FeatureFlag[] = [
export const AvailableFeaturesToOverride: FeatureFlag[] = [

@marks0351 marks0351 marked this pull request as ready for review April 10, 2024 09:08
@marks0351 marks0351 requested review from ayushpahwa and a team as code owners April 10, 2024 09:08
@marks0351 marks0351 requested review from riodeuno and removed request for a team April 10, 2024 09:08
Copy link
Contributor

coderabbitai bot commented Apr 10, 2024

Walkthrough

The recent updates focus on improving the application's layout conversion capabilities and feature flag management. Notable changes include enhancing mobile responsiveness, adding a new layout conversion button under a feature flag, and refining feature flag overrides. These modifications aim to streamline testing processes, enhance layout conversion features, and enable dynamic management of feature flags for controlled feature releases and efficient testing.

Changes

File Path Change Summary
.../MobileResponsiveTests/AutoDimension_1_spec.ts
.../MobileResponsiveTests/ResizingSpec.ts
Optimized test setup for canvas cleanup and layout conversion verification.
.../support/Pages/AutoLayout.ts Enhanced layout conversion methods with feature flag overrides.
.../actions/featureFlagActions.ts
.../ce/AppRouter.tsx
.../ce/constants/ReduxActionConstants.tsx
.../ce/entities/FeatureFlag.ts
.../ce/selectors/featureFlagsSelectors.ts
.../reducers/uiReducers/usersReducer.ts
.../utils/hooks/useFeatureFlagOverride.ts
.../utils/storage.ts
Introduced and refined feature flag override functionality.
.../layoutSystems/anvil/utils/layouts/highlights/alignedRowHighlights.ts Adjusted layout highlight logic to enhance alignment detection.
.../CanvasLayoutConversion/ConversionButton.tsx
.../CanvasLayoutConversion/SnapShotBannerCTA.tsx
.../CanvasLayoutConversion/hooks/useShowSnapShotBanner.ts
Implemented and styled the layout conversion button under a feature flag and managed snapshot banner visibility.
.../SaaSEditor/DatasourceForm.tsx
.../WidgetsEditor/components/LayoutSystemBasedPageViewer.tsx
Optimized feature flag usage and improved UI logic.

Assessment against linked issues

Objective Addressed Explanation
Implement a new "Layout Conversion" button within the application. [#32140]
Introduce the button under a feature flag to control its visibility. [#32140]
Ensure the button triggers a layout conversion process when clicked. [#32140]
Verify that the feature flag mechanism works correctly to show/hide the button based on configuration. [#32140]
Test the functionality of the layout conversion process triggered by the button. [#32140] It's unclear if automated tests specifically covering the button's post-conversion functionality have been implemented.

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/schema.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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Comment on lines 913 to 920
export const getFeatureFlagOverrideValues = async (
flagsToFetch = FeaturesToOverride,
) => {
const featureFlagValues: OverriddenFeatureFlags = {};
for (const flag of flagsToFetch) {
featureFlagValues[flag] = (await store.getItem(flag)) as boolean;
}
return featureFlagValues;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using null checks for flag values in getFeatureFlagOverrideValues.

  for (const flag of flagsToFetch) {
-   featureFlagValues[flag] = (await store.getItem(flag)) as boolean;
+   const value = await store.getItem(flag);
+   featureFlagValues[flag] = value === null ? false : (value as boolean);
  }

This ensures that if a flag is not found in the storage, it defaults to false instead of null, maintaining consistent boolean type expectations.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
export const getFeatureFlagOverrideValues = async (
flagsToFetch = FeaturesToOverride,
) => {
const featureFlagValues: OverriddenFeatureFlags = {};
for (const flag of flagsToFetch) {
featureFlagValues[flag] = (await store.getItem(flag)) as boolean;
}
return featureFlagValues;
export const getFeatureFlagOverrideValues = async (
flagsToFetch = FeaturesToOverride,
) => {
const featureFlagValues: OverriddenFeatureFlags = {};
for (const flag of flagsToFetch) {
const value = await store.getItem(flag);
featureFlagValues[flag] = value === null ? false : (value as boolean);
}
return featureFlagValues;

Comment on lines +926 to +927
for (const [flag, value] of Object.entries(featureFlagValues)) {
await store.setItem(flag, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure error handling in setFeatureFlagOverrideValues.

  for (const [flag, value] of Object.entries(featureFlagValues)) {
+   try {
      await store.setItem(flag, value);
+   } catch (error) {
+     log.error(`Error setting feature flag override for ${flag}:`, error);
+   }
  }

Adding try-catch blocks around store.setItem calls can prevent the function from failing silently in case of errors, improving reliability.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
for (const [flag, value] of Object.entries(featureFlagValues)) {
await store.setItem(flag, value);
for (const [flag, value] of Object.entries(featureFlagValues)) {
try {
await store.setItem(flag, value);
} catch (error) {
log.error(`Error setting feature flag override for ${flag}:`, error);
}

Comment on lines +90 to +92
import {
selectFeatureFlagCheck,
selectFeatureFlags,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistent import ordering.

import {
-  selectFeatureFlagCheck,
-  selectFeatureFlags,
+  selectFeatureFlags,
+  selectFeatureFlagCheck,
} from "@appsmith/selectors/featureFlagsSelectors";

Reordering imports alphabetically can improve readability and maintainability of the code.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
import {
selectFeatureFlagCheck,
selectFeatureFlags,
import {
selectFeatureFlags,
selectFeatureFlagCheck,
} from "@appsmith/selectors/featureFlagsSelectors";

@@ -851,7 +854,7 @@
showDebugger,
scopeValue,
isPluginAuthFailed,
featureFlags: state.ui.users.featureFlag.data,
featureFlags: selectFeatureFlags(state),
Copy link
Contributor

Choose a reason for hiding this comment

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

Utilize selectFeatureFlags correctly in mapStateToProps.

- featureFlags: selectFeatureFlags(state),
+ featureFlags: selectFeatureFlags(state, props.datasourceId),

Ensure that selectFeatureFlags is called with the appropriate arguments if it requires specific identifiers to fetch relevant flags. This change assumes selectFeatureFlags might need a datasourceId to fetch flags specific to a datasource. Adjust the argument as necessary based on the actual implementation of selectFeatureFlags.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
featureFlags: selectFeatureFlags(state),
featureFlags: selectFeatureFlags(state, props.datasourceId),

overrides: OverriddenFeatureFlags,
) => {
return {
type: ReduxActionTypes.FETCH_OVERRIDDEN_FEATURE_FLAGS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider renaming the action type to SET_OVERRIDDEN_FEATURE_FLAGS to more accurately reflect the action's purpose of setting overrides rather than fetching data.

@marks0351 marks0351 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 11, 2024
@marks0351
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8641992011.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 32490.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-32490.dp.appsmith.com

@marks0351
Copy link
Contributor Author

/build-deploy-preview airgap-enabled=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/8644585505.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 32490.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-32490.dp.appsmith.com

@ramsaptami ramsaptami requested review from ramsaptami and albinAppsmith and removed request for albinAppsmith April 11, 2024 11:35
Copy link
Contributor

@ramsaptami ramsaptami left a comment

Choose a reason for hiding this comment

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

tested code as per scenarios mentioned here

@marks0351 marks0351 merged commit 271dca0 into release Apr 11, 2024
82 checks passed
@marks0351 marks0351 deleted the task/disable-conversion-flow branch April 11, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anvil Pod Issue related to Anvil project Anvil team issues related to the new layout system anvil Enhancement New feature or request ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Add Layout Coversion button under a feature flag.
3 participants