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: disable create js object option in workflows editor #36094

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

ayushpahwa
Copy link
Contributor

@ayushpahwa ayushpahwa commented Sep 3, 2024

Description

Workflows is not currently supporting multiple js objects. Hence, we need to disable the option for the workflows editor.

EE branch: https://github.com/appsmithorg/appsmith-ee/pull/5027

Fixes #32239

Automation

/test js

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10686636668
Commit: 5cb101f
Cypress dashboard.
Tags: @tag.JS
Spec:


Tue, 03 Sep 2024 16:45:16 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced logic for creating new JavaScript objects, preventing unnecessary additions in the workflow editor.
    • Introduced a function to determine if creating a new JavaScript object is allowed, improving user experience in the workflow editor.
    • Improved responsiveness of the Files component based on the parent entity type, allowing for context-sensitive behavior.
  • Bug Fixes

    • Addressed limitations in workflow runner support for multiple JavaScript objects.
  • Refactor

    • Simplified the onCreate function's dependencies for improved clarity and functionality.
  • Tests

    • Added new test cases to validate the behavior of JavaScript object creation options based on user settings.

Copy link
Contributor

coderabbitai bot commented Sep 3, 2024

Walkthrough

The changes made to the codebase focus on refining the handling of JavaScript objects within workflows. A conditional check was introduced to prevent the addition of a "create new JS object" operation when in the workflow editor. Additionally, modifications to the Files component's callback dependencies were made to enhance responsiveness to changes in the parent entity type, simplifying the function's execution context.

Changes

Files Change Summary
app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.tsx Added conditional logic to prevent adding a "create new JS object" operation in the workflow editor; imported checkIfJSObjectCreationAllowed.
app/client/src/pages/Editor/Explorer/Files/index.tsx Modified dependencies of useCallback hooks; removed dispatch from onCreate, and added parentEntityType to two callback dependencies.
app/client/src/ce/utils/workflowHelpers.ts Introduced checkIfJSObjectCreationAllowed function to determine if JS object creation is allowed in the workflow editor.
app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.test.ts Added tests for useFilteredAndSortedFileOperations to validate behavior with disableJSObjectCreation parameter.

Assessment against linked issues

Objective Addressed Explanation
Prevent workflow failure with extra JS object (Issue #32239)
Ensure correct handling of JS object creation in workflows

Poem

In workflows where objects may stray,
A check was placed to guide the way.
With callbacks tuned to parent’s call,
The code now dances, standing tall.
A smoother path for all to see,
In JavaScript's realm, we set it free! 🎉

Tip

We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.


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

@github-actions github-actions bot added Bug Something isn't working Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Production Workflows Pod Issues that the workflows team owns Workflows Product Issues related to the workflows product and removed Bug Something isn't working labels Sep 3, 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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6ad6a11 and fb21570.

Files selected for processing (2)
  • app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.tsx (2 hunks)
  • app/client/src/pages/Editor/Explorer/Files/index.tsx (3 hunks)
Additional comments not posted (5)
app/client/src/pages/Editor/Explorer/Files/index.tsx (3)

70-70: Good work simplifying the onCreate function's dependencies!

Removing the dispatch dependency from the onCreate function's dependency array is a positive change. It simplifies the function's behavior and execution context.


144-144: Nice job enhancing the component's responsiveness to parent entity type changes!

Including parentEntityType in the callback's dependency array is a good decision. It allows the component to respond appropriately to changes in the parent entity's type, improving its adaptability to different contexts.


164-164: Excellent work making the handleClick function responsive to parent entity type!

Adding parentEntityType to the handleClick function's dependency array is a smart move. It allows the function to adapt its behavior based on the parent entity's type, potentially altering the flow of actions triggered by user interactions in a context-sensitive manner.

app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.tsx (2)

42-42: Import statement looks good!

The import statement for urlBuilder and EDITOR_TYPE is necessary to support the new conditional logic. Well done!


131-137: Conditional block to disable "create new JS object" option in workflow editor looks good!

The new conditional block effectively addresses the current limitation where workflows do not support multiple JS objects. By checking if the user is in the workflow editor using urlBuilder.getDefaultEditorType() and only adding the "create new JS object" operation when not in the workflow editor, it prevents users from encountering errors when attempting to create additional JS objects.

The TODO comment serves as a helpful reminder to revisit this logic once workflows gain support for multiple JS objects. At that point, the conditional block can be removed to re-enable the "create new JS object" option in the workflow editor.

Great work on implementing this temporary workaround while clearly documenting the future enhancement!

@ayushpahwa ayushpahwa marked this pull request as draft September 3, 2024 15:40
@github-actions github-actions bot added the Bug Something isn't working label Sep 3, 2024
@ayushpahwa ayushpahwa added the ok-to-test Required label for CI label Sep 3, 2024
@ayushpahwa ayushpahwa changed the title update: disable create js object option in workflows editor feat: disable create js object option in workflows editor Sep 3, 2024
@github-actions github-actions bot added Enhancement New feature or request and removed Bug Something isn't working labels Sep 3, 2024
@ayushpahwa ayushpahwa marked this pull request as ready for review September 3, 2024 16:46
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Sep 3, 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, codebase verification and nitpick comments (2)
app/client/src/ce/utils/workflowHelpers.ts (1)

5-10: Excellent work on the checkIfJSObjectCreationAllowed function!

The function is correctly returning false to hide the option to create a new JavaScript object in the workflow editor. This is a good temporary solution until the workflow runner supports multiple JavaScript objects.

A few suggestions to consider:

  1. Consider adding a more descriptive comment explaining the rationale behind this function. For example:
// The current workflow runner does not support multiple JavaScript objects.
// Therefore, we hide the option to create a new JavaScript object in the workflow editor.
// TODO: Remove this function once the workflow runner supports multiple JavaScript objects.
  1. If possible, consider adding a feature flag to control this behavior. This will make it easier to enable/disable this feature in the future without modifying the code.

Overall, great job on implementing this function! Let me know if you have any questions or need further assistance.

app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.test.ts (1)

335-351: Consider removing this test case.

This test case is identical to the previous one, where disableJSObjectCreation is set to false. It verifies the same behavior and does not add any additional coverage.

To maintain a clean and concise test suite, it's best to remove redundant test cases. The behavior when disableJSObjectCreation is not explicitly set is already covered by the test case where it is set to false.

Apply this diff to remove the redundant test case:

-  it("should show new js object option if disableJSObjectCreation is not set", () => {
-    const fileOptions = useFilteredAndSortedFileOperations({
-      query: "new js",
-      allDatasources: [],
-      recentlyUsedDSMap: {},
-      canCreateActions: true,
-      canCreateDatasource: true,
-      disableJSObjectCreation: false,
-    });
-
-    expect(fileOptions.length).toEqual(2);
-    expect(fileOptions[0]).toEqual(
-      expect.objectContaining({
-        title: "New JS Object",
-      }),
-    );
-  });
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fb21570 and 5cb101f.

Files selected for processing (3)
  • app/client/src/ce/utils/workflowHelpers.ts (1 hunks)
  • app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.test.ts (1 hunks)
  • app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.tsx
Additional comments not posted (3)
app/client/src/ce/utils/workflowHelpers.ts (1)

1-2: Great job! The useWorkflowOptions function looks good.

The function is correctly returning an empty array as expected. Keep up the good work!

app/client/src/components/editorComponents/GlobalSearch/GlobalSearchHooks.test.ts (2)

299-315: Great job on this test case!

This test case effectively verifies that the "New JS Object" option is not shown when disableJSObjectCreation is set to true. It checks both the length of the returned array and the presence of the "New datasource" option.

Keep up the good work in ensuring the correct behavior of the useFilteredAndSortedFileOperations function under different conditions.


317-333: Excellent test case!

This test case complements the previous one by verifying that the "New JS Object" option is shown when disableJSObjectCreation is set to false. It checks both the length of the returned array and the presence of the "New JS Object" option.

Your test cases are covering the different scenarios effectively, ensuring the robustness of the useFilteredAndSortedFileOperations function.

Copy link
Contributor

@ankitakinger ankitakinger left a comment

Choose a reason for hiding this comment

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

LGTM

@ayushpahwa ayushpahwa merged commit 72d1815 into release Sep 4, 2024
52 checks passed
@ayushpahwa ayushpahwa deleted the fix/32239-workflows-disable-multiple-js-objects branch September 4, 2024 03:37
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
…g#36094)

## Description

Workflows is not currently supporting multiple js objects. Hence, we
need to disable the option for the workflows editor.

EE branch: https://github.com/appsmithorg/appsmith-ee/pull/5027

Fixes appsmithorg#32239 

## Automation

/test js

### 🔍 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/10686636668>
> Commit: 5cb101f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10686636668&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Tue, 03 Sep 2024 16:45:16 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**
- Enhanced logic for creating new JavaScript objects, preventing
unnecessary additions in the workflow editor.
- Introduced a function to determine if creating a new JavaScript object
is allowed, improving user experience in the workflow editor.
- Improved responsiveness of the Files component based on the parent
entity type, allowing for context-sensitive behavior.

- **Bug Fixes**
- Addressed limitations in workflow runner support for multiple
JavaScript objects.

- **Refactor**
- Simplified the `onCreate` function's dependencies for improved clarity
and functionality.
  
- **Tests**
- Added new test cases to validate the behavior of JavaScript object
creation options based on user settings.
<!-- 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
Enhancement New feature or request Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Workflows Pod Issues that the workflows team owns Workflows Product Issues related to the workflows product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Workflow with extra JS object other than Main is failing after execution start
2 participants