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 empty canvas prompts and improve widget editor header #33993

Merged
merged 5 commits into from
Jun 6, 2024

Conversation

rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Jun 5, 2024

Description

We want drag and drop of building blocks to be the main way of accelarating UI development. This PR removes empty canvas prompts for Start from template and Generate CRUD

Fixes #33874
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.Sanity, @tag.Templates"

🔍 Cypress test results

Tip

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

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • Improved the stability and accuracy of forking templates into existing apps connected to Git.
  • Refactor

    • Streamlined import order and removed unused imports in the Widget Editor Header.
    • Simplified logic and removed redundant conditions for rendering elements in the Widget Editor Header.
    • Updated Cypress tests to use custom functions and helper methods for better readability and maintainability.
  • Chores

    • Removed obsolete constants related to template card titles and page generation messages.

@rahulbarwal rahulbarwal requested review from a team and riodeuno and removed request for a team June 5, 2024 10:28
@rahulbarwal rahulbarwal self-assigned this Jun 5, 2024
@rahulbarwal rahulbarwal requested review from jacquesikot and removed request for riodeuno June 5, 2024 10:28
@rahulbarwal rahulbarwal added Templates Product Issues related to Templates Templates labels Jun 5, 2024
Copy link
Contributor

coderabbitai bot commented Jun 5, 2024

Walkthrough

The recent changes primarily involve the removal of template-related prompts, titles, and descriptions from the user interface in the messages.ts file. Additionally, the WidgetEditorHeader.tsx file has been simplified by removing unused imports and logic. Cypress test scripts have been updated to replace certain commands with custom functions for better maintainability.

Changes

Files Change Summary
app/client/src/ce/constants/messages.ts Removed functions and constants related to template card titles, descriptions, and page generation messages.
app/client/src/pages/Editor/WidgetsEditor/WidgetEditorHeader.tsx Reordered imports, removed unused imports and references, and eliminated logic related to isAppSettingsPaneWithNavigationTabOpen and isPreviewMode.
app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js Replaced Cypress commands with custom functions and helper methods for interacting with elements on the page.
app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_To_App_spec.ts Updated test case to replace a method call with a new method call for adding selected pages from a template to an app.

Assessment against linked issues

Objective Addressed Explanation
Remove the start from templates and generate CRUD page prompts from the first page of any new app (#33874)
Ensure Cypress tests use custom functions for interacting with elements on the page (#33874)

Poem

In the code, changes sweep,
Templates bid their quiet sleep.
Widget headers now so neat,
Cypress scripts with custom beat.
Bugs and clutter, take your leave,
In this code, we do believe.
🐇✨


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.
    • @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 as 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.

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 Task A simple Todo label Jun 5, 2024
@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label Jun 5, 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 Jun 5, 2024
@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Jun 5, 2024

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

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 5, 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

Outside diff range and nitpick comments (1)
app/client/src/ce/constants/messages.ts (1)

Line range hint 1133-1133: Consider simplifying the double-negation in the boolean expression.

The use of double-negation (!!) is unnecessary when the value will already be coerced to a boolean. Simplifying this can improve code readability. Here's a suggested change:

- !!someVariable
+ Boolean(someVariable)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6ebb017 and 4302d10.

Files selected for processing (2)
  • app/client/src/ce/constants/messages.ts (2 hunks)
  • app/client/src/pages/Editor/WidgetsEditor/WidgetEditorHeader.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/pages/Editor/WidgetsEditor/WidgetEditorHeader.tsx
Additional context used
Biome
app/client/src/ce/constants/messages.ts

[error] 1133-1133: Avoid redundant double-negation. (lint/complexity/noExtraBooleanCast)

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 5, 2024
Copy link

github-actions bot commented Jun 5, 2024

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

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 5, 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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4302d10 and 846e3c0.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js (1 hunks)
  • app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_To_App_spec.ts (1 hunks)
Additional context used
Biome
app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js

[error] 34-59: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 61-97: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

Additional comments not posted (1)
app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_To_App_spec.ts (1)

36-36: LGTM! The update to use PageList.AddNewPage aligns with the new approach for adding pages from a template.

Comment on lines 35 to 38
PageList.AddNewPage("Add page from template");
agHelper.AssertElementExist(template.templateDialogBox);
_.agHelper.GetNClick(template.templateCard).first();
_.agHelper.GetNClick(template.templateViewForkButton);
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 5, 2024

Choose a reason for hiding this comment

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

The updates to use custom functions and helper methods enhance the interaction with page elements. Consider converting these function expressions to arrow functions for better readability and consistency.

- function () {
+ () => {

Committable suggestion was skipped due to low confidence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@coderabbitai I don't understand this. Can you explain more?

Copy link
Contributor

Choose a reason for hiding this comment

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

@rahulbarwal, I suggested converting function expressions to arrow functions primarily for syntactic cleanliness and consistency. Arrow functions offer a more concise syntax and do not have their own this context, which can simplify code, especially when dealing with nested functions.

However, in the context of Cypress tests, it's important to note that using arrow functions might not always be appropriate. Cypress uses the function() syntax for test callbacks to bind its own context (like this.timeout or this.retries) to these functions. Using arrow functions, which don't bind their own this, could potentially lead to issues if you rely on Cypress's custom context.

Therefore, while arrow functions are generally a good practice for cleaner and more concise code, they should be used cautiously within Cypress tests where traditional function expressions might be necessary to access Cypress-specific features tied to this. I hope this clarifies the suggestion! If you have any more questions or need further assistance, feel free to ask.


Learnings used
User: dipyamanbiswas07
PR: appsmithorg/appsmith#29282
File: app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js:11-17
Timestamp: 2024-01-09T08:39:59.723Z
Learning: The user has clarified that intercepts are called in end-to-end tests, and therefore resetting the feature flag in an `afterEach` hook is not required in their test setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@coderabbitai I still don't see where is the opportunity to replace the function expression to arrow function.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rahulbarwal, thank you for your patience. Upon reviewing the context of the Cypress tests in the file ForkTemplateToGitConnectedApp.js, I realize that the suggestion to convert function expressions to arrow functions was not appropriate.

In Cypress, it's recommended to use traditional function expressions for test definitions (it blocks). This is because Cypress extends the function's this context with its own set of properties and methods (like this.timeout or this.retries). Arrow functions, which do not have their own this context, would not be able to access these Cypress-specific features, potentially leading to issues in your tests.

Therefore, in the context of your Cypress tests, it's best to continue using function expressions as you currently are. The initial suggestion was more of a general coding practice and didn't account for the specific requirements and recommendations of writing Cypress tests. I appreciate your diligence in seeking clarification on this! If there's anything else you need, feel free to ask.


Learnings used
User: dipyamanbiswas07
PR: appsmithorg/appsmith#29282
File: app/client/cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js:11-17
Timestamp: 2024-01-09T08:39:59.723Z
Learning: The user has clarified that intercepts are called in end-to-end tests, and therefore resetting the feature flag in an `afterEach` hook is not required in their test setup.

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 6, 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 846e3c0 and 449f19a.

Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js (1 hunks)
Additional context used
Biome
app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js

[error] 34-59: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 61-97: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

Additional comments not posted (2)
app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js (2)

35-38: The updates to use custom functions and helper methods enhance the interaction with page elements.

This change should make the tests more maintainable and less susceptible to break due to UI changes.


35-38: Refactor function expressions to arrow functions for consistency and readability.

- function () {
+ () => {

This change aligns with modern JavaScript practices and enhances the readability of the code.

Likely invalid or redundant comment.

@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 6, 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

Outside diff range and nitpick comments (1)
app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js (1)

35-38: Consider removing commented-out code for clarity and maintainability.

Removing unused code helps keep the codebase clean and maintainable. If the commented-out assertions are no longer needed, it would be best to remove them.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 449f19a and 5863f53.

Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js (1 hunks)
Additional context used
Biome
app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js

[error] 34-59: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 61-97: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

Additional comments not posted (2)
app/client/cypress/e2e/Regression/ClientSide/Templates/ForkTemplateToGitConnectedApp.js (2)

Line range hint 61-97: LGTM! The use of custom helper methods enhances test maintainability.

The refactoring to use custom helper methods instead of direct Cypress commands improves the readability and maintainability of the test cases. Good job on these changes!


35-38: Refactor to use arrow functions for consistency and readability.

- function () {
+ () => {

This change aligns with best practices for Cypress tests where using traditional function expressions might be necessary to access Cypress-specific features tied to this. However, since these functions do not utilize this, converting them to arrow functions is safe and enhances readability.

Likely invalid or redundant comment.

@rahulbarwal rahulbarwal merged commit 8d0091e into release Jun 6, 2024
45 checks passed
@rahulbarwal rahulbarwal deleted the chore-33874/remove-empty-canvas-prompts branch June 6, 2024 08:59
rahulbarwal added a commit that referenced this pull request Jun 6, 2024
rahulbarwal added a commit that referenced this pull request Jun 7, 2024
…34037)

## Description
This PR fixes impact of
#33993

Refactors visual regression tests to use PageList for page generation;
remove obsolete empty canvas spec and related selectors.
* Removed unncessary:
`cypress/e2e/Regression/ClientSide/OtherUIFeatures/EmptyCanvas_spec.js`
* Fixes
`cypress/e2e/Regression/ClientSide/VisualTests/AppPageLayout_spec.js`

**RCA:**
The [original PR](#33993)
catered to removal of empty canvas prompts and visual tests were not run
leading to subsequent failures in the CI for EmptyCanvas_spec &
AppPageLayout_spec.

This PR caters to failing visual tests, while running `@tag.Visual` we
noticed that other (unrelated) visual specs started failing. These new
failures fail in local as well.
Whereas they were not failing in TBP or `@tag.All` runs and `@tag.All`
succeeded for this PR as well.

Fixes #33874
_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
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9413838227>
> Commit: b6d7f60
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9413838227&attempt=2"
target="_blank">Click here!</a>

<!-- 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

- **Refactor**
- Updated method call for adding a new page in visual regression tests
to improve code clarity and maintainability.

- **Chores**
  - Removed unused locators and declarations to clean up the codebase.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com>
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 Task A simple Todo Templates Product Issues related to Templates
Projects
None yet
2 participants