@openshift-console/dynamic-plugin-sdk
Version:
Provides core APIs, types and utilities used by dynamic plugins at runtime.
18 lines (17 loc) • 545 B
JavaScript
import { useSelector } from 'react-redux';
/**
* Hook that retrieves all current k8s models from redux.
*
* @returns An array with the first item as the list of k8s model and second item as inFlight status
* @example
* ```ts
* const Component: React.FC = () => {
* const [models, inFlight] = UseK8sModels();
* return ...
* }
* ```
*/
export const useK8sModels = () => [
useSelector(({ k8s }) => k8s.getIn(['RESOURCES', 'models'])?.toJS() ?? {}),
useSelector(({ k8s }) => k8s.getIn(['RESOURCES', 'inFlight'])) ?? false,
];