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

chore: remove padding for anvil embed apps #37173

Merged
merged 2 commits into from
Nov 7, 2024
Merged

Conversation

KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented Oct 31, 2024

Description

I removed the styles from the DSL and changed the layout type for main container to LAYOUT_COLUMN.

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/11720581716
Commit: 4ccd877
Cypress dashboard.
Tags: @tag.All
Spec:


Thu, 07 Nov 2024 11:30:39 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced the MainCanvasWrapper component for dynamic styling based on URL parameters.
    • Added a new rendering behavior for the LayoutColumn component.
  • Improvements

    • Updated highlight derivation and layout type in the LayoutColumn component.
    • Simplified layout structure in the anvilDSLTransformer function.
    • Adjusted layout properties for better alignment and spacing in the LayoutColumn component.

Copy link
Contributor

coderabbitai bot commented Oct 31, 2024

Walkthrough

The pull request introduces modifications to the LayoutColumn class in LayoutColumn.tsx, including a change in the highlight derivation method and updates to layout types and properties. A new MainCanvasWrapper component is added to manage dynamic styling based on URL query parameters. Additionally, the anvilDSLTransformer function is updated to simplify the layout structure by removing certain properties. These changes affect the rendering behavior and layout management within the application.

Changes

File Change Summary
app/client/src/layoutSystems/anvil/layoutComponents/components/LayoutColumn.tsx - Updated highlight derivation method to deriveAlignedColumnHighlights.
- Changed layoutType from WIDGET_ROW to ALIGNED_WIDGET_ROW.
- Modified getFlexLayoutProps to remove alignSelf, add height as "100%", and introduce gap as "spacing-4".
- Added renderViewMode method to wrap children in MainCanvasWrapper.
app/client/src/layoutSystems/anvil/layoutComponents/components/MainCanvasWrapper.tsx - Introduced MainCanvasWrapper component to manage padding based on the "embed" query parameter.
app/client/src/layoutSystems/anvil/utils/AnvilDSLTransformer.ts - Changed layoutType from ALIGNED_LAYOUT_COLUMN to LAYOUT_COLUMN.
- Removed layoutStyle property from the layout object.

Possibly related PRs

Suggested labels

Task, Anvil Pod, Anvil team

Suggested reviewers

  • riodeuno
  • ApekshaBhosale

🎉 In the land of code where changes flow,
LayoutColumn shines with a new glow!
With MainCanvasWrapper to style and align,
The layout's refreshed, oh how divine!
Properties trimmed, and logic refined,
A cleaner structure, beautifully designed! 🌟


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@KelvinOm KelvinOm added the ok-to-test Required label for CI label Oct 31, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 31, 2024
import BaseLayoutComponent from "../BaseLayoutComponent";
import {
type DeriveHighlightsFn,
LayoutComponentTypes,
type LayoutProps,
} from "layoutSystems/anvil/utils/anvilTypes";
import type { FlexLayoutProps } from "./FlexLayout";
import { deriveColumnHighlights } from "layoutSystems/anvil/utils/layouts/highlights/columnHighlights";
import { MainCanvasWrapper } from "./MainCanvasWrapper";

class LayoutColumn extends BaseLayoutComponent {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@riodeuno This type has not been used anywhere. The same situation applies to many other types (we need to check this). In this PR, I use LayoutColumn type for the main container, since previously changes to ALIGNED_LAYOUT_COLUMN affected not only the main container but also the zones

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: 1

🧹 Outside diff range and nitpick comments (3)
app/client/src/layoutSystems/anvil/utils/AnvilDSLTransformer.ts (2)

Line range hint 1-11: Documentation needs update to reflect layout style changes.

The function's documentation should mention that layout styles (padding, etc.) are intentionally excluded for embed apps.

 /**
  * This function transforms a page's DSL to become compatible with the Anvil Layout system
  * Note: This also gets rid of any properties that are not needed for the Auto Layout system
+ * Note: Layout styles like padding are excluded for embed apps
  * @returns dsl: The transformed DSL
  */

Line range hint 12-35: Consider adding type safety for layout properties.

The layout object creation uses a fixed structure. Consider defining an interface for better type safety.

interface AnvilLayout {
  layoutId: string;
  layoutType: LayoutComponentTypes;
  layout: Array<any>;
  isDropTarget: boolean;
  isPermanent: boolean;
  childTemplate: {
    insertChild: boolean;
    isDropTarget: boolean;
    isPermanent: boolean;
    layout: Array<any>;
    layoutId: string;
    layoutType: LayoutComponentTypes;
    maxChildLimit: number;
  };
}
app/client/src/layoutSystems/anvil/layoutComponents/components/LayoutColumn.tsx (1)

38-44: LGTM: New view mode implementation

The MainCanvasWrapper integration aligns with the PR objective of removing padding for anvil embed apps.

Consider adding a brief JSDoc comment explaining the purpose of renderViewMode method.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ac9e101 and 6f241e1.

📒 Files selected for processing (3)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/LayoutColumn.tsx (2 hunks)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/MainCanvasWrapper.tsx (1 hunks)
  • app/client/src/layoutSystems/anvil/utils/AnvilDSLTransformer.ts (1 hunks)
🔇 Additional comments (7)
app/client/src/layoutSystems/anvil/layoutComponents/components/MainCanvasWrapper.tsx (2)

6-16: LGTM! Clean implementation of conditional padding based on embed status.

The component correctly implements the padding adjustment based on URL parameters while maintaining proper prop forwarding.


6-16: Verify test coverage for this component.

Since this component handles critical layout behavior, ensure it has proper test coverage for both embedded and non-embedded scenarios.

app/client/src/layoutSystems/anvil/utils/AnvilDSLTransformer.ts (1)

21-21: Verify the impact of changing layoutType to LAYOUT_COLUMN.

The change from ALIGNED_LAYOUT_COLUMN to LAYOUT_COLUMN could affect existing layouts.

app/client/src/layoutSystems/anvil/layoutComponents/components/LayoutColumn.tsx (4)

1-2: LGTM: Import change aligns with layout modifications


Line range hint 17-26: Verify widget row alignment compatibility

The change to ALIGNED_WIDGET_ROW should maintain compatibility with existing widget layouts.

#!/bin/bash
# Search for existing WIDGET_ROW usage
ast-grep --pattern 'layoutType: LayoutComponentTypes.WIDGET_ROW'

28-36: LGTM: Flex layout properties use design system tokens

The addition of height and gap properties improves layout consistency.

#!/bin/bash
# Verify spacing token usage across the codebase
rg "spacing-4" --type ts

15-15: Verify highlight behavior with aligned columns

The change from deriveColumnHighlights to deriveAlignedColumnHighlights may affect column highlighting behavior.

@riodeuno
Copy link
Contributor

riodeuno commented Nov 4, 2024

@KelvinOm These changes will not effect existing Anvil applications, or will they?
This is fine because we haven't released Anvil to users. I'm only sharing this so that we consider the fact that we may need migrations if we need to this again in the future.

@KelvinOm
Copy link
Collaborator Author

KelvinOm commented Nov 7, 2024

@KelvinOm These changes will not effect existing Anvil applications, or will they? This is fine because we haven't released Anvil to users. I'm only sharing this so that we consider the fact that we may need migrations if we need to this again in the future.

These changes should not affect existing apps. The embed check will not work for them.

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

🧹 Outside diff range and nitpick comments (1)
app/client/src/layoutSystems/anvil/layoutComponents/components/LayoutColumn.tsx (1)

32-33: Consider documenting the spacing constant.

The layout properties look good, but it would be helpful to document where the "spacing-4" constant is defined.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f15d543 and 4ccd877.

📒 Files selected for processing (3)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/LayoutColumn.tsx (2 hunks)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/MainCanvasWrapper.tsx (1 hunks)
  • app/client/src/layoutSystems/anvil/utils/AnvilDSLTransformer.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/src/layoutSystems/anvil/layoutComponents/components/MainCanvasWrapper.tsx
  • app/client/src/layoutSystems/anvil/utils/AnvilDSLTransformer.ts
🔇 Additional comments (3)
app/client/src/layoutSystems/anvil/layoutComponents/components/LayoutColumn.tsx (3)

24-24: LGTM! Layout type change aligns with container modifications.

The switch to ALIGNED_WIDGET_ROW is consistent with the container-specific changes mentioned in the previous discussion.


38-44: Verify MainCanvasWrapper's padding behavior in embed mode.

The new render method looks good, but given the failing Cypress tests and the PR's objective to remove padding, we should verify the wrapper's behavior.

#!/bin/bash
# Check MainCanvasWrapper implementation for padding logic
rg -A 5 "MainCanvasWrapper" --type tsx

# Check for related test files
fd -e spec.tsx -e spec.ts "MainCanvasWrapper"

1-2: LGTM! Verify impact on existing highlight behavior.

The switch to aligned column highlights is consistent with the layout changes.

✅ Verification successful

Import change is safe and consistent with codebase patterns

Both highlight derivation methods coexist in the codebase with clear separation of concerns:

  • deriveColumnHighlights is used by WidgetColumn
  • deriveAlignedColumnHighlights is used by LayoutColumn, AlignedLayoutColumn, and AlignedWidgetColumn
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any other uses of the old highlight derivation
rg "deriveColumnHighlights" --type ts

Length of output: 112


Script:

#!/bin/bash
# Search for both old and new highlight derivation methods
rg "derive.*ColumnHighlights" --type typescript -A 3

# Search for files containing Column highlights
fd -e ts -e tsx . | xargs rg "Column.*Highlights"

# Check imports in layout related files
fd -e ts -e tsx "Layout.*" | xargs rg "^import.*Highlights"

Length of output: 5632

@KelvinOm KelvinOm merged commit 1f25adc into release Nov 7, 2024
83 checks passed
@KelvinOm KelvinOm deleted the chore/anvil-embed branch November 7, 2024 12:19
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
## Description
I removed the styles from the DSL and changed the layout type for main
container to `LAYOUT_COLUMN`.

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11720581716>
> Commit: 4ccd877
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11720581716&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Thu, 07 Nov 2024 11:30:39 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced the `MainCanvasWrapper` component for dynamic styling based
on URL parameters.
	- Added a new rendering behavior for the `LayoutColumn` component.

- **Improvements**
- Updated highlight derivation and layout type in the `LayoutColumn`
component.
	- Simplified layout structure in the `anvilDSLTransformer` function.
- Adjusted layout properties for better alignment and spacing in the
`LayoutColumn` component.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants