1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-03 01:17:41 +03:00

B OpenNebula/one#6120: Fix datatable zones (#3026)

Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
This commit is contained in:
Jorge Miguel Lobo Escalona 2024-04-05 12:03:12 +02:00 committed by GitHub
parent cfe1be8641
commit b9bfbaa094
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 24 deletions

View File

@ -46,7 +46,7 @@ const ZoneInfoTab = ({ tabProps = {}, id }) => {
} = tabProps } = tabProps
const [update] = useUpdateZoneMutation() const [update] = useUpdateZoneMutation()
const { data: zone = {} } = useGetZoneQuery({ id }) const { data: zone = {} } = useGetZoneQuery(id)
const { TEMPLATE } = zone const { TEMPLATE } = zone
const handleAttributeInXml = async (path, newValue) => { const handleAttributeInXml = async (path, newValue) => {

View File

@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and * * See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
import { memo, useMemo } from 'react'
import PropTypes from 'prop-types'
import { Alert, LinearProgress } from '@mui/material' import { Alert, LinearProgress } from '@mui/material'
import PropTypes from 'prop-types'
import { memo, useMemo } from 'react'
import { RESOURCE_NAMES } from 'client/constants'
import { useViews } from 'client/features/Auth' import { useViews } from 'client/features/Auth'
import { useGetZoneQuery } from 'client/features/OneApi/zone' import { useGetZoneQuery } from 'client/features/OneApi/zone'
import { getAvailableInfoTabs } from 'client/models/Helper' import { getAvailableInfoTabs } from 'client/models/Helper'
import { RESOURCE_NAMES } from 'client/constants'
import Tabs from 'client/components/Tabs' import Tabs from 'client/components/Tabs'
import Info from 'client/components/Tabs/Zone/Info' import Info from 'client/components/Tabs/Zone/Info'
@ -32,14 +32,16 @@ const getTabComponent = (tabName) =>
const ZoneTabs = memo(({ id }) => { const ZoneTabs = memo(({ id }) => {
const { view, getResourceView } = useViews() const { view, getResourceView } = useViews()
const { isLoading, isError, error } = useGetZoneQuery(id) const { isError, error, status, data } = useGetZoneQuery(id, {
refetchOnMountOrArgChange: 10,
})
const tabsAvailable = useMemo(() => { const tabsAvailable = useMemo(() => {
const resource = RESOURCE_NAMES.ZONE const resource = RESOURCE_NAMES.HOST
const infoTabs = getResourceView(resource)?.['info-tabs'] ?? {} const infoTabs = getResourceView(resource)?.['info-tabs'] ?? {}
return getAvailableInfoTabs(infoTabs, getTabComponent, id) return getAvailableInfoTabs(infoTabs, getTabComponent, id)
}, [view]) }, [view, id])
if (isError) { if (isError) {
return ( return (
@ -49,11 +51,11 @@ const ZoneTabs = memo(({ id }) => {
) )
} }
return isLoading ? ( if (status === 'fulfilled' || id === data?.ID) {
<LinearProgress color="secondary" sx={{ width: '100%' }} /> return <Tabs addBorder tabs={tabsAvailable} />
) : ( }
<Tabs addBorder tabs={tabsAvailable ?? []} />
) return <LinearProgress color="secondary" sx={{ width: '100%' }} />
}) })
ZoneTabs.propTypes = { id: PropTypes.string.isRequired } ZoneTabs.propTypes = { id: PropTypes.string.isRequired }

View File

@ -13,25 +13,25 @@
* See the License for the specific language governing permissions and * * See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
import { ReactElement, useState, memo } from 'react' import { Box, Chip, Stack, Typography } from '@mui/material'
import PropTypes from 'prop-types' import Cancel from 'iconoir-react/dist/Cancel'
import GotoIcon from 'iconoir-react/dist/Pin' import GotoIcon from 'iconoir-react/dist/Pin'
import RefreshDouble from 'iconoir-react/dist/RefreshDouble' import RefreshDouble from 'iconoir-react/dist/RefreshDouble'
import Cancel from 'iconoir-react/dist/Cancel' import PropTypes from 'prop-types'
import { Typography, Box, Stack, Chip } from '@mui/material' import { ReactElement, memo, useState } from 'react'
import { Row } from 'react-table' import { Row } from 'react-table'
import { SubmitButton } from 'client/components/FormControl'
import { Tr } from 'client/components/HOC'
import MultipleTags from 'client/components/MultipleTags'
import SplitPane from 'client/components/SplitPane'
import { ZonesTable } from 'client/components/Tables'
import ZoneTabs from 'client/components/Tabs/Zone'
import { T, Zone } from 'client/constants'
import { import {
useLazyGetZoneQuery, useLazyGetZoneQuery,
useUpdateZoneMutation, useUpdateZoneMutation,
} from 'client/features/OneApi/zone' } from 'client/features/OneApi/zone'
import { ZonesTable } from 'client/components/Tables'
import ZoneTabs from 'client/components/Tabs/Zone'
import SplitPane from 'client/components/SplitPane'
import MultipleTags from 'client/components/MultipleTags'
import { SubmitButton } from 'client/components/FormControl'
import { Tr } from 'client/components/HOC'
import { T, Zone } from 'client/constants'
/** /**
* Displays a list of Zones with a split pane between the list and selected row(s). * Displays a list of Zones with a split pane between the list and selected row(s).
@ -99,7 +99,7 @@ const InfoTabs = memo(({ zone, gotoPage, unselect }) => {
icon={<RefreshDouble />} icon={<RefreshDouble />}
tooltip={Tr(T.Refresh)} tooltip={Tr(T.Refresh)}
isSubmitting={isFetching} isSubmitting={isFetching}
onClick={() => get({ id })} onClick={() => get(id)}
/> />
{typeof gotoPage === 'function' && ( {typeof gotoPage === 'function' && (
<SubmitButton <SubmitButton