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

[Nu-1882] change parameter parameter list item labels #7171

Merged

Conversation

Dzuming
Copy link
Contributor

@Dzuming Dzuming commented Nov 19, 2024

Describe your changes

  • Any values with suggestion
image
  • Fixed list
image

Checklist before merge

  • Related issue ID is placed at the beginning of PR title in [brackets] (can be GH issue or Nu Jira issue)
  • Code is cleaned from temporary changes and commented out lines
  • Parts of the code that are not easy to understand are documented in the code
  • Changes are covered by automated tests
  • Showcase in dev-application.conf added to demonstrate the feature
  • Documentation added or updated
  • Added entry in Changelog.md describing the change from the perspective of a public distribution user
  • Added MigrationGuide.md entry in the appropriate subcategory if introducing a breaking change
  • Verify that PR will be squashed during merge

Summary by CodeRabbit

  • New Features

    • Enhanced user feedback for duplicate entries with updated error messages in the fragment modal.
    • Added customizable input labels for user-defined lists in the UI.
  • Bug Fixes

    • Improved validation and error handling for various input modes in the fragment feature.
  • Documentation

    • Updated test cases to ensure comprehensive coverage of edge cases and expected behaviors.

Copy link

coderabbitai bot commented Nov 19, 2024

Walkthrough

The pull request introduces modifications to the Cypress end-to-end tests for a fragment feature, enhancing validation and error handling for input parameters. It updates error messages and expands test cases to cover various input modes. Additionally, new props for customizable labels are added to components related to user-defined lists, improving user interface clarity. The changes maintain existing logic while enhancing the robustness and clarity of the tests and components involved.

Changes

File Change Summary
designer/client/cypress/e2e/fragment.cy.ts Updated Cypress tests for fragment feature, including error message changes and expanded test cases for input validation.
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/AnyValueWithSuggestionVariant.tsx Added userDefinedListInputLabel prop to FixedValuesSetting component for improved labeling.
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/FixedListVariant.tsx Added userDefinedListInputLabel prop to FixedValuesSetting component, allowing dynamic labeling.
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/FixedValuesSetting.tsx Introduced userDefinedListInputLabel property to FixedValuesSetting interface and updated function signature to include this new parameter.
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/UserDefinedListInput.tsx Added optional inputLabel property to Props interface, allowing customizable labels for the input field.

Possibly related PRs

  • Assign user friendly editor fix #7166: The changes in this PR involve enhancing the handling of UI source parameters, which may relate to the validation and error handling logic updates in the main PR's Cypress tests for the fragment feature, particularly in how user inputs are processed and validated.

Suggested labels

docs

Suggested reviewers

  • arkadius

🐰 In the meadow where rabbits play,
New labels hop in, brightening the day.
With tests that catch each little mistake,
Our fragment's strong, make no mistake!
So let’s celebrate with a joyful cheer,
For clearer inputs, the change is here! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b776b63 and 35d0157.

📒 Files selected for processing (1)
  • designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/UserDefinedListInput.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/UserDefinedListInput.tsx

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.

CodeRabbit Configuration 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 client client main fe ui labels Nov 19, 2024
Copy link

@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 (6)
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/FixedValuesSetting.tsx (1)

19-19: Consider making userDefinedListInputLabel optional

Making this a required prop might be a breaking change for existing implementations. Consider marking it as optional with ? unless it's absolutely necessary to have a label.

-    userDefinedListInputLabel: string;
+    userDefinedListInputLabel?: string;
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/FixedListVariant.tsx (1)

Line range hint 14-21: Add userDefinedListInputLabel to Props interface

The userDefinedListInputLabel prop is being passed to FixedValuesSetting but is not defined in the Props interface. This should be added to maintain type safety.

Apply this diff to fix the interface:

interface Props {
    item: FixedListParameterVariant;
    onChange: (path: string, value: onChangeType) => void;
    path: string;
    readOnly: boolean;
    variableTypes: VariableTypes;
    errors: NodeValidationError[];
+   userDefinedListInputLabel?: string;
}
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/AnyValueWithSuggestionVariant.tsx (1)

Line range hint 31-75: Consider component optimization opportunities.

While the component is well-structured, consider these improvements:

  1. Split the component into smaller sub-components for better maintainability (e.g., separate components for fixed values, initial value, hint text sections)
  2. Use React.memo or useMemo for performance optimization if the component re-renders frequently with the same props

Example refactor for splitting components:

// HintTextSection.tsx
const HintTextSection: React.FC<{
    hintText: string;
    onChange: (path: string, value: string) => void;
    path: string;
    readOnly: boolean;
}> = ({ hintText, onChange, path, readOnly }) => {
    const { t } = useTranslation();
    return (
        <FormControl>
            <SettingLabelStyled>{t("fragment.hintText", "Hint text:")}</SettingLabelStyled>
            <TextAreaNode
                value={hintText}
                onChange={(e) => onChange(`${path}.hintText`, e.currentTarget.value)}
                style={{ width: "70%" }}
                disabled={readOnly}
                className={nodeInput}
            />
        </FormControl>
    );
};
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/UserDefinedListInput.tsx (2)

171-171: Consider making the default label more generic

The current fallback uses "Add list item:" which might be too specific for a generic input label component. Consider using a more generic translation key and default text that better reflects the component's reusable nature.

-<SettingLabelStyled>{inputLabel || t("fragment.addListItem", "Add list item:")}</SettingLabelStyled>
+<SettingLabelStyled>{inputLabel || t("common.input.list.label", "List input:")}</SettingLabelStyled>

Line range hint 1-204: Consider enhancing TypeScript type safety

The component could benefit from stricter TypeScript type definitions:

  1. Consider using strict type checking for the validation errors
  2. Add proper typing for the AceEditor ref callback
  3. Define explicit return types for callbacks

Example improvements:

// Add explicit typing for validation errors
type ValidationError = {
    errorType: string;
    fieldName: FieldName;
    typ: string;
    description: string;
    message: string;
};

// Add proper typing for the AceEditor ref
const editorRef = (ref: AceEditor | null): void => {
    if (ref?.editor) {
        ref.editor.commands.addCommand(aceEditorEnterCommand);
    }
};

// Add return type for callbacks
const handleAddNewListItem = (): void => {
    // ... existing implementation
};
designer/client/cypress/e2e/fragment.cy.ts (1)

Line range hint 1-507: Consider improving test organization and maintainability

While the tests are comprehensive and well-written, consider these improvements to enhance maintainability:

  1. Break down the large test case into smaller, focused test cases using describe blocks
  2. Extract common setup steps into beforeEach hooks
  3. Consider using custom commands for repetitive UI interactions
  4. Add explicit wait conditions instead of force-clicking elements

Example refactor for better test organization:

 describe("Fragment", () => {
+    describe("Input Parameters", () => {
+        beforeEach(() => {
+            cy.visitNewFragment(seed, "fragment");
+            cy.get("[model-id=input]").dblclick();
+        });
+
+        it("should handle String Any Value input mode", () => {
+            // Test specific to String Any Value
+        });
+
+        it("should handle String Any with Suggestion Value input mode", () => {
+            // Test specific to String Any with Suggestion
+        });
+    });
+
+    describe("Fragment Properties", () => {
+        // Group property-related tests
+    });
 });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 74022e2 and b776b63.

📒 Files selected for processing (5)
  • designer/client/cypress/e2e/fragment.cy.ts (1 hunks)
  • designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/AnyValueWithSuggestionVariant.tsx (1 hunks)
  • designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/FixedListVariant.tsx (1 hunks)
  • designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/FixedValuesSetting.tsx (3 hunks)
  • designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/UserDefinedListInput.tsx (3 hunks)
🔇 Additional comments (7)
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/FixedValuesSetting.tsx (2)

34-34: LGTM!

The new parameter is correctly destructured and follows the existing code style.


52-52: Verify prop name consistency with UserDefinedListInput component

The prop name inputLabel differs from the parameter name userDefinedListInputLabel. Let's verify that the UserDefinedListInput component correctly accepts this prop.

✅ Verification successful

Prop name is correctly defined and used in UserDefinedListInput component

The inputLabel prop is properly defined as an optional prop in the Props interface and correctly used within the component. The code shows:

  • Props interface includes inputLabel?: string
  • Component destructures and uses the prop in the JSX
  • The prop is used as a fallback with the translation: {inputLabel || t("fragment.addListItem", "Add list item:")}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for UserDefinedListInput Props interface definition
ast-grep --pattern 'interface Props {
  $$$
  inputLabel$_
  $$$
}'

# Alternatively, search for the component definition
ast-grep --pattern 'function UserDefinedListInput($_) {
  $$$
}'

Length of output: 136


Script:

#!/bin/bash
# Let's try to find the UserDefinedListInput component file first
fd UserDefinedListInput

# Then search for prop definitions or usages with ripgrep for broader coverage
rg "UserDefinedListInput.*Props" -A 5
rg "interface.*Props.*UserDefinedListInput" -A 5

Length of output: 240


Script:

#!/bin/bash
# Now that we found the file, let's examine its contents
cat designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/UserDefinedListInput.tsx

Length of output: 8754

designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/FixedListVariant.tsx (1)

46-46: LGTM! Well-structured internationalization implementation.

The translation implementation follows best practices:

  • Uses a descriptive hierarchical key: fragment.userDefinedList.label.possibleValues
  • Provides a clear fallback text
  • Aligns with the PR objective of fixing parameter list item labels
designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/AnyValueWithSuggestionVariant.tsx (1)

47-47: LGTM! Verify translation key existence.

The addition of the internationalized label prop follows React best practices and improves UI clarity.

Let's verify the translation key exists and is consistent across the application:

designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/UserDefinedListInput.tsx (2)

30-30: LGTM! Props interface change is well-structured

The addition of the optional inputLabel prop follows TypeScript best practices and maintains backward compatibility.


43-43: LGTM! Parameter destructuring is consistent

The addition of inputLabel to the destructured parameters maintains code style consistency and aligns with the Props interface.

designer/client/cypress/e2e/fragment.cy.ts (1)

Line range hint 69-74: LGTM: Error message update maintains test coverage

The change from "Add list item" to "Suggested values" in the error message validation is consistent with the PR objectives to fix parameter list item labels. The test structure properly validates both the presence and content of the error message.

Let's verify the consistency of this error message across the codebase:

✅ Verification successful

The test update correctly reflects the UI label change

The change from "Add list item" to "Suggested values" in the test is consistent with the actual implementation. The new label is properly defined in the translation system and used in AnyValueWithSuggestionVariant component with the key fragment.userDefinedList.label.suggestedValues. The test correctly validates this UI element's visibility and content.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of the old and new error messages
# to ensure consistent messaging across the application

echo "Checking for old 'Add list item' message..."
rg -i "add list item" --type ts

echo "Checking for new 'Suggested values' message..."
rg -i "suggested values" --type ts

Length of output: 1306


Script:

#!/bin/bash
# Let's check the actual implementation to understand the context better
# and verify if the message change is intentional and consistent

# Check the implementation of AnyValueWithSuggestionVariant
ast-grep --pattern 'const AnyValueWithSuggestionVariant = $_'

# Check translation keys usage
rg -l "fragment\.userDefinedList\.label\.suggestedValues" --type ts

# Check if there are any other similar list-related components
fd UserDefinedList --type f --extension tsx --extension ts

Length of output: 19544

@Dzuming Dzuming changed the title [Nu-1882] fix parameter parameter list item labels [Nu-1882] change parameter parameter list item labels Nov 19, 2024
@Dzuming Dzuming requested a review from arkadius November 19, 2024 14:02
@Dzuming Dzuming requested a review from arkadius November 19, 2024 15:51
@Dzuming Dzuming merged commit 628a6a8 into release/1.18 Nov 20, 2024
14 checks passed
@Dzuming Dzuming deleted the NU-1882-fix-parameter-parameter-list-item-labels branch November 20, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client main fe ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants