mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
B #~: Add IP on provision was making the wrong call (#1985)
This commit is contained in:
parent
d019bd49a6
commit
2b8ba0f531
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and *
|
||||
* limitations under the License. *
|
||||
* ------------------------------------------------------------------------- */
|
||||
import { memo, useState } from 'react'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { Trash as DeleteIcon, AddCircledOutline } from 'iconoir-react'
|
||||
@ -37,9 +37,16 @@ const Networks = memo(({ id }) => {
|
||||
const [amount, setAmount] = useState(() => 1)
|
||||
const { enqueueSuccess } = useGeneralApi()
|
||||
|
||||
const [addIp, { isLoading: loadingAddIp }] = useAddIpToProvisionMutation()
|
||||
const [removeResource, { isLoading: loadingRemove }] =
|
||||
useRemoveResourceMutation()
|
||||
const [addIp, { isLoading: loadingAddIp, isSuccess: successAddIp }] =
|
||||
useAddIpToProvisionMutation()
|
||||
const [
|
||||
removeResource,
|
||||
{
|
||||
isLoading: loadingRemove,
|
||||
isSuccess: successRemove,
|
||||
originalArgs: { id: vnetId } = {},
|
||||
},
|
||||
] = useRemoveResourceMutation()
|
||||
const { data = {} } = useGetProvisionQuery(id)
|
||||
|
||||
const provisionNetworks =
|
||||
@ -47,6 +54,14 @@ const Networks = memo(({ id }) => {
|
||||
(network) => +network.id
|
||||
) ?? []
|
||||
|
||||
useEffect(() => {
|
||||
successAddIp && enqueueSuccess(`IP added ${amount}x`)
|
||||
}, [successAddIp])
|
||||
|
||||
useEffect(() => {
|
||||
successRemove && enqueueSuccess(`Network deleted - ID: ${vnetId}`)
|
||||
}, [successRemove])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack direction="row" mb="0.5em">
|
||||
@ -67,10 +82,7 @@ const Networks = memo(({ id }) => {
|
||||
label={<Translate word={T.AddIP} />}
|
||||
sx={{ ml: 1, display: 'flex', alignItems: 'flex-start' }}
|
||||
isSubmitting={loadingAddIp}
|
||||
onClick={async () => {
|
||||
await addIp({ id, amount })
|
||||
enqueueSuccess(`IP added ${amount}x`)
|
||||
}}
|
||||
onClick={async () => await addIp({ id, amount })}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@ -102,14 +114,13 @@ const Networks = memo(({ id }) => {
|
||||
data-cy={`provision-vnet-delete-${vnet.ID}`}
|
||||
icon={<DeleteIcon />}
|
||||
isSubmitting={loadingRemove}
|
||||
onClick={async () => {
|
||||
removeResource({
|
||||
onClick={async () =>
|
||||
await removeResource({
|
||||
provision: id,
|
||||
id: vnet.ID,
|
||||
resource: 'network',
|
||||
})
|
||||
enqueueSuccess(`Network deleted - ID: ${vnet.ID}`)
|
||||
}}
|
||||
}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ const provisionApi = oneApi.injectEndpoints({
|
||||
* @throws Fails when response isn't code 200
|
||||
*/
|
||||
query: (params) => {
|
||||
const name = Actions.PROVISION_ADD_HOST
|
||||
const name = Actions.PROVISION_ADD_IP
|
||||
const command = { name, ...Commands[name] }
|
||||
|
||||
return { params, command }
|
||||
|
Loading…
x
Reference in New Issue
Block a user