From 6d6874405ee17e62d8e31d4432ea2eb58be73370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Thu, 7 Nov 2024 12:27:40 +0000 Subject: [PATCH] feat(web): add hook for config devices --- web/src/queries/storage.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/src/queries/storage.ts b/web/src/queries/storage.ts index d37c7035d8..a6a53b7a48 100644 --- a/web/src/queries/storage.ts +++ b/web/src/queries/storage.ts @@ -51,6 +51,7 @@ import { Volume, VolumeTarget, } from "~/types/storage"; +import * as ConfigModel from "~/storage/model/config"; import { QueryHookOptions } from "~/types/queries"; @@ -149,6 +150,18 @@ const useConfigMutation = () => { return useMutation(query); }; +/** + * Hook that returns the config devices. + */ +const useConfigDevices = (options?: QueryHookOptions): ConfigModel.Device[] => { + const config = useConfig(options); + const solvedConfig = useSolvedConfig(options); + + if (!config || !solvedConfig) return []; + + return ConfigModel.generate(config, solvedConfig); +}; + /** * Hook that returns the list of storage devices for the given scope. * @@ -334,6 +347,7 @@ export { useConfig, useSolvedConfig, useConfigMutation, + useConfigDevices, useDevices, useAvailableDevices, useProductParams,