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

feat(ui): Add shortcut for commenting in script editor #15313

Merged
merged 4 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## v2.0.0-alpha.19 [unreleased]

### Features
1. [15313](https://github.com/influxdata/influxdb/pull/15313): Add shortcut for toggling comments in script editor

### Bug Fixes
1. [15295](https://github.com/influxdata/influxdb/pull/15295): Ensures users are created with an active status

Expand Down
7 changes: 6 additions & 1 deletion ui/src/shared/components/FluxEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Controlled as ReactCodeMirror, IInstance} from 'react-codemirror2'
import {EditorChange, LineWidget, Position} from 'codemirror'
import {ShowHintOptions} from 'src/types/codemirror'
import 'src/external/codemirror'
import 'codemirror/addon/comment/comment'

// Components
import {ErrorHandling} from 'src/shared/decorators/errors'
Expand Down Expand Up @@ -97,7 +98,11 @@ class FluxEditor extends PureComponent<Props, State> {
theme: 'time-machine',
completeSingle: false,
gutters: ['error-gutter'],
extraKeys: {Tab: onTab},
comment: true,
extraKeys: {
Tab: onTab,
'Ctrl-/': 'toggleComment',
},
}

return (
Expand Down
1 change: 1 addition & 0 deletions ui/src/style/chronograf.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
@import 'src/pageLayout/components/RenamablePageTitle.scss';
@import 'src/timeMachine/components/SelectorList.scss';
@import 'src/timeMachine/components/Queries.scss';
@import 'src/timeMachine/components/EditorShortcutsTooltip.scss';
@import 'src/timeMachine/components/SearchBar.scss';
@import 'src/timeMachine/components/QueriesTimer.scss';
@import 'src/timeMachine/components/QueriesSwitcher.scss';
Expand Down
15 changes: 15 additions & 0 deletions ui/src/timeMachine/components/EditorShortcutsTooltip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.editor-shortcuts {
width: 250px;
}

.editor-shortcuts--body {
dt {
float: left;
padding-right: $ix-marg-a;
font-weight: 700;
color: $g18-cloud;
}
dd {
white-space: nowrap;
}
}
22 changes: 22 additions & 0 deletions ui/src/timeMachine/components/EditorShortcutsTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, {FC} from 'react'

import QuestionMarkTooltip from 'src/shared/components/question_mark_tooltip/QuestionMarkTooltip'

const EditorShortcutsTooltip: FC = () => {
return (
<QuestionMarkTooltip
testID="editor-shortcuts"
ischolten marked this conversation as resolved.
Show resolved Hide resolved
tipContent={
<div className="editor-shortcuts">
<h5>Shortcuts</h5>
<dl className="editor-shortcuts--body">
<dt>Ctl-/:</dt> <dd>Toggle comment for line or lines</dd>
<dt>Ctl-Enter:</dt> <dd>Submit Script</dd>
</dl>
</div>
}
/>
)
}

export default EditorShortcutsTooltip
6 changes: 5 additions & 1 deletion ui/src/timeMachine/components/Queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import TimeMachineQueryBuilder from 'src/timeMachine/components/QueryBuilder'
import SubmitQueryButton from 'src/timeMachine/components/SubmitQueryButton'
import RawDataToggle from 'src/timeMachine/components/RawDataToggle'
import QueryTabs from 'src/timeMachine/components/QueryTabs'
import EditorShortcutsToolTip from 'src/timeMachine/components/EditorShortcutsTooltip'
import {
ComponentSize,
FlexBox,
Expand Down Expand Up @@ -57,7 +58,7 @@ type Props = StateProps & DispatchProps

class TimeMachineQueries extends PureComponent<Props> {
public render() {
const {timeRange, isInCheckOverlay} = this.props
const {timeRange, isInCheckOverlay, activeQuery} = this.props

return (
<div className="time-machine-queries">
Expand All @@ -69,6 +70,9 @@ class TimeMachineQueries extends PureComponent<Props> {
justifyContent={JustifyContent.FlexEnd}
margin={ComponentSize.Small}
>
{activeQuery.editMode === 'advanced' && (
<EditorShortcutsToolTip />
)}
<RawDataToggle />
{!isInCheckOverlay && (
<>
Expand Down