Skip to content

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

976 B
Raw Blame
import type { CollectionAuthorityLevelIcon as CollectionAuthorityLevelIconComponent } from "metabase/plugins/index";
import { Icon } from "metabase/ui";
import { color } from "metabase/ui/utils/colors";

import { AUTHORITY_LEVELS } from "../constants";
import { isRegularCollection } from "../utils";

export const CollectionAuthorityLevelIcon: CollectionAuthorityLevelIconComponent =
  ({ collection, tooltip = "default", archived, ...iconProps }) => {
    if (isRegularCollection(collection)) {
      return null;
    }
    const level = AUTHORITY_LEVELS[String(collection.authority_level)];
    const levelColor = level.color ? color(level.color) : undefined;
    const iconColor = archived ? color("text-disabled") : levelColor;
    return (
      <Icon
        {...iconProps}
        name={level.icon}
        tooltip={level.tooltips?.[tooltip] || tooltip}
        style={{ color: iconColor }}
        data-testid={`${level.type}-collection-marker`}
      />
    );
  };