diff --git a/src/fireedge/src/client/components/Tables/Vms/index.js b/src/fireedge/src/client/components/Tables/Vms/index.js index e835d479d9..2a75d49a7c 100644 --- a/src/fireedge/src/client/components/Tables/Vms/index.js +++ b/src/fireedge/src/client/components/Tables/Vms/index.js @@ -10,7 +10,7 @@ import VmRow from 'client/components/Tables/Vms/row' import VmDetail from 'client/components/Tables/Vms/detail' const INITIAL_ELEMENT = 0 -const NUMBER_OF_INTERVAL = 10 +const NUMBER_OF_INTERVAL = 12 const VmsTable = () => { const [[start, end], setPage] = useState([INITIAL_ELEMENT, -NUMBER_OF_INTERVAL]) diff --git a/src/fireedge/src/client/features/One/slice.js b/src/fireedge/src/client/features/One/slice.js index 445e341b78..ab61478e3f 100644 --- a/src/fireedge/src/client/features/One/slice.js +++ b/src/fireedge/src/client/features/One/slice.js @@ -1,4 +1,4 @@ -import { createSlice } from '@reduxjs/toolkit' +import { createSlice, isPending, isFulfilled } from '@reduxjs/toolkit' import { logout } from 'client/features/Auth/actions' import { updateResourceList } from 'client/features/One/utils' @@ -84,21 +84,25 @@ const { actions, reducer } = createSlice({ } ) .addMatcher( - ({ type }) => type.includes('/pool') && type.endsWith('/pending'), - (state, { meta, type }) => { - const pureType = type.replace('/pending', '') + ({ type }) => type.includes('/pool'), + (state, action) => { + const { requests } = state + const { payload, type } = action - if (!state?.requests?.[pureType]) { - state.requests[pureType] = meta + // filter type without: /pending, /fulfilled or /rejected + const pureType = type.match(/(.*\/pool)/)[0] + + if (isPending(action)) { + return { ...state, requests: { ...requests, [pureType]: action } } } - } - ) - .addMatcher( - ({ type }) => type.includes('/pool') && type.endsWith('/fulfilled'), - (state, { payload, type }) => { - const { [getNameListFromType(type)]: _, ...requests } = state.requests - return { ...state, requests, ...payload } + const { [pureType]: _, ...restOfRequests } = requests + + return { + ...state, + ...(isFulfilled(action) && payload), + requests: restOfRequests + } } ) } diff --git a/src/fireedge/src/client/features/One/utils.js b/src/fireedge/src/client/features/One/utils.js index ade077debd..346d144928 100644 --- a/src/fireedge/src/client/features/One/utils.js +++ b/src/fireedge/src/client/features/One/utils.js @@ -1,4 +1,4 @@ -import { createAsyncThunk } from '@reduxjs/toolkit' +import { createAsyncThunk, isPending } from '@reduxjs/toolkit' import { logout } from 'client/features/Auth/actions' import { ATTRIBUTES_EDITABLE } from 'client/features/One/slice' @@ -26,11 +26,7 @@ export const createAction = (type, service, wrapResult) => return rejectWithValue(data?.message ?? statusText) } }, { - condition: (_, { getState }) => { - const { requests } = getState().one - - return !requests[type] - } + condition: (_, { getState }) => !getState().one.requests[type] }) export const poolRequest = async (data = {}, command, element) => { @@ -45,7 +41,7 @@ export const poolRequest = async (data = {}, command, element) => { } /** - * @param {Object} currentList Current state from redux + * @param {Object} currentList Current list of resources from redux * @param {Object} value OpenNebula resource * @returns {Array} Returns a new list with the attributes editable modified */