-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix: workflow js func rename code split #34512
Conversation
WalkthroughA Changes
Assessment against linked issues
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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 (6)
app/client/src/ce/api/JSActionAPI.tsx (1)
Line range hint
65-190
: Consider refactoring theJSActionAPI
class.The class consists only of static methods, which suggests it could instead be a module of standalone functions. This would simplify the structure and potentially improve modularity and testability.
- class JSActionAPI extends API { + // Functions moved out of JSActionAPI class + const url = "v1/collections/actions"; + function fetchJSCollections(payload: FetchActionsPayload): Promise<AxiosPromise<ApiResponse<JSCollection[]>>> { + return API.get(url, payload); + } // Add similar transformations for all other methodsapp/client/src/utils/JSPaneUtils.tsx (2)
Line range hint
152-152
: Remove redundant double-negation.The use of double-negation here is unnecessary and can be simplified.
- if (!!existedVar) { + if (existedVar) {
Line range hint
157-157
: Implement optional chaining.This change simplifies the code by safely accessing nested properties.
- existedValue.toString() !== (newVar.value && newVar.value.toString()) + existedValue.toString() !== newVar.value?.toString()app/client/src/sagas/JSPaneSagas.ts (3)
Line range hint
185-199
: Generator function withoutyield
.This generator function is expected to contain
yield
statements to handle asynchronous operations properly. If it's intended to be synchronous, consider converting it to a regular function.- function* handleJSObjectNameChangeSuccessSaga(action: ReduxAction<{ actionId: string }>) { + function handleJSObjectNameChangeSuccessSaga(action: ReduxAction<{ actionId: string }>) {
Line range hint
327-327
: Implement optional chaining for safer property access.This change will prevent potential runtime errors when accessing properties on potentially undefined objects.
- const isValidResponse: boolean = yield validateResponse(response); + const isValidResponse: boolean = yield validateResponse(response?);Also applies to: 334-334
Line range hint
464-464
: Remove unnecessary double-negation.Simplify the condition checks by removing redundant double-negation.
- if (!!collection.isMainJSCollection) + if (collection.isMainJSCollection)Also applies to: 505-505
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- app/client/src/ce/api/JSActionAPI.tsx (1 hunks)
- app/client/src/sagas/JSPaneSagas.ts (1 hunks)
- app/client/src/utils/JSPaneUtils.tsx (2 hunks)
Additional context used
Biome
app/client/src/ce/api/JSActionAPI.tsx
[error] 65-190: Avoid classes that contain only static members. (lint/complexity/noStaticOnlyClass)
Prefer using simple functions instead of classes with only static members.
app/client/src/utils/JSPaneUtils.tsx
[error] 152-152: 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
[error] 157-157: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
app/client/src/sagas/JSPaneSagas.ts
[error] 185-199: This generator function doesn't contain yield. (lint/correctness/useYield)
[error] 327-327: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 334-334: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 464-464: 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
[error] 505-505: 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
Additional comments not posted (4)
app/client/src/ce/api/JSActionAPI.tsx (1)
55-55
: Addition ofworkflowId
toRefactorAction
interface.This new optional field appears to be well-integrated with the existing fields and follows the optional chaining pattern used throughout the interface. This should facilitate handling scenarios where the workflow ID is not applicable or unavailable.
app/client/src/utils/JSPaneUtils.tsx (2)
34-34
: Addition ofworkflowId
tonameChangedActions
structure.The addition of the
workflowId
field here aligns with the changes in other parts of the codebase to support workflow-specific functionalities. This should help in tracking and managing actions specific to different workflows effectively.
108-108
: Proper propagation ofworkflowId
ingetDifferenceInJSCollection
.This change ensures that the
workflowId
is correctly maintained across renames within the JS collections, which is crucial for maintaining consistency in workflow-related features.
[APROVED]app/client/src/sagas/JSPaneSagas.ts (1)
220-220
: Handling ofworkflowId
inhandleEachUpdateJSCollection
.The inclusion of
workflowId
in the update logic ensures that workflow-specific information is preserved during collection updates, aligning with the overall feature enhancement.
There was a problem hiding this 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
Files selected for processing (1)
- app/client/src/utils/JSPaneUtils.test.ts (1 hunks)
Additional comments not posted (9)
app/client/src/utils/JSPaneUtils.test.ts (9)
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.Verification successful
The
workflowId
field is appropriately tested.The
workflowId
field is present in thegetDifferenceInJSCollection
function and is included in the test data withinJSPaneUtils.test.ts
, ensuring it is tested correctly.
app/client/src/utils/JSPaneUtils.tsx
:workflowId
is used within thegetDifferenceInJSCollection
function.app/client/src/utils/JSPaneUtils.test.ts
:workflowId
is part of the test data.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if `workflowId` is used in the function `getDifferenceInJSCollection`. # Test: Search for the function implementation. Expect: Usage of `workflowId`. ast-grep --lang javascript --pattern $'function getDifferenceInJSCollection($_, $_) { $$$ workflowId($_) $$$ }'Length of output: 118
Script:
#!/bin/bash # Locate the definition of the function `getDifferenceInJSCollection` ast-grep --lang javascript --pattern 'function getDifferenceInJSCollection($_, $_) { $$$ }' # Check for `workflowId` usage within the located function # First, find the file containing the function definition function_file=$(ast-grep --lang javascript --pattern 'function getDifferenceInJSCollection($_, $_) { $$$ }' --json | jq -r '.[0].path') # Then, search for `workflowId` within that file if [ -n "$function_file" ]; then rg --context 5 'workflowId' $function_file fiLength of output: 333
Script:
#!/bin/bash # Search for `workflowId` usage across the entire codebase rg --context 5 'workflowId'Length of output: 28331
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.Verification successful
The
workflowId
field is appropriately tested.The
workflowId
field is included in the test setup inapp/client/src/utils/JSPaneUtils.test.ts
at line 302, ensuring it is considered in the test scenarios.
app/client/src/utils/JSPaneUtils.test.ts
line 302:workflowId: undefined,
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if `workflowId` is used in the function `getDifferenceInJSCollection`. # Test: Search for the function implementation. Expect: Usage of `workflowId`. ast-grep --lang javascript --pattern $'function getDifferenceInJSCollection($_, $_) { $$$ workflowId($_) $$$ }'Length of output: 118
Script:
#!/bin/bash # Locate the implementation of the function `getDifferenceInJSCollection` ast-grep --lang javascript --pattern 'function getDifferenceInJSCollection($_, $_)' > /tmp/getDifferenceInJSCollection_locations.txt # Extract the file paths from the search results file_paths=$(awk -F':' '{print $1}' /tmp/getDifferenceInJSCollection_locations.txt | sort | uniq) # Check if `workflowId` is referenced in the files containing `getDifferenceInJSCollection` for file in $file_paths; do echo "Checking file: $file" grep -n 'workflowId' "$file" doneLength of output: 531
Script:
#!/bin/bash # Locate the implementation of the function `getDifferenceInJSCollection` using a refined pattern ast-grep --lang javascript --pattern 'function getDifferenceInJSCollection' > /tmp/getDifferenceInJSCollection_locations.txt # Extract the file paths from the search results file_paths=$(awk -F':' '{print $1}' /tmp/getDifferenceInJSCollection_locations.txt | sort | uniq) # Check if `workflowId` is referenced in the files containing `getDifferenceInJSCollection` for file in $file_paths; do echo "Checking file: $file" grep -n 'workflowId' "$file" doneLength of output: 523
Script:
#!/bin/bash # Locate the implementation of the function `getDifferenceInJSCollection` using ripgrep rg 'function getDifferenceInJSCollection' > /tmp/getDifferenceInJSCollection_locations.txt # Extract the file paths from the search results file_paths=$(awk -F':' '{print $1}' /tmp/getDifferenceInJSCollection_locations.txt | sort | uniq) # Check if `workflowId` is referenced in the files containing `getDifferenceInJSCollection` for file in $file_paths; do echo "Checking file: $file" grep -n 'workflowId' "$file" doneLength of output: 144
Script:
#!/bin/bash # Search for any occurrences of `getDifferenceInJSCollection` in the codebase rg 'getDifferenceInJSCollection' > /tmp/getDifferenceInJSCollection_occurrences.txt # Extract the file paths from the search results file_paths=$(awk -F':' '{print $1}' /tmp/getDifferenceInJSCollection_occurrences.txt | sort | uniq) # Check if `workflowId` is referenced in the files containing occurrences of `getDifferenceInJSCollection` for file in $file_paths; do echo "Checking file: $file" grep -n 'workflowId' "$file" doneLength of output: 1037
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
302-302
: Ensure theworkflowId
field is appropriately tested.The
workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
@@ -299,6 +299,7 @@ const resultRenamedActions = { | |||
id: "fun1", | |||
collectionId: "1234", | |||
moduleId: undefined, | |||
workflowId: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Ensure the workflowId
field is appropriately tested.
The workflowId
field is currently set to undefined
in the test file JSPaneUtils.test.ts
. To ensure comprehensive testing, please update the test cases to include meaningful values for workflowId
and validate its handling within the function.
app/client/src/utils/JSPaneUtils.test.ts
: Update test cases to include meaningful values forworkflowId
.
Analysis chain
Ensure the workflowId
field is appropriately tested.
The workflowId
field has been added to various data structures as per the PR description, but it is not clear if this field is being tested or used appropriately in this test scenario.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify if `workflowId` is used in the function `getDifferenceInJSCollection`.
# Test: Search for the function implementation. Expect: Usage of `workflowId`.
ast-grep --lang javascript --pattern $'function getDifferenceInJSCollection($_, $_) {
$$$
workflowId($_)
$$$
}'
Length of output: 118
Script:
#!/bin/bash
# Description: Search for the implementation of the function `getDifferenceInJSCollection` and inspect its contents.
# Search for the function implementation
ast-grep --lang javascript --pattern 'function getDifferenceInJSCollection($_, $_) {
$$$
}'
Length of output: 95
Script:
#!/bin/bash
# Description: Search for the function name `getDifferenceInJSCollection` across the entire codebase.
# Search for the function name
rg 'getDifferenceInJSCollection'
Length of output: 1190
Script:
#!/bin/bash
# Description: Extract the implementation of the function `getDifferenceInJSCollection` from `JSPaneUtils.tsx` and inspect its contents for `workflowId`.
# Extract the function implementation
ast-grep --lang typescript --pattern 'export const getDifferenceInJSCollection = ($_$) => {
$$$
}' -- 'app/client/src/utils/JSPaneUtils.tsx'
Length of output: 142
Script:
#!/bin/bash
# Description: Extract lines containing `getDifferenceInJSCollection` from `JSPaneUtils.tsx` to inspect its implementation.
# Extract the function definition and its implementation
rg -A 20 'export const getDifferenceInJSCollection' app/client/src/utils/JSPaneUtils.tsx
Length of output: 1035
Script:
#!/bin/bash
# Description: Extract additional lines containing `getDifferenceInJSCollection` from `JSPaneUtils.tsx` to capture the complete implementation.
# Extract the function definition and its implementation with more lines
rg -A 50 'export const getDifferenceInJSCollection' app/client/src/utils/JSPaneUtils.tsx
Length of output: 2000
Script:
#!/bin/bash
# Description: Extract additional lines containing `getDifferenceInJSCollection` from `JSPaneUtils.tsx` to capture the complete implementation.
# Extract the function definition and its implementation with even more lines
rg -A 100 'export const getDifferenceInJSCollection' app/client/src/utils/JSPaneUtils.tsx
Length of output: 3628
Script:
#!/bin/bash
# Description: Search for the usage of `workflowId` in `JSPaneUtils.test.ts` to confirm it is included in the test data and assertions.
# Search for `workflowId` in the test file
rg 'workflowId' app/client/src/utils/JSPaneUtils.test.ts
Length of output: 85
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
## Description This is a code split PR for [EE change](https://github.com/appsmithorg/appsmith-ee/pull/4536) which fixes rename of functions inside of a js object. Fixes [appsmithorg#34470](appsmithorg#34470) ## Automation /test sanity ### 🔍 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/9690260557> > Commit: 6da583f > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9690260557&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` <!-- 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** - Added an optional `workflowId` field to enhance the functionality of JavaScript actions and workflows. - **Tests** - Updated tests to include the new `workflowId` field. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
This is a code split PR for EE change which fixes rename of functions inside of a js object.
Fixes #34470
Automation
/test sanity
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9690260557
Commit: 6da583f
Cypress dashboard.
Tags:
@tag.Sanity
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
workflowId
field to enhance the functionality of JavaScript actions and workflows.Tests
workflowId
field.