index.tsx


Overview

index.tsx defines a React functional component named SingleDebugDrawer. This component provides a full-screen bottom drawer UI to facilitate debugging of a single component within a flow or application. It allows users to:

The drawer leverages hooks to fetch input elements and perform debugging, and uses a combination of Ant Design UI components and custom components to render the interface.


Component: SingleDebugDrawer

Description

SingleDebugDrawer is a modal drawer designed to debug a single component instance identified by the componentId. It fetches input elements, allows the user to run a debug process with those inputs, and displays the debug output in a user-friendly JSON format.

The drawer is intended to be shown or hidden based on the visible prop and can be dismissed via the hideModal callback.


Props

interface IProps {
  componentId?: string;            // Optional ID of the component to debug
}

interface IModalProps<T> {
  visible: boolean;                // Controls drawer visibility
  hideModal: () => void;           // Callback to hide the drawer
}

SingleDebugDrawer accepts props that combine IModalProps<any> and IProps:

Prop

Type

Description

componentId

string (opt.)

Identifier of the component to debug

visible

boolean

Controls whether the drawer is visible

hideModal

() => void

Function to call when closing/hiding drawer


Internal Hooks and Data


Functions / Methods

onOk

const onOk = useCallback(
  (nextValues: any[]) => {
    if (componentId) {
      debugSingle({ component_id: componentId, params: nextValues });
    }
  },
  [componentId, debugSingle],
);

Rendered UI and Components


Usage Example

import SingleDebugDrawer from './index';

function ParentComponent() {
  const [visible, setVisible] = React.useState(false);
  const componentId = 'component-123';

  return (
    <>
      <button onClick={() => setVisible(true)}>Open Debug Drawer</button>
      <SingleDebugDrawer
        visible={visible}
        hideModal={() => setVisible(false)}
        componentId={componentId}
      />
    </>
  );
}

Important Implementation Details


Interaction with Other Parts of the Application

Together, these integrations position SingleDebugDrawer as a specialized debugging tool embedded in a larger flow or UI system for testing component behavior interactively.


Mermaid Component Diagram

componentDiagram
    component SingleDebugDrawer {
      +componentId?: string
      +visible: boolean
      +hideModal(): void
    }
    component DebugContent {
      +parameters: any[]
      +ok(nextValues: any[]): void
      +isNext: boolean
      +loading: boolean
      +submitButtonDisabled: boolean
    }
    component Drawer
    component CopyToClipboard {
      +text: string
    }
    component JsonView {
      +src: object
      +displaySize: boolean
      +collapseStringsAfterLength: number
    }
    component useFetchInputElements
    component useDebugSingle
    component useTranslation

    SingleDebugDrawer --> Drawer : renders
    SingleDebugDrawer --> useFetchInputElements : fetches input list
    SingleDebugDrawer --> useDebugSingle : triggers debug & gets data
    SingleDebugDrawer --> useTranslation : localization
    Drawer --> DebugContent : renders input form
    Drawer --> CopyToClipboard : copies JSON output
    Drawer --> JsonView : shows JSON output

Summary

The index.tsx file exports a React component SingleDebugDrawer which provides a bottom drawer UI for debugging a single component instance by fetching input parameters, running debug executions, and displaying formatted JSON output interactively. It integrates with custom hooks, UI components, and internationalization utilities to offer a streamlined debugging experience within the application.

This component is designed to be embedded into a larger flow or UI system and facilitates quick testing and inspection of component behavior.