-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed bug with VM detail leading after refresh #497
Conversation
src/actions/vm.js
Outdated
@@ -1,6 +1,7 @@ | |||
import { | |||
CHANGE_VM_ICON, | |||
CHANGE_VM_ICON_BY_ID, | |||
CHECK_VM_AVIABILITY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling?
src/components/Pages/index.js
Outdated
@@ -110,6 +110,7 @@ const VmDetailPageConnected = connect( | |||
}), | |||
(dispatch) => ({ | |||
getVms: ({ vmId }) => dispatch(selectVmDetail({ vmId })), | |||
checkVMAviability: ({ vmId }) => dispatch(checkVMAviability({ vmId })), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like this collision of names, it might be source of dummy bugs in the future or decreases readability at least.
src/actions/vm.js
Outdated
@@ -345,3 +346,12 @@ export function changeVmIconById ({ vmId, iconId }) { | |||
}, | |||
} | |||
} | |||
|
|||
export function checkVMAviability ({ vmId }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we follow the convention that only first letter in an abbreviation is capitalized? Like: checkVmAvailability
.
We already use that in e.g. VmDialog
, VmDetail
, and others. Similarly we use CHECK_VM_AVIABILITY
, not CHECK_V_M_AVIABILITY
baa4aa0
to
b24bda3
Compare
src/sagas.js
Outdated
@@ -581,6 +582,16 @@ function* fetchUSBFilter (action) { | |||
} | |||
} | |||
|
|||
function* checkVmAviability (action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this can be simplified:
yield fetchSingleVm({ payload: { vmId: action.payload.vmId } })
const vm = yield select(state => state.getIn(['vms', 'vms', action.payload.vmId])
if (!vm) {
yield put(redirectRoute({ route: '/' }))
}
It could save one request.
src/sagas.js
Outdated
@@ -581,6 +582,16 @@ function* fetchUSBFilter (action) { | |||
} | |||
} | |||
|
|||
function* checkVmAvailability (action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy from previous pull request version
Maybe this can be simplified:
yield fetchSingleVm({ payload: { vmId: action.payload.vmId } })
const vm = yield select(state => state.getIn(['vms', 'vms', action.payload.vmId])
if (!vm) {
yield put(redirectRoute({ route: '/' }))
}
It could save one request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because if we call fetchSingleVm
it update state vms
, before adding fetched VM to state, thus VmDetailPage
will update and call check again, and again, and again... Thus my version is more simplified. Otherwise it need to add more lines for take care of this recursion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So how about (pseudo-code):
const vmFromStore = yield select(state => state.getIn(['vms', 'vms', action.payload.vmId])
if (vmFromStore) {
return
}
yield fetchSingleVm({ payload: { vmId: action.payload.vmId } })
const loadedVm = yield select(state => state.getIn(['vms', 'vms', action.payload.vmId])
if (!loadedVm) {
yield put(redirectRoute({ route: '/' }))
}
I agree that originally posted version is easy to read. I find network requests expensive and requesting the same entity twice in this case not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doing the same thing, and we already check availability of VM in current vms
state, in VmDetailPage
component.
b24bda3
to
92adbca
Compare
@jniederm @mareklibra Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except that new line LGTM
src/components/PageRouter.js
Outdated
@@ -103,6 +103,7 @@ class PageRouter extends React.Component { | |||
|
|||
render () { | |||
let { route, location, history, routeReducer } = this.props | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this seems pretty unrelated.
92adbca
to
d972d0d
Compare
@jniederm Done. |
Review status: 0 of 1 files reviewed at latest revision, 7 unresolved discussions. src/components/Pages/index.js, line 22 at r4 (raw file):
This can cause firing of multiple same API requests at the app init. I would move that to Comments from Reviewable |
@mareklibra it already in |
I'm sorry, I don't understand following sentence:
In recent implementation, I can see the call within If availability of
|
Here you can see almost the same functionality https://github.com/bond95/ovirt-web-ui/blob/d972d0d2a9dfbec9909239e7cdabba678aa174ba/src/components/Pages/index.js#L13
It wouldn't, because if VM already in redux state, then it don't gonna send request again, you can see it here in if (!vmInStore && Selectors.isFilterChecked()) { |
It will. The |
d972d0d
to
f08dd8d
Compare
@mareklibra what do you think now? |
Bug: If open detail of VM that is not on first page, and refresh it, it'll leads to main page. Fixes: oVirt#491
f08dd8d
to
258d869
Compare
Bug: If open detail of VM that is not on first page, and refresh it, it'll leads to main page.
Fixes: #491
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)