fix: monaco polish (#17908)

* fix: monaco cleaning

* chore: tsc

Co-authored-by: drdelambre <drdelambre>
pull/17915/head
Alex Boatwright 2020-04-29 15:39:06 -07:00 committed by GitHub
commit 09f3ba5787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 30 deletions

View File

@ -61,11 +61,10 @@ export function comments(editor: EditorType) {
} }
export function submit(editor: EditorType, submitFn: () => any) { export function submit(editor: EditorType, submitFn: () => any) {
editor.onKeyUp(evt => { editor.addCommand(
const {ctrlKey, code} = evt window.monaco.KeyMod.CtrlCmd | window.monaco.KeyCode.Enter,
() => {
if (ctrlKey && code === 'Enter') {
submitFn() submitFn()
} }
}) )
} }

View File

@ -1,15 +1,21 @@
.editor-shortcuts { .editor-shortcuts {
width: 250px; width: 250px;
h5 {
margin: 8px 0 12px;
}
} }
.editor-shortcuts--body { .editor-shortcuts--body {
font-size: 14px;
line-height: 16px;
dt { dt {
float: left;
padding-right: $ix-marg-a; padding-right: $ix-marg-a;
font-weight: 700; font-weight: 700;
color: $g18-cloud; color: $g18-cloud;
margin-top: 8px;
} }
dd { dd {
white-space: nowrap; display: block
} }
} }

View File

@ -12,8 +12,10 @@ const EditorShortcutsTooltip: FC = () => {
<div className="editor-shortcuts"> <div className="editor-shortcuts">
<h5>Shortcuts</h5> <h5>Shortcuts</h5>
<dl className="editor-shortcuts--body"> <dl className="editor-shortcuts--body">
<dt>Ctl-/:</dt> <dd>Toggle comment for line or lines</dd> <dt>[Ctl or ] + /:</dt>
<dt>Ctl-Enter:</dt> <dd>Submit Script</dd> <dd>Toggle comment for line or lines</dd>
<dt>[Ctl or ] + [Enter]:</dt>
<dd>Submit Script</dd>
</dl> </dl>
</div> </div>
} }

View File

@ -31,22 +31,7 @@ interface DispatchProps {
type Props = StateProps & DispatchProps type Props = StateProps & DispatchProps
interface State { class SubmitQueryButton extends PureComponent<Props> {
didClick: boolean
}
class SubmitQueryButton extends PureComponent<Props, State> {
public state: State = {didClick: false}
public componentDidUpdate(prevProps: Props) {
if (
prevProps.queryStatus === RemoteDataState.Loading &&
this.props.queryStatus === RemoteDataState.Done
) {
this.setState({didClick: false})
}
}
public render() { public render() {
return ( return (
<Button <Button
@ -62,14 +47,12 @@ class SubmitQueryButton extends PureComponent<Props, State> {
private get buttonStatus(): ComponentStatus { private get buttonStatus(): ComponentStatus {
const {queryStatus, submitButtonDisabled} = this.props const {queryStatus, submitButtonDisabled} = this.props
const {didClick} = this.state
if (submitButtonDisabled) { if (submitButtonDisabled) {
return ComponentStatus.Disabled return ComponentStatus.Disabled
} }
if (queryStatus === RemoteDataState.Loading && didClick) { if (queryStatus === RemoteDataState.Loading) {
// Only show loading state for button if it was just clicked
return ComponentStatus.Loading return ComponentStatus.Loading
} }
@ -78,7 +61,6 @@ class SubmitQueryButton extends PureComponent<Props, State> {
private handleClick = (): void => { private handleClick = (): void => {
this.props.onSubmit() this.props.onSubmit()
this.setState({didClick: true})
} }
} }