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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: anvil layout and some cleanup #33442

Merged
merged 1 commit into from
May 15, 2024
Merged

fix: anvil layout and some cleanup #33442

merged 1 commit into from
May 15, 2024

Conversation

KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented May 14, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
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.Anvil"

馃攳 Cypress test results

Tip

馃煝 馃煝 馃煝 All cypress tests have passed! 馃帀 馃帀 馃帀
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9083152704
Commit: b443ac6
Cypress dashboard url: Click here!

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Copy link
Contributor

coderabbitai bot commented May 14, 2024

Walkthrough

Walkthrough

The recent updates primarily focus on simplifying and streamlining the layout components within the Anvil layout system. Key changes include the removal of several properties from the FlexLayoutProps interface and significant code clean-up in the AlignedWidgetRowComp.tsx component. Additionally, obsolete imports and type declarations have been eliminated from the anvilTypes.ts file, leading to a more efficient and maintainable codebase.

Changes

File Path Change Summary
.../components/FlexLayout.tsx
.../components/alignedWidgetRow/AlignedWidgetRowComp.tsx
Removed various properties from interfaces, cleaned up unused imports, and simplified component logic.
.../utils/anvilTypes.ts Removed obsolete imports and type declarations like RenderMode, GenerateHighlights, and UpdateHighlights.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3b2161a and b443ac6.
Files selected for processing (3)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/FlexLayout.tsx (8 hunks)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/alignedWidgetRow/AlignedWidgetRowComp.tsx (5 hunks)
  • app/client/src/layoutSystems/anvil/utils/anvilTypes.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/FlexLayout.tsx
  • app/client/src/layoutSystems/anvil/utils/anvilTypes.ts
Additional comments not posted (5)
app/client/src/layoutSystems/anvil/layoutComponents/components/alignedWidgetRow/AlignedWidgetRowComp.tsx (5)

1-1: The removal of unused imports (useEffect, useState, isEditOnlyModeSelector, shouldOverrideAlignmentStyle, ALIGNMENT_WIDTH_THRESHOLD, RenderModes, getAnvilLayoutDOMId) is a good cleanup step. It reduces the complexity and improves maintainability.


34-34: The removal of the renderMode prop and related logic simplifies the component and aligns with the goal of reducing complexity. Ensure that this change does not affect any dependent functionality.


46-57: The use of useMemo to define the commonProps object is a good practice to optimize performance by memoizing the object and preventing unnecessary re-renders.


59-62: The logic to check if the layout renders a Fill widget (isFillWidgetPresentInList) is necessary and correctly retained. It ensures the appropriate rendering strategy for child widgets.


94-135: The simplification of the rendering logic for child widgets by removing unnecessary hooks and state management is a positive change. It reduces complexity and potential performance issues. The use of FlexLayout for rendering child widgets is appropriate and aligns with the overall goal of improving maintainability.


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.

@github-actions github-actions bot added the Bug Something isn't working label May 14, 2024
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: 0

Out of diff range and nitpick comments (1)
app/client/src/layoutSystems/anvil/utils/anvilTypes.ts (1)

[!TIP]
Codebase Verification

The verification script has revealed numerous instances of the renderMode property still being used throughout the codebase. This indicates that the removal of the renderMode property from the LayoutComponentProps interface might not be complete or could lead to issues if not addressed properly.

Locations where renderMode is still used:

  • app/client/test/factories/Widgets/CanvasFactory.ts
  • app/client/test/factories/Widgets/FilepickerFactory.ts
  • app/client/test/factories/Widgets/ListFactory.ts
  • app/client/test/factories/Widgets/VideoFactory.ts
  • app/client/test/factories/Widgets/TabsFactory.ts
  • app/client/test/factories/Widgets/SwitchFactory.ts
  • app/client/test/factories/Widgets/SkeletonFactory.ts
  • app/client/test/factories/Widgets/RichTextFactory.ts
  • app/client/test/factories/Widgets/RadiogroupFactory.ts
  • app/client/test/factories/Widgets/MapFactory.ts
  • app/client/test/factories/Widgets/ModalFactory.ts
  • app/client/test/factories/Widgets/TextFactory.ts
  • app/client/test/factories/Widgets/IconFactory.ts
  • app/client/test/factories/Widgets/FormFactory.ts
  • app/client/test/factories/Widgets/FormButtonFactory.ts
  • app/client/test/factories/Widgets/DropdownFactory.ts
  • app/client/test/factories/Widgets/DividerFactory.ts
  • app/client/test/factories/Widgets/ImageFactory.ts
  • app/client/test/factories/Widgets/ContainerFactory.ts
  • app/client/test/factories/Widgets/CheckboxFactory.ts
  • app/client/test/factories/Widgets/ChartFactory.ts
  • app/client/test/factories/Widgets/ButtonFactory.ts
  • app/client/test/factories/Widgets/DatepickerFactory.ts
  • app/client/test/factories/WidgetFactoryUtils.ts
  • app/client/src/sagas/WidgetSelectUtils.test.ts
  • app/client/src/sagas/WidgetOperationUtils.ts
  • app/client/src/sagas/WidgetBlueprintSagas.test.ts
  • app/client/src/sagas/WidgetOperationUtils.test.ts
  • app/client/src/sagas/WidgetOperationSagas.tsx
  • app/client/src/sagas/WidgetAdditionSagas.ts
  • app/client/src/widgets/withWidgetProps.tsx
  • app/client/src/widgets/ListWidgetV2/testData.ts
  • app/client/src/widgets/ListWidgetV2/widget/index.tsx
  • app/client/src/widgets/wds/WDSTableWidget/widget/reactTableUtils/getColumnsPureFn.tsx
  • app/client/src/widgets/wds/WDSTableWidget/widget/index.tsx
  • app/client/src/widgets/wds/WDSButtonWidget/component/Container.tsx
  • app/client/src/widgets/useDropdown.tsx
  • app/client/src/widgets/ListWidgetV2/MetaWidgetGenerator.ts
  • app/client/src/widgets/ListWidgetV2/MetaWidgetGenerator.test.ts
  • app/client/src/widgets/DropdownWidget/widget/index.test.tsx
  • app/client/src/widgets/WidgetUtils.test.ts
  • app/client/src/widgets/anvil/ZoneWidget/widget/config/anvilConfig.ts
  • app/client/src/widgets/TableWidgetV2/widget/reactTableUtils/getColumnsPureFn.tsx
  • app/client/src/widgets/TableWidgetV2/widget/index.tsx
  • app/client/src/widgets/TableWidget/widget/propertyUtils.test.ts
  • app/client/src/widgets/TableWidget/widget/index.tsx
  • app/client/src/widgets/DividerWidget/widget/index.test.tsx
  • app/client/src/widgets/SingleSelectTreeWidget/widget/index.tsx
  • app/client/src/widgets/SingleSelectTreeWidget/component/index.tsx
  • app/client/src/widgets/MultiSelectWidgetV2/component/index.tsx
  • app/client/src/widgets/MultiSelectWidgetV2/widget/index.tsx
  • app/client/src/widgets/MultiSelectTreeWidget/widget/index.tsx
  • app/client/src/widgets/ModalWidget/widget/index.tsx
  • app/client/src/widgets/ModalWidget/component/index.tsx
  • app/client/src/widgets/MultiSelectTreeWidget/component/index.tsx
  • app/client/src/widgets/MenuButtonWidget/widget/index.tsx
  • app/client/src/widgets/MenuButtonWidget/constants.ts
  • app/client/src/widgets/MenuButtonWidget/component/index.tsx
  • app/client/src/widgets/JSONFormWidget/widget/index.tsx
  • app/client/src/widgets/ListWidget/widget/index.tsx
  • app/client/src/widgets/ListWidget/widget/index.test.tsx
  • app/client/src/widgets/JSONFormWidget/fields/useRegisterFieldValidity.test.tsx
  • app/client/src/widgets/JSONFormWidget/fields/PhoneInputField.tsx
  • app/client/src/widgets/JSONFormWidget/fields/CurrencyInputField.tsx
  • app/client/src/widgets/JSONFormWidget/fields/ArrayField.test.tsx
  • app/client/src/widgets/JSONFormWidget/FormContext.tsx
  • app/client/src/widgets/JSONFormWidget/component/index.tsx
  • app/client/src/widgets/ImageWidget/widget/index.tsx
  • app/client/src/widgets/InputWidget/widget/index.tsx
  • app/client/src/widgets/InputWidget/widget/index.test.tsx
  • app/client/src/widgets/IframeWidget/widget/index.tsx
  • app/client/src/widgets/IframeWidget/component/index.tsx
  • app/client/src/widgets/IconButtonWidget/widget/index.tsx
  • app/client/src/widgets/IconButtonWidget/component/index.tsx
  • app/client/src/widgets/CustomWidget/widget/index.tsx
  • app/client/src/widgets/CustomWidget/component/index.tsx
  • app/client/src/widgets/ChartWidget/widget/index.test.ts
  • app/client/src/widgets/ChartWidget/widget/SyntaxErrorsEvaluation.test.ts
  • app/client/src/widgets/ButtonGroupWidget/widget/index.tsx
  • app/client/src/workers/common/DataTreeEvaluator/mockData/mockUnEvalTree.ts
  • app/client/src/workers/common/DataTreeEvaluator/mockData/ArrayAccessorTree.ts
  • app/client/src/workers/common/DataTreeEvaluator/mockData/NestedArrayAccessorTree.ts
  • app/client/src/widgets/ButtonGroupWidget/component/index.tsx
  • app/client/src/widgets/ButtonWidget/component/DragContainer.tsx
  • app/client/src/widgets/BaseWidget.tsx
  • app/client/src/workers/Evaluation/replayUtils.ts
  • app/client/src/workers/Evaluation/__tests__/evaluate.test.ts
  • app/client/src/workers/Evaluation/__tests__/setters.test.ts
  • app/client/src/workers/Evaluation/__tests__/validations.test.ts
  • app/client/src/workers/Evaluation/__tests__/generateOpimisedUpdates.test.ts
  • app/client/src/workers/Evaluation/__tests__/evaluation.test.ts
  • app/client/src/workers/Evaluation/__tests__/Actions.test.ts
  • app/client/src/utils/metaWidgetState.ts
  • app/client/src/utils/testDSLs.ts
  • app/client/src/utils/helpers.test.ts
  • app/client/src/utils/autocomplete/__tests__/dataTreeTypeDefCreator.test.ts
  • app/client/src/utils/WidgetPropsUtils.tsx
  • app/client/src/utils/WidgetSizeUtils.test.ts
  • app/client/src/utils/WidgetLoadingStateUtils.test.ts
  • app/client/src/utils/WidgetFeatures.test.ts
  • app/client/src/utils/FilterInternalProperties/__tests__/index.test.ts
  • app/client/src/selectors/propertyPaneSelectors.tsx
  • app/client/src/selectors/flattenedChildCanvasSelector.ts
  • app/client/src/selectors/editorSelectors.tsx
  • app/client/src/reducers/entityReducers/metaWidgetsReducer.test.ts
  • app/client/src/pages/Editor/WidgetsEditor/WidgetEditorContainer.tsx
  • app/client/src/pages/Editor/CustomWidgetBuilder/Preview/index.tsx
  • app/client/src/pages/AppViewer/index.tsx
  • app/client/src/mocks/widgetProps/input.ts
  • app/client/src/mocks/widgetProps/container.ts
  • app/client/src/mocks/layoutComponents/layoutComponentMock.ts
  • app/client/src/mocks/widgetProps/button.ts
  • app/client/src/mocks/widgetProps/canvas.ts
  • app/client/src/layoutSystems/withLayoutSystemWidgetHOC.test.tsx
  • app/client/src/layoutSystems/withLayoutSystemWidgetHOC.tsx
  • app/client/src/layoutSystems/autolayout/viewer/AutoLayoutViewerWidgetOnion.tsx
  • app/client/src/mockComponentProps/WidgetPayloads.ts
  • app/client/src/layoutSystems/common/dropTarget/DragLayerComponent.test.tsx
  • app/client/src/layoutSystems/anvil/utils/layouts/renderUtils.tsx
  • app/client/src/layoutSystems/anvil/layoutComponents/components/zone/useZoneMinWidth.ts
  • app/client/src/layoutSystems/anvil/layoutComponents/components/section/SectionRow.tsx
  • app/client/src/layoutSystems/anvil/layoutComponents/WidgetRenderer.tsx
  • app/client/src/layoutSystems/anvil/layoutComponents/LayoutProvider.tsx
  • app/client/src/layoutSystems/anvil/layoutComponents/BaseLayoutComponent.tsx
  • app/client/src/layoutSystems/anvil/index.ts
  • app/client/src/layoutSystems/CanvasFactory.tsx
  • app/client/src/entities/Widget/utils.test.ts
  • app/client/src/entities/Replay/ReplayEntity/ReplayCanvas.ts
  • app/client/src/entities/DataTree/dataTreeWidget.test.ts
  • app/client/src/entities/AppTheming/utils.test.ts
  • app/client/src/components/editorComponents/EditorContextProvider.tsx
  • app/client/src/components/editorComponents/PartialImportExport/PartialExportModal/unitTestUtils.ts
  • app/client/src/components/editorComponents/EditorContextProvider.test.tsx
  • app/client/src/constants/WidgetConstants.tsx
  • app/client/src/ce/workers/Evaluation/evaluationUtils.test.ts
  • app/client/src/WidgetProvider/factory/index.tsx
  • app/client/packages/dsl/src/migrate/tests/ChartDataFromArrayFromArrayToObject.test.ts
  • app/client/packages/dsl/src/migrate/tests/MigrateInitialValues.test.ts
  • app/client/packages/dsl/src/migrate/tests/TextWidget.test.ts
  • app/client/packages/dsl/src/migrate/tests/DSLMigrationsUtils.test.ts
  • app/client/packages/dsl/src/migrate/tests/PhoneInputWidgetMigrations.test.ts
  • app/client/packages/dsl/src/migrate/tests/ModalWidget.test.ts
  • app/client/packages/dsl/src/migrate/tests/CustomWidget.test.ts
  • app/client/packages/dsl/src/migrate/tests/testDSLs.ts
  • app/client/packages/dsl/src/migrate/tests/ChartWidgetReskinningMigrations.test.ts
  • app/client/packages/dsl/src/migrate/tests/CurrencyInputWidgetMigrations.test.ts
  • app/client/packages/dsl/src/migrate/tests/SelectWidget.test.ts
  • app/client/packages/dsl/src/migrate/tests/TableWidget.test.ts
  • app/client/packages/dsl/src/migrate/tests/ThemingMigration.test.ts

Action Required:

  • Review and update the codebase to ensure the renderMode property is either properly refactored or reintroduced if necessary.
  • Ensure that all instances of renderMode are handled appropriately to avoid potential runtime errors or inconsistencies.
Analysis chain

Line range hint 16-16: The removal of the renderMode property and the type declarations indicates a refactor or deprecation of these features. Ensure that these removed properties and types are not used elsewhere in the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the removed `renderMode` property and type declarations are not used elsewhere in the codebase.

# Test: Search for the usage of the removed `renderMode` property and type declarations. Expect: No occurrences of the removed properties and types.
rg --type typescript 'renderMode|GenerateHighlights|UpdateHighlights'

Length of output: 106



Script:

#!/bin/bash
# Description: Verify that the removed `renderMode` property and type declarations are not used elsewhere in the codebase.

# Test: Search for the usage of the removed `renderMode` property and type declarations. Expect: No occurrences of the removed properties and types.
rg --type ts 'renderMode|GenerateHighlights|UpdateHighlights'

Length of output: 105511

@KelvinOm KelvinOm added skip-changelog Adding this label to a PR prevents it from being listed in the changelog skip-docs skip-testPlan Does not require QA intervention or approval process skip-documentation To avoid commenting the reminder about the documentation update. ok-to-test Required label for CI labels May 14, 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 May 14, 2024
position?: PositionValues;
gap?: Responsive<SpacingDimension>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All this we have in FlexProps type.

@@ -160,7 +121,7 @@ export const FlexLayout = React.memo((props: FlexLayoutProps) => {
? { background: "var(--anvil-cell-highlight)" }
: {}),
};
}, [border, isDropTarget, position, renderMode, shouldHighlightCell]);
Copy link
Collaborator Author

@KelvinOm KelvinOm May 14, 2024

Choose a reason for hiding this comment

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

We don't use border and renderMode in this useMemo.

@@ -31,72 +23,18 @@ import { RenderModes } from "constants/WidgetConstants";
* Each alignment has following characteristics:
* 1. Mobile viewport:
* - flex-wrap: wrap.
* - flex-basis: auto.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed flex-basis to 0% for mobile because I believe it's wrong. With auto the container with the component takes more space and the grid breaks.
May-14-2024 19-18-13

@@ -152,54 +90,48 @@ const AlignedWidgetRowComp = (props: LayoutComponentProps) => {
// WDS Flex can be used as a replacement.
return (
<>
{isStartVisible() && (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was a bad idea, brings less benefit than problems. I'm deleting it.

@@ -140,19 +138,6 @@ export interface DraggedWidget {
widgetId: string;
}

export type GenerateHighlights = (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not used anywhere

@@ -202,14 +187,3 @@ export interface HighlightPayload {
highlights: AnvilHighlightInfo[];
skipEntity: boolean;
}

export type UpdateHighlights = (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not used anywhere

@KelvinOm KelvinOm added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels May 14, 2024
Copy link
Contributor

@riodeuno riodeuno left a comment

Choose a reason for hiding this comment

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

@KelvinOm thanks for reviewing the layout code and reducing the code. It should be more maintainable now.

@KelvinOm KelvinOm merged commit c4a63d7 into release May 15, 2024
42 checks passed
@KelvinOm KelvinOm deleted the fix/anvil-layout branch May 15, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI skip-docs skip-documentation To avoid commenting the reminder about the documentation update. skip-testPlan Does not require QA intervention or approval process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants