Skip to content

Thulasizwe/en/tabed properties panel#3102

Merged
James-Baloyi merged 7 commits intoshesha-io:mainfrom
czwe-01:thulasizwe/en/tabed-properties-panel
Apr 2, 2025
Merged

Thulasizwe/en/tabed properties panel#3102
James-Baloyi merged 7 commits intoshesha-io:mainfrom
czwe-01:thulasizwe/en/tabed-properties-panel

Conversation

@czwe-01
Copy link
Copy Markdown
Collaborator

@czwe-01 czwe-01 commented Apr 2, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a mode toggle in the settings to switch easily between different view types.
    • Added new styles for button components to improve layout and text handling.
  • Refactor
    • Adjusted form field behavior to consistently use the read-only state for interactivity.
    • Simplified button rendering logic in the code editor component.
  • Style
    • Enhanced visual styling across components, including updated button icons and improved toolbar layouts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request modifies several components within the designer module. The updates alter property assignments in the FormItem component, introduce a mode-switch button with state logic in SettingsControl, adjust CSS styling in multiple files, and make minor syntax revisions to style objects and JSX. Additionally, button rendering in the CodeEditor component is simplified with updated icon usage.

Changes

File(s) Change Summary
.../components/formItem.tsx Modified the createClonedElement function to pass readOnly (and thus disabled) solely based on the readOnly prop, removing the previous logical OR with hasCode.
.../settingsControl.tsx Introduced a new Ant Design button and the onSwitchMode function to toggle between 'code' and 'value' modes; adjusted conditional rendering for the editor and value view.
.../styles/styles.ts
.../propertiesTabs/style.ts
Updated CSS: removed a scoped class selector, changed fixed top positioning, and introduced a new flex-based style block for toolbar buttons.
.../utils/border/utils.tsx Minor formatting changes: removed a blank line after an if statement and added a blank line before a variable declaration.
.../button/button.tsx Adjusted the object literal syntax in the Factory function by adding a comma after spreading jsStyle; no functional change.
.../codeEditor/codeEditor.tsx Simplified button JSX: removed the classNames utility and type prop, applied conditional monospace styling, altered content presentation, and replaced the icon from CodeFilled to CodeOutlined.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SettingsControl
  participant Editor
  participant ValueDisplay

  User->>SettingsControl: Click mode toggle button
  SettingsControl->>SettingsControl: Execute onSwitchMode()
  alt Mode is 'code'
    SettingsControl-->>Editor: Render Code Editor
  else Mode is 'value'
    SettingsControl-->>ValueDisplay: Render Value Container
  end
Loading

Suggested reviewers

  • James-Baloyi

Poem

Hop along in lines of code,
Tweaks and changes on the road.
Modes now switch with a simple click,
CSS refined, and syntax slick.
A happy tune from a rabbit so merry—
CodeRabbit hops in joy (🐇)!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3b5506 and 0c2bc8b.

📒 Files selected for processing (1)
  • shesha-reactjs/src/designer-components/_settings/styles/styles.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-test
🔇 Additional comments (3)
shesha-reactjs/src/designer-components/_settings/styles/styles.ts (3)

76-76: Fixed positioning replaced conditional logic

The top property for sidebar container has been changed from what was likely a conditional value (based on hasCode like in line 81) to a fixed value of -25px. This simplifies the layout but could potentially affect the component's appearance in different states.

Make sure this fixed value works properly in all scenarios where the sidebar container is used, especially when toggling between code and non-code views.


83-83: Minor formatting change

Added whitespace improves code readability.


3-3:

Details

❓ Verification inconclusive

Parameter removal impacts CSS class scoping

The prefixCls parameter has been removed from the function signature. This change suggests a shift away from prefix-based CSS class scoping, which could simplify the styling structure but might affect component styling specificity.


🏁 Script executed:

#!/bin/bash
# Search for any remaining references to prefixCls in components that might use these styles
rg -A 2 -B 2 "prefixCls.*styles" src/designer-components/_settings

Length of output: 142


Please verify CSS Class Scoping Update

The removal of the prefixCls parameter from the createStyles function in
shesha-reactjs/src/designer-components/_settings/styles/styles.ts appears intentional and aligns with an updated styling strategy. However, because the initial reference search used an incorrect directory (resulting in a “No such file or directory” error), please re-run the above command (or verify manually) within the correct path to ensure that no dependent components are left referencing prefixCls.

  • Action Required:
    • Ensure that any components previously relying on prefixCls have been updated accordingly for their CSS scoping.
    • Confirm that no residual references to prefixCls remain in the shesha-reactjs/src/designer-components tree.

🏁 Script executed:

#!/bin/bash
# Re-run search for any remaining references to 'prefixCls' in the designer-components
rg -A 2 -B 2 "prefixCls" shesha-reactjs/src/designer-components

Length of output: 264


Action: Verify Dependent Components’ CSS Scoping and Directory Structure

The removal of the prefixCls parameter in
shesha-reactjs/src/designer-components/_settings/styles/styles.ts
appears intentional, aligning with a new scoping strategy. However, our search for remaining references to prefixCls failed due to a directory error—indicating that the assumed path may be incorrect or that the component structure has been reorganized.

  • Next Steps:
    • Manually confirm the correct location of the designer components (e.g., search for the folder named “designer-components” or the file styles.ts) to verify that no dependent components still reference prefixCls.
    • Ensure that any components previously relying on the prefixCls parameter have been fully updated in the new styling approach.

Please verify the actual directory structure and dependent component usage to ensure a smooth transition with this change.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@czwe-01 czwe-01 requested a review from James-Baloyi April 2, 2025 15:13
Copy link
Copy Markdown
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

🧹 Nitpick comments (1)
shesha-reactjs/src/designer-components/_settings/utils/border/utils.tsx (1)

130-135: Remove redundant commented-out interface.

The commented-out IHideCornerConditions interface is already defined and used later in the file (lines 256-261). Commented code creates unnecessary noise and potential confusion.

-// interface IHideCornerConditions {
-//     topLeft?: string;
-//     topRight?: string;
-//     bottomLeft?: string;
-//     bottomRight?: string;
-// }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 695c2fe and 96238fa.

📒 Files selected for processing (7)
  • shesha-reactjs/src/designer-components/_settings/components/formItem.tsx (1 hunks)
  • shesha-reactjs/src/designer-components/_settings/settingsControl.tsx (3 hunks)
  • shesha-reactjs/src/designer-components/_settings/styles/styles.ts (1 hunks)
  • shesha-reactjs/src/designer-components/_settings/utils/border/utils.tsx (1 hunks)
  • shesha-reactjs/src/designer-components/button/button.tsx (1 hunks)
  • shesha-reactjs/src/designer-components/codeEditor/codeEditor.tsx (2 hunks)
  • shesha-reactjs/src/designer-components/propertiesTabs/style.ts (1 hunks)
🔇 Additional comments (10)
shesha-reactjs/src/designer-components/propertiesTabs/style.ts (1)

19-30: Improved button text overflow handling.

The added styles properly handle text overflow in buttons by implementing flex layout with text-overflow ellipsis. This enhancement prevents long button text from breaking the layout while ensuring content remains accessible.

shesha-reactjs/src/designer-components/_settings/styles/styles.ts (1)

76-77:

Details

❓ Verification inconclusive

Fixed positioning simplifies the sidebar container styling.

Replacing the conditional position based on hasCode with a fixed value of -20px and adding a specific width makes the styling more consistent. However, verify that this doesn't negatively impact the UI when switching between modes.


🏁 Script executed:

#!/bin/bash
# Check for any references to the jsSwitch class to understand its usage context
rg "jsSwitch" --type=tsx --type=ts

Length of output: 62


It appears that the previous command used an unrecognized file type flag for TSX files. The updated script above uses a glob pattern to search both .ts and .tsx files for "jsSwitch". Once you run this, please verify whether there are any usages of "jsSwitch" that might get affected by the styling changes—specifically, confirm that replacing the conditional positioning with a fixed top value of -20px and setting the width to 25px doesn’t negatively impact the UI when switching modes.


🏁 Script executed:

#!/bin/bash
# Re-run the search for 'jsSwitch' references in both TypeScript and TSX files using a glob pattern.
rg "jsSwitch" --glob "*.{ts,tsx}"

Length of output: 304


Let's verify that TypeScript files (including the one in shesha-reactjs/src/designer-components/_settings/styles/styles.ts) are being picked up by our file search tools. Ideally, once we confirm their presence, we can re-run the search for "jsSwitch" with a correct file filter. This will help ensure that replacing the conditional positioning doesn’t adversely affect any mode-switching functionality.


🏁 Script executed:

#!/bin/bash
# List all TypeScript and TSX files in the repository to verify that they are being detected by file search utilities.
fd -e ts -e tsx

Length of output: 139


Action Required: Confirm UI Behavior with Sidebar Changes

The fixed styling update (top: -20px; width: 25px) appears to be localized with no references found to the jsSwitch class. However, since automated searches did not yield conclusive results regarding mode-switch dependencies, please manually verify that these changes do not adversely impact the UI when switching modes.

  • Impact Area: Sidebar container in shesha-reactjs/src/designer-components/_settings/styles/styles.ts
  • Verification Needed: Ensure mode-switch functionality and layout remain consistent with the fixed positioning.
shesha-reactjs/src/designer-components/_settings/components/formItem.tsx (1)

27-27:

Details

❓ Verification inconclusive

Simplified readonly/disabled state logic.

The changes decouple the form item's interactivity from the hasCode state, making it depend solely on the readOnly prop. This simplifies the logic but potentially changes behavior.

Also applies to: 29-29


🏁 Script executed:

#!/bin/bash
# Check for usages of the FormItem component to understand the impact
rg "FormItem" --type=tsx -A 5 -B 5
# Check if readOnly and hasCode are used together elsewhere
rg "readOnly.*hasCode|hasCode.*readOnly" --type=tsx

Length of output: 144


It appears that using the --type=tsx flag caused the issue because ripgrep did not recognize it. Please run the above script so that we can obtain better output regarding the usage of FormItem and any occurrence of readOnly with hasCode. Once you have the output, we can verify if the simplified readOnly logic affects any dependent behavior.


🏁 Script executed:

#!/bin/bash
# Re-run the search using a glob filter for .tsx files instead of --type=tsx.

# Check for usages of the FormItem component to understand its impact
rg "FormItem" -g "*.tsx" -A 5 -B 5

# Check if readOnly and hasCode occur together in .tsx files
rg "readOnly.*hasCode|hasCode.*readOnly" -g "*.tsx"

Length of output: 386


Review Comment: Decoupled readOnly and hasCode Logic

In shesha-reactjs/src/designer-components/_settings/components/formItem.tsx at line 27, the code now reads:

            readOnly: readOnly,

This change simplifies the logic by basing the form item's interactivity solely on the readOnly prop, rather than coupling it with the hasCode state. Although this streamlines the implementation, it could potentially alter behavior in parts of the application that previously depended on both states being intertwined.

  • Action Required: Please perform a manual verification to ensure that decoupling readOnly from hasCode does not lead to unintended side effects in any usage of the FormItem component.
shesha-reactjs/src/designer-components/button/button.tsx (1)

95-95: Syntax improvement with trailing comma

Adding a trailing comma in the object spread is good practice. It makes future additions easier and improves consistency in the code style.

shesha-reactjs/src/designer-components/codeEditor/codeEditor.tsx (2)

14-14: Icon import change to support UI updates

Replaced CodeFilled with CodeOutlined to support the updated button rendering approach.


148-155: Improved button rendering with more readable code display

The button component has been simplified by:

  1. Removing the unnecessary classNames utility
  2. Removing redundant type="default" prop
  3. Adding monospace font styling for better code readability
  4. Using consistent icon (CodeOutlined) in both states

This improves readability of code snippets when displayed on the button.

shesha-reactjs/src/designer-components/_settings/settingsControl.tsx (4)

12-15: Added necessary imports for mode-switching feature

Imported Button component and necessary icons to implement the new mode-switching functionality.


82-85: Added new mode-switching function

The new onSwitchMode function provides a clean way to toggle between 'code' and 'value' modes, enhancing the user experience by making it easy to switch views.


118-128: Added mode-switching button with appropriate visual indicators

The new button implementation:

  1. Is hidden when in readOnly mode
  2. Uses appropriate icons for different states
  3. Shows danger styling when in 'value' mode but code exists
  4. Provides visual feedback about the current mode

This enhances the UI by making mode switching intuitive and provides clear visual indicators of the current state.


129-132: Improved conditional rendering based on mode

The updated conditional rendering ensures that only the appropriate view is shown based on the selected mode, while maintaining the correct styling and layout.

@James-Baloyi James-Baloyi merged commit 3fd1510 into shesha-io:main Apr 2, 2025
1 of 4 checks passed
This was referenced Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants