Skip to content

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

989 B
Raw Blame
import { t } from "ttag";

import { Link } from "metabase/common/components/Link";
import { Anchor, FixedSizeIcon, Group, Stack } from "metabase/ui";
import * as Urls from "metabase/urls";
import type { Card, IconName } from "metabase-types/api";

type LocationSectionProps = {
  card: Card;
};

export function LocationSection({ card }: LocationSectionProps) {
  if (card.collection == null) {
    return null;
  }

  return (
    <Stack role="region" aria-label={t`Location`} gap="sm">
      <LocationLink
        label={card.collection.name}
        icon="folder"
        to={Urls.collection(card.collection)}
      />
    </Stack>
  );
}

type LocationLinkProps = {
  label: string;
  icon: IconName;
  to: string;
};

function LocationLink({ icon, label, to }: LocationLinkProps) {
  return (
    <Anchor component={Link} lh="1rem" to={to} target="_blank">
      <Group gap="sm" wrap="nowrap">
        <FixedSizeIcon name={icon} />
        {label}
      </Group>
    </Anchor>
  );
}