Skip to content

Commit

Permalink
feat(web): add hook for config devices
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Nov 11, 2024
1 parent 690e5a9 commit 00e3b01
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions web/src/queries/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
Volume,
VolumeTarget,
} from "~/types/storage";
import * as ConfigModel from "~/storage/model/config";

import { QueryHookOptions } from "~/types/queries";

Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -334,6 +347,7 @@ export {
useConfig,
useSolvedConfig,
useConfigMutation,
useConfigDevices,
useDevices,
useAvailableDevices,
useProductParams,
Expand Down

0 comments on commit 00e3b01

Please sign in to comment.