From 258d869f9b656a33a61a488066d0ce64515c5f47 Mon Sep 17 00:00:00 2001 From: Bohdan Iakymets Date: Wed, 21 Feb 2018 15:18:11 +0100 Subject: [PATCH] Fixed bug with VM detail leading after refresh Bug: If open detail of VM that is not on first page, and refresh it, it'll leads to main page. Fixes: https://github.com/oVirt/ovirt-web-ui/issues/491 --- src/components/Pages/index.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/components/Pages/index.js b/src/components/Pages/index.js index 7c0224e97..d02d7958c 100644 --- a/src/components/Pages/index.js +++ b/src/components/Pages/index.js @@ -10,12 +10,25 @@ import { selectVmDetail, selectPoolDetail, getISOStorages } from '../../actions/ import Selectors from '../../selectors' class VmDetailPage extends React.Component { + constructor (props) { + super(props) + this.requestSent = false + } + componentWillMount () { if (Selectors.isFilterChecked()) { this.props.getVms({ vmId: this.props.match.params.id }) } } + componentWillUpdate () { + const vmInStore = this.props.vms.getIn(['vms', this.props.match.params.id]) + if (!vmInStore && Selectors.isFilterChecked() && !this.requestSent) { + this.requestSent = true + this.props.getVms({ vmId: this.props.match.params.id }) + } + } + render () { let { match, vms, config } = this.props if (vms.getIn(['vms', match.params.id])) { @@ -44,11 +57,25 @@ VmDetailPage.propTypes = { } class PoolDetailPage extends React.Component { + constructor (props) { + super(props) + this.requestSent = false + } + componentWillMount () { if (Selectors.isFilterChecked()) { this.props.getPools({ poolId: this.props.match.params.id }) } } + + componentWillUpdate () { + const poolInStore = this.props.vms.getIn(['pools', this.props.match.params.id, 'vm']) + if (!poolInStore && Selectors.isFilterChecked() && !this.requestSent) { + this.requestSent = true + this.props.getPools({ poolId: this.props.match.params.id }) + } + } + render () { let { match, vms, config } = this.props if (vms.getIn(['pools', match.params.id, 'vm'])) {