1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

M #~: Disable dashboard animation by user settings (#2110)

applies to master & one-6.4
This commit is contained in:
Sergio Betanzos 2022-05-31 16:29:33 +02:00 committed by GitHub
parent 9eaf885758
commit c817b6fd62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,17 +49,15 @@ function SunstoneDashboard() {
const imageAccess = useMemo(() => hasAccessToResource(IMAGE), [view])
const vnetAccess = useMemo(() => hasAccessToResource(VNET), [view])
const styles = useMemo(() => {
if (stringToBoolean(DISABLE_ANIMATIONS))
return {
'& *, & *::before, & *::after': { animation: 'none !important' },
}
}, [DISABLE_ANIMATIONS])
return (
<Box
py={3}
{...(stringToBoolean(DISABLE_ANIMATIONS) && {
sx: {
'& *, & *::before, & *::after': {
animation: 'none !important',
},
},
})}
>
<Box py={3} sx={styles}>
<Grid
container
data-cy="dashboard-widget-total-sunstone-resources"
@ -98,20 +96,25 @@ function SunstoneDashboard() {
)
}
const ResourceWidget = memo(({ query, ...props }) => {
const ResourceWidget = memo((props) => {
const { settings: { DISABLE_ANIMATIONS } = {} } = useAuth()
const { query, onClick, text, bgColor, icon } = props
const { data = [], isFetching } = query()
const NumberElement = useMemo(() => {
if (stringToBoolean(DISABLE_ANIMATIONS)) return data?.length
return <NumberEasing value={data?.length} />
}, [DISABLE_ANIMATIONS, data?.length])
return (
<Grid item xs={12} sm={6} md={3}>
<WavesCard
value={
isFetching ? (
<CircularProgress size={20} />
) : (
<NumberEasing value={data?.length} />
)
}
{...props}
bgColor={bgColor}
icon={icon}
text={text}
value={isFetching ? <CircularProgress size={20} /> : NumberElement}
onClick={onClick || undefined}
/>
</Grid>
)
@ -124,6 +127,7 @@ ResourceWidget.propTypes = {
text: PropTypes.string,
bgColor: PropTypes.string,
icon: PropTypes.any,
onClick: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
}
export default SunstoneDashboard