Procházet zdrojové kódy

Add `Enter` support for options modals

Add `Enter` support for replica execution options and replica migration
options modals.
Sergiu Miclea před 8 roky
rodič
revize
925fbb4311

+ 10 - 1
src/components/organisms/ReplicaExecutionOptions/ReplicaExecutionOptions.jsx

@@ -19,10 +19,11 @@ import PropTypes from 'prop-types'
 import { WizardOptionsField, Button } from 'components'
 
 import LabelDictionary from '../../../utils/LabelDictionary'
+import KeyboardManager from '../../../utils/KeyboardManager'
+import { executionOptions } from '../../../config'
 
 import executionImage from './images/execution.svg'
 
-import { executionOptions } from '../../../config'
 
 const Wrapper = styled.div`
   display: flex;
@@ -71,6 +72,14 @@ class ReplicaExecutionOptions extends React.Component {
     }
   }
 
+  componentDidMount() {
+    KeyboardManager.onEnter('execution-options', () => { this.props.onExecuteClick(this.state.fields) }, 2)
+  }
+
+  componentWillUnmount() {
+    KeyboardManager.removeKeyDown('execution-options')
+  }
+
   getFieldValue(field) {
     if (!this.props.options || this.props.options[field.name] === null || this.props.options[field.name] === undefined) {
       return field.value

+ 9 - 0
src/components/organisms/ReplicaMigrationOptions/ReplicaMigrationOptions.jsx

@@ -19,6 +19,7 @@ import PropTypes from 'prop-types'
 import { Button, WizardOptionsField } from 'components'
 
 import LabelDictionary from '../../../utils/LabelDictionary'
+import KeyboardManager from '../../../utils/KeyboardManager'
 import replicaMigrationImage from './images/replica-migration.svg'
 
 const Wrapper = styled.div`
@@ -79,6 +80,14 @@ class ReplicaMigrationOptions extends React.Component {
     }
   }
 
+  componentDidMount() {
+    KeyboardManager.onEnter('migration-options', () => { this.props.onMigrateClick(this.state.fields) }, 2)
+  }
+
+  componentWillUnmount() {
+    KeyboardManager.removeKeyDown('migration-options')
+  }
+
   handleValueChange(field, value) {
     this.state.fields.find(f => f.name === field.name).value = value
     this.setState({ fields: this.state.fields })