Skip to content

Commit

Permalink
Fixed bug with VM detail leading after refresh
Browse files Browse the repository at this point in the history
Bug: If open detail of VM that is not on first page, and refresh it, it'll leads to main page.
Fixes: #491
  • Loading branch information
bond95 committed Feb 28, 2018
1 parent 2ffb1c4 commit 258d869
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/components/Pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down Expand Up @@ -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'])) {
Expand Down

0 comments on commit 258d869

Please sign in to comment.