mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
F OpenNebula/one#5422: Fix condition to fetch pool
This commit is contained in:
parent
071f2d46dc
commit
260c38fd2a
@ -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])
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user