Skip to content

feat(client): adds a switch block component#689

Merged
johbaxter merged 21 commits intodevfrom
feature/switch-block-component
Mar 20, 2025
Merged

feat(client): adds a switch block component#689
johbaxter merged 21 commits intodevfrom
feature/switch-block-component

Conversation

@22mayank
Copy link
Copy Markdown
Contributor

Description

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes

@22mayank 22mayank requested a review from a team as a code owner March 11, 2025 13:15
@github-actions
Copy link
Copy Markdown

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

feat(client): adds a switch block component


User description

Description

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes


PR Type

  • Enhancement

Description

  • Added Switch Block component integration

  • Configured Switch Block UI and settings

  • Updated block registry and assets exports

  • Added menu item for Switch Block in designer


Changes walkthrough 📝

Relevant files
Enhancement
index.ts
Integrate SwitchBlock into block defaults                               

libs/renderer/src/components/block-defaults/index.ts

  • Imported SwitchBlock config and definition
  • Added SwitchBlockDef to union types and registry
  • +5/-1     
    SwitchBlock.tsx
    Create SwitchBlock component with UI logic                             

    libs/renderer/src/components/block-defaults/switch-block/SwitchBlock.tsx

  • Added SwitchBlock component implementation
  • Defined styled container and helper texts
  • Used FormControlLabel for label placements
  • +105/-0 
    config.tsx
    Configure default settings for SwitchBlock                             

    libs/renderer/src/components/block-defaults/switch-block/config.tsx

  • Created config for SwitchBlock
  • Set default properties and event listeners
  • Integrated block settings and dimensions
  • +143/-0 
    index.ts
    Export module for SwitchBlock component                                   

    libs/renderer/src/components/block-defaults/switch-block/index.ts

  • Exported SwitchBlock and its config
  • Established module entry point
  • +2/-0     
    index.ts
    Add asset exports for SwitchBlock images                                 

    packages/client/src/assets/blocks/index.ts

  • Exported SWITCH_ACTIVE and SWITCH_HOVER images
  • Updated asset list for new component
  • +2/-0     
    default-menu.ts
    Include designer menu entry for SwitchBlock                           

    packages/client/src/components/blocks-workspace/menus/default-menu.ts

  • Added menu item for Switch Block
  • Provided JSON config and helper texts for UI
  • Integrated block images for active and hover states
  • +26/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link
    Copy Markdown

    @CodiumAI-Agent /review

    @github-actions
    Copy link
    Copy Markdown

    @CodiumAI-Agent /improve

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Union Consistency

    The union type for DefaultBlockDefinitions now includes both duplicate and additional entries (e.g. duplicate ThemeBlockDef and added EchartVisualizationBlockDef and SwitchBlockDef). Verify that this ordering and redundancy are intentional.

    | ThemeBlockDef
    | ToggleButtonBlockDef
    | UploadBlockDef
    | VegaVisualizationBlockDef
    | RadioBlockDef
    | ThemeBlockDef
    | EchartVisualizationBlockDef
    | SwitchBlockDef;

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix listener type mismatch

    Update the listener property to match the type defined in the block definition.

    libs/renderer/src/components/block-defaults/switch-block/config.tsx [30-32]

     listeners: {
    -    onChange: [],
    +    onChange: true,
     },
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly updates the listeners property to match the block definition (onChange should be true instead of an empty array) and thus ensures type consistency.

    Medium

    Copy link
    Copy Markdown
    Contributor

    @johbaxter johbaxter left a comment

    Choose a reason for hiding this comment

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

    Cool for now

    @johbaxter johbaxter merged commit fd5b272 into dev Mar 20, 2025
    3 checks passed
    @johbaxter johbaxter deleted the feature/switch-block-component branch March 20, 2025 15:36
    @github-actions
    Copy link
    Copy Markdown

    @CodiumAI-Agent /update_changelog

    @QodoAI-Agent
    Copy link
    Copy Markdown

    Changelog updates: 🔄

    2025-03-20

    Added

    • Introduced a new switch block component with its configuration and assets.

    to commit the new content to the CHANGELOG.md file, please type:
    '/update_changelog --pr_update_changelog.push_changelog_changes=true'

    @22mayank 22mayank linked an issue Mar 21, 2025 that may be closed by this pull request
    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.

    Switch Block component

    4 participants