Skip to content
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

Add feature for changing console button tooltip to "Console in use" #106

Closed
wants to merge 1 commit into from

Conversation

bond95
Copy link
Contributor

@bond95 bond95 commented Mar 17, 2017

Fixes: #66

@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

11 similar comments
@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@lago-bot
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@ovirt-infra
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@ovirt-infra
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@ovirt-infra
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

@ovirt-infra
Copy link

The commiter is not a member of organization nor whitelist. Please contact maintainer for patch verification.

src/sagas.js Outdated
@@ -138,6 +139,7 @@ function* fetchAllVms (action) {
yield put(removeMissingVms({ vmIdsToPreserve }))

yield put(updateVms({ vms: internalVms, copySubResources: true }))
yield fetchVmsSessions({ vms: internalVms })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an additional query per each VM on every refresh cycle which is too high price for too small gain I'd say.
I think we should do it a bit differently. Maybe something like this:

  • do this if "shallowFetch == false" and than showing a msg in the VM details
  • also, do this as a part of the attempt to connect to the console. So, the flow would be like this:
    • click connect to console button
    • first check the active sessions, if there is some active session, warn the user that there is an active session and ask if he wants to continue anyway
  • continue with the taking the console normally in case the user confirms

@mareklibra what you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's to costly since it's a per-VM call.

I agree with @jelkosz , let's try usability when triggered within console retrieval.

@landgraf
Copy link

ci test please

@mareklibra
Copy link
Contributor

Rebase is needed because of #109

this.setState({
openModal: true,
})
this.props.checkConsole()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to onConsoleSessionConfirmaClose()

}),
(dispatch, { vm }) => ({
checkConsole: () => dispatch(checkConsoleInUse({ vmId: vm.get('id') })),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use more self-descriptive name, instead of checkConsole use i.e. onCheckConsoleSessionInUse

onGetConsole: () => dispatch(getConsole({ vmId: vm.get('id') })),
modalClose: () => dispatch(setConsoleInUse({ vmId: vm.get('id'), consoleInUse: false })),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar: modalClose --> onConsoleSessionConfirmationClosed

}),
(dispatch, { vm }) => ({
checkConsole: () => dispatch(checkConsoleInUse({ vmId: vm.get('id') })),
onGetConsole: () => dispatch(getConsole({ vmId: vm.get('id') })),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change the overall "Get Console" flow is becoming hard to understand.
To help, please refactor throughout the application getConsole() ---> downloadConsole() and change the action type string accordingly.

sessionsInternal.find((x) => x.consoleUser) !== undefined) {
yield put(setConsoleInUse({ vmId, consoleInUse: true }))
} else {
yield put(getConsole({ vmId }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after recatoring: downloadConsole() (see different comment)

src/sagas.js Outdated
@@ -295,6 +321,12 @@ function* schedulerPerMinute (action) {
}
}

let sagasFunctions = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment describing purpose of this wrapping object.

Something like:
Saga functions to be called from subsagas .

Or better even more descriptive.

src/sagas.js Outdated
@@ -308,10 +340,12 @@ export function *rootSaga () {
takeEvery('START_VM', startVm),
takeEvery('GET_CONSOLE_VM', getConsoleVm),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor: GET_CONSOLE_VM --> DOWNLOAD_CONSOLE_VM

src/sagas.js Outdated
@@ -308,10 +340,12 @@ export function *rootSaga () {
takeEvery('START_VM', startVm),
takeEvery('GET_CONSOLE_VM', getConsoleVm),
takeEvery('SUSPEND_VM', suspendVm),
takeEvery('GET_SESSIONS_VM', getSessionsVm),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this dispatched from somewhere? Please review whole flow.

@@ -0,0 +1,5 @@
import { buildSagas as VmActionsSagas } from './components/VmActions/sagas'

export default (sagas) => [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is becoming one of the key parts of the overall architecture.
Please add comment describing it's purpose, try to be as much descriptive as possible.
Try to describe the general idea behind this composition and what is expected to be done for future additions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will help to keep it's use consistently and make it more understandable.

}

if (vm.get('sessions') &&
!(vm.get('sessions').filter(c => c.get('consoleUser')).isEmpty())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this patch, the redux store now contains two related properties:

  • consoleUser
  • consoleInUse

Both filled in within different flows but used for more or less similar use case. Can they be merged into one and related flows changed accordingly? This logical duplicity might cause difficulties for maintenance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's correct, the existence of potentially existing parallel console session is checked right before the console is downloaded (the new VmActions/sagas.js).

Just an idea:
Within this saga, the consoleUser might be set to some constant pessimistically enforcing the state the console is in use and once the fetchVmSessions() finishes, correct value is set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they can not be merged in to one, only if I add actions from reducer VmAction to vms reducer, but of whole that modularity is to make every module more independent and not to make mess in global files (like sagas.js or reducers/vms.js).
Yes, it's a good idea to add consoleInUse parameter to state


export function setVmSessions ({ vmId, sessions }) {
return {
type: 'SET_VM_SESSIONS',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use constants.js

@@ -0,0 +1,20 @@
import { SET_CONSOLE_IN_USE, CONSOLE_IN_USE } from './constants'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a single file to be used across whole application.
It will help to avoid name conflicts without explicit namespacing.
Merge conflicts are easy to resolve.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of dividing is to make every module more independent, and this action use only this module, so there can not be any conflicts.

@mareklibra
Copy link
Contributor

For user confirmation I do prefer the
https://ethaizone.github.io/Bootstrap-Confirmation/
as written in my previous comment.

Just for a reference, if modal is supposed to be used, I would follow:
http://www.patternfly.org/pattern-library/widgets/#modal

@bond95
Copy link
Contributor Author

bond95 commented Apr 19, 2017

@mareklibra change modal window to user confirmation popup, please review

Copy link
Contributor

@mareklibra mareklibra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bond95 , I pulled the pull request to try and I can still see the modal dialog, no confirmation component. Did you push proper version, please?

@@ -25,7 +25,7 @@ class DetailContainer extends Component {
render () {
const { children } = this.props
return (
<div className={'container-fluid ' + sharedStyle['move-left-detail']}>
<div className={'container-fluid ' + sharedStyle['move-left-detail'] + ' ' + sharedStyle['detail-z-index']}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be left for a follow-up, but string composition with back-ticks is better in this case

yarn.lock Outdated
@@ -46,8 +46,8 @@ ajv-keywords@^1.0.0:
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c"

ajv@^4.7.0:
version "4.11.3"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.3.tgz#ce30bdb90d1254f762c75af915fb3a63e7183d22"
version "4.11.5"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are no changes to the package.json, please remove this file from commit.

@bond95
Copy link
Contributor Author

bond95 commented Apr 20, 2017

@mareklibra fixed. I think better if popup will look something like this,
screenshot from 2017-04-20 09-41-47

yarn.lock Outdated
@@ -1,5707 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not git rm yarn.lock :-)
My previous comment was just about committing changes if the package.json is untouched.

})
onConsoleClick (e) {
this.setState({
openModal: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename to consoleConfirmationAboutToOpen

okLabel: 'Yes',
onOk: onSuspend,
})
onModalClose () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename to onConsoleConfirmationClose()

okLabel: 'Yes',
onOk: this.onConsoleDownload,
onCancel: this.onModalClose,
}))()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be the OnClickTopConfirmation() function executed directly without the wrapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried do it without wrapping and it throw error

}

componentDidUpdate (prevProps, prevState) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code can be moved to the render() method since it's called once props/state is updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it can't cause function render must be pure and can only return component, but not change other components, or added new one inside

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flow is strange, but ok, let's keep it.
Please simplify the call on line 148, I think you can call the function directly, can't you?

@bond95
Copy link
Contributor Author

bond95 commented Apr 28, 2017

@mareklibra fixed conflicts, please review

@mareklibra
Copy link
Contributor

Merge is pending due to conflicts in oVirt/ovirt-ui-components#34

@bond95
Copy link
Contributor Author

bond95 commented May 25, 2017

@mareklibra please review

@mareklibra
Copy link
Contributor

oVirt/ovirt-ui-components#34 seems to be still needed for this PR, please fix issues there. Once merged in ovirt-ui-components, we can merge here.

@bond95
Copy link
Contributor Author

bond95 commented May 25, 2017

@mareklibra I closed this oVirt/ovirt-ui-components#34 PR, because all changes was already rebased to web-ui

@mareklibra
Copy link
Contributor

Replaced by #204

@mareklibra mareklibra closed this May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants