Skip to content

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

867 B
Raw Blame
import { useMemo } from "react";
import { t } from "ttag";

import type { ObjectWithModel } from "metabase/common/utils/icon";
import { useGetIcon } from "metabase/hooks/use-icon";
import { Group, Icon, Text } from "metabase/ui";
import type { Collection } from "metabase-types/api";

export const CollectionAuthorityLevelDisplay = ({
  collection,
}: {
  collection: Collection;
}) => {
  const getIcon = useGetIcon();
  const iconProps = useMemo(
    () =>
      // Unjustified type cast. FIXME
      getIcon({
        ...collection,
        model: "collection",
      } as unknown as ObjectWithModel),
    [collection, getIcon],
  );

  if (collection.authority_level !== "official") {
    return null;
  }

  return (
    <Group wrap="nowrap" gap="sm" pb="sm">
      <Icon {...iconProps} />
      <Text lh={1}>{t`Official collection`}</Text>
    </Group>
  );
};