Skip to content

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

890 B
Raw Blame
import { type ComponentProps, createContext, useContext } from "react";

import { SettingsSection } from "metabase/settings-components";

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

const RemoteSyncSettingsVariantContext =
  createContext<RemoteSyncSettingsVariant>("admin");

export const RemoteSyncSettingsVariantProvider =
  RemoteSyncSettingsVariantContext.Provider;

export const useRemoteSyncSettingsVariant = () =>
  useContext(RemoteSyncSettingsVariantContext);

export const RemoteSyncSettingsSection = ({
  children,
  title,
  ...props
}: ComponentProps<typeof SettingsSection> & { title: string }) => {
  const variant = useRemoteSyncSettingsVariant();

  return (
    <SettingsSection
      {...props}
      title={title}
      titleProps={{
        order: variant === "settings-modal" ? 3 : 2,
      }}
    >
      {children}
    </SettingsSection>
  );
};