Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

1.3 KB
Raw Blame
import { memo } from "react";

import { Stack } from "metabase/ui";
import type { DependencyNode } from "metabase-types/api";

import type { DependencyDiagnosticsMode } from "../types";

import { BrokenDependentsSection } from "./BrokenDependentsSection";
import S from "./DiagnosticsSidebar.module.css";
import { ErrorsSection } from "./ErrorsSection";
import { FieldsSection } from "./FieldsSection";
import { InfoSection } from "./InfoSection";
import { LocationSection } from "./LocationSection";
import { SidebarHeader } from "./SidebarHeader";

type DiagnosticsSidebarProps = {
  node: DependencyNode;
  mode: DependencyDiagnosticsMode;
  onClose: () => void;
};

export const DiagnosticsSidebar = memo(function DiagnosticsSidebar({
  node,
  mode,
  onClose,
}: DiagnosticsSidebarProps) {
  return (
    <Stack
      className={S.sidebar}
      p="xl"
      gap="xxl"
      bg="background_page-primary"
      data-testid="dependency-list-sidebar"
    >
      <Stack gap="xl">
        <SidebarHeader node={node} onClose={onClose} mode={mode} />
        <LocationSection node={node} />
        <InfoSection node={node} />
      </Stack>
      {mode === "broken" && <ErrorsSection node={node} />}
      {mode === "broken" && <BrokenDependentsSection node={node} />}
      {mode === "unreferenced" && <FieldsSection node={node} />}
    </Stack>
  );
});