Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

1.3 KB
Raw Blame
import { Spotlight } from "@mantine/spotlight";

import { translateIfNecessary } from "@homarr/translation";
import { useI18n } from "@homarr/translation/client";

import type { SearchGroup } from "../../../lib/group";
import type { inferSearchInteractionOptions } from "../../../lib/interaction";
import type { SpotlightMode } from "../../../open";
import { SpotlightGroupActions } from "../group-actions";

interface SpotlightActionGroupsProps {
  groups: SearchGroup[];
  query: string;
  setQuery: (query: string) => void;
  setMode: (mode: SpotlightMode) => void;
  setChildrenOptions: (options: inferSearchInteractionOptions<"children">) => void;
}

export const SpotlightActionGroups = ({ groups, ...others }: SpotlightActionGroupsProps) => {
  const t = useI18n();

  return groups.map((group) => (
    <Spotlight.ActionsGroup
      key={`${translateIfNecessary(t, group.title)}::${String(group.keyPath)}`}
      label={translateIfNecessary(t, group.title)}
      data-search-source={group.source?.kind ?? "local"}
      data-remote-source={group.source?.kind === "remote" ? group.source.source : undefined}
    >
      {/*eslint-disable-next-line @typescript-eslint/no-explicit-any */}
      <SpotlightGroupActions<any> group={group} {...others} />
    </Spotlight.ActionsGroup>
  ));
};