diff --git a/src/dashboard/src/components/dashboard/Dashboard.tsx b/src/dashboard/src/components/dashboard/Dashboard.tsx index 1f450942..bb78a455 100644 --- a/src/dashboard/src/components/dashboard/Dashboard.tsx +++ b/src/dashboard/src/components/dashboard/Dashboard.tsx @@ -39,7 +39,7 @@ import { useDashboardFilter } from '.'; * @returns Component */ export const Dashboard = () => { - const { download, downloadHistory } = useApiServerItems(); + const { download } = useApiServerItems(); const { isReady: isReadyTenants, tenants } = useTenants({ init: true }); const { isReady: isReadyOrganizations, organizations } = useOrganizations({ init: true, @@ -198,7 +198,7 @@ export const Dashboard = () => { dashboardOrganization, dashboardOperatingSystemItem, handleExport, - ] + ], ); return ( diff --git a/src/dashboard/src/hooks/filter/useFilteredFileSystemItems.ts b/src/dashboard/src/hooks/filter/useFilteredFileSystemItems.ts index bf725117..ad6ad062 100644 --- a/src/dashboard/src/hooks/filter/useFilteredFileSystemItems.ts +++ b/src/dashboard/src/hooks/filter/useFilteredFileSystemItems.ts @@ -4,11 +4,11 @@ import { IFileSystemItemFilter, IFileSystemItemModel, useApiFileSystemItems } fr export const useFilteredFileSystemItems = () => { const { find } = useApiFileSystemItems(); + const isLoading = useFilteredStore((state) => state.loadingFileSystemItems); + const setIsLoading = useFilteredStore((state) => state.setLoadingFileSystemItems); const fileSystemItems = useFilteredStore((state) => state.fileSystemItems); const setFileSystemItems = useFilteredStore((state) => state.setFileSystemItems); - const [isLoading, setIsLoading] = React.useState(false); - const fetch = React.useCallback( async (filter: IFileSystemItemFilter) => { try { @@ -23,7 +23,7 @@ export const useFilteredFileSystemItems = () => { setIsLoading(false); } }, - [find, setFileSystemItems], + [find, setFileSystemItems, setIsLoading], ); return React.useMemo( diff --git a/src/dashboard/src/hooks/filter/useFilteredOperatingSystemItems.ts b/src/dashboard/src/hooks/filter/useFilteredOperatingSystemItems.ts index ab4d21c1..c38dcf6a 100644 --- a/src/dashboard/src/hooks/filter/useFilteredOperatingSystemItems.ts +++ b/src/dashboard/src/hooks/filter/useFilteredOperatingSystemItems.ts @@ -9,12 +9,12 @@ import { export const useFilteredOperatingSystemItems = () => { const { findList } = useApiOperatingSystemItems(); + const isLoading = useFilteredStore((state) => state.loadingOperatingSystemItems); + const setIsLoading = useFilteredStore((state) => state.setLoadingOperatingSystemItems); const { operatingSystemItem } = useFilteredStore((state) => state.values); const operatingSystemItems = useFilteredStore((state) => state.operatingSystemItems); const setOperatingSystemItems = useFilteredStore((state) => state.setOperatingSystemItems); - const [isLoading, setIsLoading] = React.useState(false); - const fetch = React.useCallback( async (filter: IOperatingSystemItemFilter) => { try { @@ -29,7 +29,7 @@ export const useFilteredOperatingSystemItems = () => { setIsLoading(false); } }, - [findList, setOperatingSystemItems], + [findList, setIsLoading, setOperatingSystemItems], ); const options = React.useMemo( diff --git a/src/dashboard/src/hooks/filter/useFilteredOrganizations.ts b/src/dashboard/src/hooks/filter/useFilteredOrganizations.ts index af045699..4b2b46d0 100644 --- a/src/dashboard/src/hooks/filter/useFilteredOrganizations.ts +++ b/src/dashboard/src/hooks/filter/useFilteredOrganizations.ts @@ -10,11 +10,11 @@ export interface IFilteredOrganizations { export const useFilteredOrganizations = ({ includeDisabled }: IFilteredOrganizations = {}) => { const { findList } = useApiOrganizations(); + const isLoading = useFilteredStore((state) => state.loadingOrganizations); + const setIsLoading = useFilteredStore((state) => state.setLoadingOrganizations); const organizations = useFilteredStore((state) => state.organizations); const setOrganizations = useFilteredStore((state) => state.setOrganizations); - const [isLoading, setIsLoading] = React.useState(false); - const fetch = React.useCallback( async (filter: IOrganizationFilter) => { try { @@ -29,7 +29,7 @@ export const useFilteredOrganizations = ({ includeDisabled }: IFilteredOrganizat setIsLoading(false); } }, - [findList, setOrganizations], + [findList, setIsLoading, setOrganizations], ); const options = React.useMemo( diff --git a/src/dashboard/src/hooks/filter/useFilteredServerItems.ts b/src/dashboard/src/hooks/filter/useFilteredServerItems.ts index bdac5b5b..3a01dfa3 100644 --- a/src/dashboard/src/hooks/filter/useFilteredServerItems.ts +++ b/src/dashboard/src/hooks/filter/useFilteredServerItems.ts @@ -7,11 +7,11 @@ export interface IFilteredServerItemsProps {} export const useFilteredServerItems = ({}: IFilteredServerItemsProps) => { const { findList } = useApiServerItems(); + const isLoading = useFilteredStore((state) => state.loadingServerItems); + const setIsLoading = useFilteredStore((state) => state.setLoadingServerItems); const serverItems = useFilteredStore((state) => state.serverItems); const setFilteredServerItems = useFilteredStore((state) => state.setServerItems); - const [isLoading, setIsLoading] = React.useState(false); - const fetch = React.useCallback( async (filter: IServerItemFilter) => { try { @@ -26,7 +26,7 @@ export const useFilteredServerItems = ({}: IFilteredServerItemsProps) => { setIsLoading(false); } }, - [findList, setFilteredServerItems], + [findList, setFilteredServerItems, setIsLoading], ); const options = React.useMemo( diff --git a/src/dashboard/src/hooks/filter/useFilteredTenants.ts b/src/dashboard/src/hooks/filter/useFilteredTenants.ts index 2b6c96d1..558dd14b 100644 --- a/src/dashboard/src/hooks/filter/useFilteredTenants.ts +++ b/src/dashboard/src/hooks/filter/useFilteredTenants.ts @@ -10,11 +10,11 @@ export interface IFilteredTenants { export const useFilteredTenants = ({ includeDisabled }: IFilteredTenants = {}) => { const { findList } = useApiTenants(); + const isLoading = useFilteredStore((state) => state.loadingTenants); + const setIsLoading = useFilteredStore((state) => state.setLoadingTenants); const tenants = useFilteredStore((state) => state.tenants); const setTenants = useFilteredStore((state) => state.setTenants); - const [isLoading, setIsLoading] = React.useState(false); - const fetch = React.useCallback( async (filter: ITenantFilter) => { try { @@ -29,7 +29,7 @@ export const useFilteredTenants = ({ includeDisabled }: IFilteredTenants = {}) = setIsLoading(false); } }, - [findList, setTenants], + [findList, setIsLoading, setTenants], ); const options = React.useMemo( diff --git a/src/dashboard/src/store/useFilteredStore.ts b/src/dashboard/src/store/useFilteredStore.ts index de822b4a..fa04c6ce 100644 --- a/src/dashboard/src/store/useFilteredStore.ts +++ b/src/dashboard/src/store/useFilteredStore.ts @@ -22,30 +22,40 @@ export interface IFilteredStoreState { setValues: (dispatch: (values: IFilterValues) => IFilterValues) => void; // Tenants + loadingTenants: boolean; + setLoadingTenants: (value: boolean) => void; tenantsReady?: boolean; setTenantsReady: (value?: boolean) => void; tenants: ITenantListModel[]; setTenants: (values: ITenantListModel[]) => void; // Organizations + loadingOrganizations: boolean; + setLoadingOrganizations: (value: boolean) => void; organizationsReady?: boolean; setOrganizationsReady: (value?: boolean) => void; organizations: IOrganizationListModel[]; setOrganizations: (values: IOrganizationListModel[]) => void; // Operating System Items + loadingOperatingSystemItems: boolean; + setLoadingOperatingSystemItems: (value: boolean) => void; operatingSystemItemsReady?: boolean; setOperatingSystemItemsReady: (value?: boolean) => void; operatingSystemItems: IOperatingSystemItemListModel[]; setOperatingSystemItems: (values: IOperatingSystemItemListModel[]) => void; // Server Items + loadingServerItems: boolean; + setLoadingServerItems: (value: boolean) => void; serverItemsReady?: boolean; setServerItemsReady: (value?: boolean) => void; serverItems: IServerItemListModel[]; setServerItems: (values: IServerItemListModel[]) => void; // File System Items + loadingFileSystemItems: boolean; + setLoadingFileSystemItems: (value: boolean) => void; fileSystemItemsReady?: boolean; setFileSystemItemsReady: (value?: boolean) => void; fileSystemItems: IFileSystemItemModel[]; @@ -63,27 +73,39 @@ export const useFilteredStore = create((set, get) => ({ }, // Tenants + loadingTenants: false, + setLoadingTenants: (value) => set((state) => ({ ...state, loadingTenants: value })), setTenantsReady: (value) => set((state) => ({ ...state, tenantsReady: value })), tenants: [], setTenants: (values) => set((state) => ({ ...state, tenants: values })), // Organizations + loadingOrganizations: false, + setLoadingOrganizations: (value) => set((state) => ({ ...state, loadingOrganizations: value })), setOrganizationsReady: (value) => set((state) => ({ ...state, organizationsReady: value })), organizations: [], setOrganizations: (values) => set((state) => ({ ...state, organizations: values })), // Operating System Items + loadingOperatingSystemItems: false, + setLoadingOperatingSystemItems: (value) => + set((state) => ({ ...state, loadingOperatingSystemItems: value })), setOperatingSystemItemsReady: (value) => set((state) => ({ ...state, operatingSystemItemsReady: value })), operatingSystemItems: [], setOperatingSystemItems: (values) => set((state) => ({ ...state, operatingSystemItems: values })), // Server Items + loadingServerItems: false, + setLoadingServerItems: (value) => set((state) => ({ ...state, loadingServerItems: value })), setServerItemsReady: (value) => set((state) => ({ ...state, serverItemsReady: value })), serverItems: [], setServerItems: (values) => set((state) => ({ ...state, serverItems: values })), // File System Items + loadingFileSystemItems: false, + setLoadingFileSystemItems: (value) => + set((state) => ({ ...state, loadingFileSystemItems: value })), setFileSystemItemsReady: (value) => set((state) => ({ ...state, fileSystemItemsReady: value })), fileSystemItems: [], setFileSystemItems: (values) => set((state) => ({ ...state, fileSystemItems: values })),