fix(ui): expand tab key presses to 2 spaces in the Flux editor

pull/13809/head
Christopher Henn 2019-05-06 11:20:36 -07:00
parent e029a95ad3
commit afd4c6b902
3 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,7 @@
1. [13753](https://github.com/influxdata/influxdb/pull/13753): Removed hardcoded bucket for Getting Started with Flux dashboard 1. [13753](https://github.com/influxdata/influxdb/pull/13753): Removed hardcoded bucket for Getting Started with Flux dashboard
1. [13783](https://github.com/influxdata/influxdb/pull/13783): Ensure map type variables allow for selecting values 1. [13783](https://github.com/influxdata/influxdb/pull/13783): Ensure map type variables allow for selecting values
1. [13800](https://github.com/influxdata/influxdb/pull/13800): Generate more idiomatic Flux in query builder 1. [13800](https://github.com/influxdata/influxdb/pull/13800): Generate more idiomatic Flux in query builder
1. [13797](https://github.com/influxdata/influxdb/pull/13797): Expand tab key presses to 2 spaces in the Flux editor
### UI Improvements ### UI Improvements

View File

@ -13,6 +13,7 @@ import {EXCLUDED_KEYS} from 'src/shared/constants/fluxEditor'
// Utils // Utils
import {getSuggestions} from 'src/shared/utils/autoComplete' import {getSuggestions} from 'src/shared/utils/autoComplete'
import {onTab} from 'src/shared/utils/fluxEditor'
// Types // Types
import {OnChangeScript, Suggestion} from 'src/types/flux' import {OnChangeScript, Suggestion} from 'src/types/flux'
@ -96,6 +97,7 @@ class FluxEditor extends PureComponent<Props, State> {
theme: 'time-machine', theme: 'time-machine',
completeSingle: false, completeSingle: false,
gutters: ['error-gutter'], gutters: ['error-gutter'],
extraKeys: {Tab: onTab},
} }
return ( return (

View File

@ -0,0 +1,9 @@
import {Doc} from 'codemirror'
export const onTab = (cm: Doc & {indentSelection: (a: any) => any}) => {
if (cm.somethingSelected()) {
cm.indentSelection('add')
} else {
cm.replaceSelection(' ', 'end')
}
}