github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/ui/dashboard/src/components/dashboards/layout/Children/index.tsx (about)

     1  import Child from "../Child";
     2  import {
     3    ContainerDefinition,
     4    DashboardPanelType,
     5    PanelDefinition,
     6  } from "../../../../types";
     7  import { useDashboard } from "../../../../hooks/useDashboard";
     8  
     9  type ChildrenProps = {
    10    children: ContainerDefinition[] | PanelDefinition[] | undefined;
    11    parentType: DashboardPanelType;
    12    showPanelControls?: boolean;
    13  };
    14  
    15  const Children = ({
    16    children = [],
    17    parentType,
    18    showPanelControls = true,
    19  }: ChildrenProps) => {
    20    const { panelsMap } = useDashboard();
    21    return (
    22      <>
    23        {children.map((child) => {
    24          const definition = panelsMap[child.name];
    25          if (!definition) {
    26            return null;
    27          }
    28          return (
    29            <Child
    30              key={definition.name}
    31              layoutDefinition={child}
    32              panelDefinition={definition}
    33              parentType={parentType}
    34              showPanelControls={showPanelControls}
    35            />
    36          );
    37        })}
    38      </>
    39    );
    40  };
    41  
    42  export default Children;