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

refactor: parameter component, edit node modal and api modal #2928

Merged
merged 89 commits into from
Jul 26, 2024

Conversation

lucaseduoli
Copy link
Collaborator

This pull request includes various code refactorings and bug fixes. It improves the overall code structure and resolves several issues. Some of the changes include:

  • Refactoring column definitions to receive handleOnNewValue and use it to change the Advanced variable

  • Exporting function isTargetHandleConnected

  • Refactoring types of setNodeClass

  • Exporting type of handleOnNewValue

  • Refactoring useHandleNodeClass to only handle changes to node data

  • Refactoring toggleCellRender to handle advanced values by itself with the handleOnNewValue

  • Changing setNodeClass types and disabling hook

  • Changing handleNodeClass on parametercomponent

  • Changing handleNodeClass on the two components that used it

  • Updating handleNodeClass to accept newNodeClass and type only

  • Refactoring EditNodeModal component to use new handleNodeClass and columnDefs

  • Changing columnDefs to receive new handleNodeClass and not receive useless parameters

  • Changing cellTypeStr to strRender

  • Refactoring inputFileComponent to use the new handleOnNewValue

  • Refactoring keypairList to convert values on the fly

  • Adding parameterRenderComponent that renders all parameters in one place

  • Exporting parameterRenderComponent

  • Changing tableNodeCellRender to use ParameterRenderComponent

  • Changing parameterredercomponent to receive name

  • Changing strrendercomponent to receive name

  • Changing nodecellrender to pass name and to check if value is undefined before assigning on templateData

  • Refactoring use-handle-new-value to handle undefined values in changes

  • Using ParameterRenderComponent at parameterComponent

  • Refactoring parameterRenderComponent to include refresh button

  • Creating refresh parameter component

  • Adding nodeId to parameterrendercomponent call

  • Removing unused variable

  • Refactoring refreshButton

  • Fixing parameters not showing when they don't have a value

  • Creating a tweakComponent that renders the tweak individually, with the same table as the EditNode

  • Creating tweaks component, that renders all tweaks

  • Changing tableNodeCellRender to pass setNode as well

  • Changing handleOnNewValue to use custom setNode if specified

  • Adding editNodeComponent that handles the table and rowData and columnDefs

  • Changing editNodeModal to use editNodeComponent instead of table

  • Changing columndefs type to handle setNode and hideVisibility optional parameters

  • Changing useRowData to not use myData, and just use nodeClass

  • Changing codeTabsPropsType tweaks property to include only the necessary

  • Changing codeTabsComponent to use TweaksComponent and handle an internal nodes state

  • Changing apiModal to handle the tweaks built by finding the differences between old and current node

  • Fixing bug on API modal that refreshes tweaks table all the time

  • Creating new tweaks store type

  • Adding tweaks store with all of the logic needed to get the tweaks on the API page

  • Refactoring TweakComponent to hold a temporary state to prevent the table from rerendering

  • Adding TweakComponent into TweaksComponent

  • Removing external state on tableAdvancedToggle, making every state come from the Stores

  • Removing external state from TableNodeCellRender and adding isTweaks to choose which store to use

  • Adding SetNode type on HandleOnNewValue

  • Adding custom setNode to handleNodeClass

  • Removing unused logic from apiModal

  • Removing unused old code

  • Changing type of getChangesTypes

  • Transforming string into object on get codes

  • Changing getNodesWithDefaultValue to return nodes that will appear on Tweaks, as well as just the allowed parameters

  • Adding hasTweaks to tabs

  • Adding check of template keys to update the local nodeClass state, allowing the table to be updated just when the number of parameters changes

  • Passing isTweaks to columnDefs

  • Removing unused state and passing isTweaks to value getters

  • Removing unused state

  • Updating tabsArrayType with hasTweaks and removing unused types

  • Adding local nodes tweaks state to the codetabscomponent and refactoring conditions of display

  • Removing unused console.log

  • Changing advanced toggle to use parameterid given by the value

  • Changing nodecellrender to use parameter id given by the value

  • Passing parameter id by value to the renderers

  • Removing nodeClass from columnDefs definition

  • Fixing isTargetHandleConnected returning error if field is undefined

  • Fixing performance issues on edit node modal

  • Fixing scroll overflow issues on tweaksComponent

These changes improve the code structure, fix bugs, and enhance the overall performance and user experience.

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 24, 2024
Copy link
Contributor

@anovazzi1 anovazzi1 left a comment

Choose a reason for hiding this comment

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

approve to run frontend tests

@@ -51,7 +60,7 @@ const useHandleOnNewValue = ({
if (!options?.skipSnapshot) takeSnapshot();

Object.entries(changes).forEach(([key, value]) => {
parameter[key] = value;
if (value !== undefined) parameter[key] = value;
Copy link
Contributor

Choose a reason for hiding this comment

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

why we need to check if the value is not undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there are some old components that the key returns an undefined value. The flow was braking, so I did that.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 24, 2024
@lucaseduoli lucaseduoli linked an issue Jul 24, 2024 that may be closed by this pull request
@anovazzi1 anovazzi1 self-requested a review July 24, 2024 21:10
@lucaseduoli lucaseduoli self-assigned this Jul 24, 2024
Cristhianzl and others added 12 commits July 25, 2024 18:40
…bility and accessibility.

✨ (Hierarchical Tasks Agent.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (Memory Chatbot.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (Sequential Tasks Agent.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-0.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-1.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-2.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update input list element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update prompt area element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (freeze-path.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-0.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-1.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-3.spec.ts): Update dropdown element IDs to improve clarity and consistency

🔧 (logs.spec.ts, textInputOutput.spec.ts): update dropdown test selectors to match changes in the frontend codebase
… descriptive test IDs for better clarity and maintainability

📝 (fileUploadComponent.spec.ts): Add explicit wait for "Run Flow" button to ensure it is loaded before clicking
📝 (folders.spec.ts): Update file path in readFileSync function to use an absolute path for better reliability
📝 (freeze-path.spec.ts): Refactor test code to remove commented out code and improve readability by using more descriptive test IDs and removing unnecessary code snippets

✨ (inputListComponent.spec.ts): Update test file to use consistent naming convention for input elements in the InputListComponent
📝 (intComponent.spec.ts): Refactor test file to use consistent naming convention for input elements in the IntComponent

✨ (nestedComponent.spec.ts): Update test steps and interactions for nestedComponent to improve test coverage and accuracy.

📝 (promptModalComponent.spec.ts): Update test selectors for prompt modal component to improve consistency and readability
📝 (textAreaModalComponent.spec.ts): Update test selectors for text area modal component to improve consistency and readability
📝 (toggleComponent.spec.ts): Update test selectors for toggle component to improve consistency and readability
…IntComponent

🐛 (intComponent.spec.ts): fix missing test step for clicking on a specific element in IntComponent test
…cessfully" text to improve test reliability and prevent false negatives
@lucaseduoli lucaseduoli merged commit a9863a0 into main Jul 26, 2024
51 checks passed
@lucaseduoli lucaseduoli deleted the refactor/parameter_components branch July 26, 2024 16:32
nicoloboschi pushed a commit to datastax/ragstack-ai-langflow that referenced this pull request Jul 30, 2024
…w-ai#2928)

* changed column defs to receive handleOnNewValue and use it to change Advanced variable

* Exported function isTargetHandleConnected

* Refactored types of setNodeClass

* Exported type of handleOnNewValue

* Refactored useHandleNodeClass to only handle changes to node data

* Refactored toggleCellRender to handle advanced values by itself with the handleOnNewValue

* changed setNodeClass types and disabled hook

* changed handleNodeClass on parametercomponent

* changed handleNodeClass on the two components that used it

* refactor: Update handleNodeClass to accept newNodeClass and type only

* Refactor EditNodeModal component to use new handleNodeClass and columnDefs

* Changed columnDefs to receive new handleNodeClass and not receive useless parameters

* changed cellTypeStr to strRender

* Refactored inputFileComponent to use the new handleOnNewValue

* Refactored keypairList to convert values on the fly

* added parameterRenderComponent that renders all parameters in one place

* Exported parameterRenderComponent

* Changed tableNodeCellRender to use ParameterRenderComponent

* changed parameterredercomponent to receive name

* changed strrendercomponent to receive name

* changed nodecellrender to pass name and to check if value is undefined before assigning on templateData

* chore: Refactor use-handle-new-value to handle undefined values in changes

* Used ParameterRenderComponent at parameterComponent

* Refactored parameterRenderComponent to include refresh button

* Created refresh parameter component

* Added nodeId to parameterrendercomponent call

* Removed unused variable

* Refactored refreshButton

* Fixed parameters not showing when they dont have a value

* Created a tweakComplnent that renders the tweak individually, with the same table as the EditNode

* Created tweaks component, that renders all tweaks

* Changed tableNodeCellRender to pass setNode as well

* changed handleOnNewValue to use custom setNode if specified

* added editNodeComponent that handles the table and rowData and columnDefs

* changed editNodeModal to use editNodeComponent instead of table

* changed columndefs type to handle setNode and hideVisibility optional parameters

* changed useRowData to not use myData, and just use nodeClass

* Changed codeTabsPropsType tweaks property to include only the ncessary

* changed codeTabsComponent to use TweaksComponent and handle an internal nodes state

* changed apiModal to handle the tweaks build by finding the differences between old and current node

* fix bug on API modal that refresh tweaks table all the time

* Created new tweaks store type

* Added tweaks store with all of the logic needed to get the tweaks on the API page

* refactored TweakComponent to hold an temporary state to prevent the table from rerendering

* Added TweakComponent into TweaksComponent

* Removed external state on tableAdvancedToggle, making every state come from the Stores

* Removed external state from TableNodeCellRender and added isTweaks to choose which store to use

* Added SetNode type on HandleOnNewValue

* Added custom setNode to handleNodeClass

* Removed unused logic from apiModal

* removed unused old code

* Changed type of getChangesTypes

* Transformed string into object on get codes

* Changed getNodesWithDefaultValue to return nodes that will appear on Tweaks, as well as just the allowed parameters

* added hasTweaks to tabs

* added check of template keys to update the local nodeClass state, allowing the table to be updated just when the number of parameters changes

* passed isTweaks to columnDefs

* removed unused state and passed isTweaks to value getters

* Removed unused state

* updated tabsArrayType with hasTweaks and removed unused types

* Added local nodes tweaks state to the codetabscomponent and refactored conditions of display

* removed unused console.log

* changed advanced toggle to use parameterid given by the value

* changed nodecellrender to use parameter id given by the value

* passed parameter id by value to the renderers

* removed nodeClass from columnDefs definition

* Fixed isTargetHandleConnected returning error if field is undefined

* Fix performance issues on edit node modal

* Fixed scroll overflow issues on tweaksComponent

* Revert "Revert "refactor: update template api, handleonnewvalue and handlenodeclass hooks (langflow-ai#2628)""

This reverts commit 236ae82.

* 📝 (tweaksTest.spec.ts): remove redundant code and improve readability by simplifying the interaction with elements in the test case

* added custom id for tests

* ✨ (frontend): Add unique id prop to input components for better testability and accessibility.

✨ (Hierarchical Tasks Agent.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (Memory Chatbot.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (Sequential Tasks Agent.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-0.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-1.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-2.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update input list element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update prompt area element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (freeze-path.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-0.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-1.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-3.spec.ts): Update dropdown element IDs to improve clarity and consistency

🔧 (logs.spec.ts, textInputOutput.spec.ts): update dropdown test selectors to match changes in the frontend codebase

* Fixed prompt not holding the value when validating

* Fixed range spec on int component

* Fixed OpenAI Model max tokens range spec

* ✨ (dropdownComponent.spec.ts): Update dropdown test cases to use more descriptive test IDs for better clarity and maintainability
📝 (fileUploadComponent.spec.ts): Add explicit wait for "Run Flow" button to ensure it is loaded before clicking
📝 (folders.spec.ts): Update file path in readFileSync function to use an absolute path for better reliability
📝 (freeze-path.spec.ts): Refactor test code to remove commented out code and improve readability by using more descriptive test IDs and removing unnecessary code snippets

✨ (inputListComponent.spec.ts): Update test file to use consistent naming convention for input elements in the InputListComponent
📝 (intComponent.spec.ts): Refactor test file to use consistent naming convention for input elements in the IntComponent

✨ (nestedComponent.spec.ts): Update test steps and interactions for nestedComponent to improve test coverage and accuracy.

📝 (promptModalComponent.spec.ts): Update test selectors for prompt modal component to improve consistency and readability
📝 (textAreaModalComponent.spec.ts): Update test selectors for text area modal component to improve consistency and readability
📝 (toggleComponent.spec.ts): Update test selectors for toggle component to improve consistency and readability

* 🐛 (intComponent.spec.ts): fix incorrect value comparison in test for IntComponent
🐛 (intComponent.spec.ts): fix missing test step for clicking on a specific element in IntComponent test

* 📝 (Vector Store.spec.ts): increase timeout for waiting for "built successfully" text to improve test reliability and prevent false negatives

* Fixed folders test

---------

Co-authored-by: anovazzi1 <[email protected]>
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
Co-authored-by: cristhianzl <[email protected]>
(cherry picked from commit a9863a0)
@edwinjosechittilappilly
Copy link
Collaborator

edwinjosechittilappilly commented Aug 13, 2024

So with this PR, Does Each component have tests?
Will it effect the way we design the custom components ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer refactor Maintenance tasks and housekeeping size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: parameter component
5 participants