feat: add context specific search and actions (#1570)

This commit is contained in:
Meier Lukas
2024-12-06 19:07:27 +01:00
committed by GitHub
parent aaa3e7ce0c
commit c840ff85bc
18 changed files with 517 additions and 183 deletions

View File

@@ -2,8 +2,10 @@
import { useCallback } from "react";
import { Center, Stack, Text, UnstyledButton } from "@mantine/core";
import { IconBinaryTree } from "@tabler/icons-react";
import { clientApi } from "@homarr/api/client";
import { useRegisterSpotlightContextActions } from "@homarr/spotlight";
import type { WidgetComponentProps } from "../../definition";
import { NoIntegrationSelectedError } from "../../errors";
@@ -60,6 +62,27 @@ const InnerComponent = ({ options, integrationId, isEditMode }: InnerComponentPr
});
}, [integrationId, isEditMode, mutate, options.clickable, options.entityId]);
useRegisterSpotlightContextActions(
`smartHome-entityState-${options.entityId}`,
[
{
id: options.entityId,
name: options.displayName,
icon: IconBinaryTree,
interaction() {
return {
type: "javaScript",
onSelect() {
handleClick();
},
};
},
disabled: !options.clickable,
},
],
[handleClick, options.clickable, options.displayName, options.entityId],
);
return (
<UnstyledButton
onClick={handleClick}