-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate query logs syntax errors to the console #56
Added an error listener to the lexer to ensure that all error message are handled through the same error handler and do not print out to the console resolves #56
- Loading branch information
Showing
6 changed files
with
175 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import SyntaxHighlighter from 'react-syntax-highlighter/prism'; | ||
import * as CopyToClipboard from 'react-copy-to-clipboard'; | ||
import { xonokai } from 'react-syntax-highlighter/styles/prism'; | ||
|
||
import * as React from 'react'; | ||
import { Button } from 'office-ui-fabric-react/lib/Button'; | ||
|
||
export interface CodeOutputProps { | ||
title: string | JSX.Element; | ||
lang: string; | ||
data?: string; | ||
showCopyToClipboard: boolean; | ||
copyToClipboardDisabled: boolean; | ||
showChildrenAboveClipboard?: boolean; | ||
customStyle?: any; | ||
} | ||
|
||
export default class CodeOutput extends React.Component<CodeOutputProps, any> { | ||
constructor(props: CodeOutputProps) { | ||
super(props); | ||
} | ||
|
||
public render() { | ||
return ( | ||
<div className="ms-Grid-row"> | ||
<div className="ms-Grid-col ms-sm12"> | ||
<div className="ms-font-l">{this.props.title}</div> | ||
<SyntaxHighlighter language={this.props.lang} style={xonokai} customStyle={this.props.customStyle}> | ||
{this.props.data} | ||
</SyntaxHighlighter> | ||
<div> | ||
{this.props.showChildrenAboveClipboard && this.props.children} | ||
{this.props.showCopyToClipboard && this.props.data && ( | ||
<CopyToClipboard text={this.props.data}> | ||
<Button | ||
primary={true} | ||
disabled={this.props.copyToClipboardDisabled} | ||
iconProps={{ iconName: 'copy' }} | ||
title="Copy" | ||
ariaLabel="Copy" | ||
text="Copy to Clipboard" | ||
/> | ||
</CopyToClipboard> | ||
)} | ||
{!this.props.showChildrenAboveClipboard && this.props.children} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import * as React from 'react'; | ||
import { Checkbox } from 'office-ui-fabric-react/lib/Checkbox'; | ||
import { TextField } from 'office-ui-fabric-react/lib/TextField'; | ||
import { FormatOptions } from 'soql-parser-js'; | ||
|
||
export interface ParseSoqlFormatProps { | ||
style?: any; | ||
formatOptions: FormatOptions; | ||
enabled: boolean; | ||
toggleFormat: (enabled: boolean) => void; | ||
onChange: (formatOptions: FormatOptions) => void; | ||
} | ||
|
||
export default class ParseSoqlFormat extends React.Component<ParseSoqlFormatProps, any> { | ||
public setMaxFieldLen = (ev: React.SyntheticEvent<HTMLInputElement>) => { | ||
const formatOptions = { | ||
...this.props.formatOptions, | ||
fieldMaxLineLen: Math.max(0, Number((ev.target as HTMLInputElement).value)), | ||
}; | ||
this.props.onChange(formatOptions); | ||
}; | ||
|
||
public toggleSubqueryParens = () => { | ||
const formatOptions = { | ||
...this.props.formatOptions, | ||
fieldSubqueryParensOnOwnLine: !this.props.formatOptions.fieldSubqueryParensOnOwnLine, | ||
}; | ||
this.props.onChange(formatOptions); | ||
}; | ||
|
||
public toggleWhereClauseIndent = () => { | ||
const formatOptions = { | ||
...this.props.formatOptions, | ||
whereClauseOperatorsIndented: !this.props.formatOptions.whereClauseOperatorsIndented, | ||
}; | ||
this.props.onChange(formatOptions); | ||
}; | ||
|
||
public render() { | ||
return ( | ||
<div style={this.props.style}> | ||
<Checkbox | ||
label="Format Output" | ||
checked={this.props.enabled} | ||
onChange={() => this.props.toggleFormat(!this.props.enabled)} | ||
/> | ||
<div style={{ margin: 5, paddingLeft: 10 }}> | ||
<div style={{ maxWidth: 400 }}> | ||
<TextField | ||
label={ | ||
( | ||
<span> | ||
Number of characters before fields wrap -{' '} | ||
<small> | ||
<code>fieldMaxLineLen</code> | ||
</small> | ||
</span> | ||
) as any | ||
} | ||
type="number" | ||
value={String(this.props.formatOptions.fieldMaxLineLen)} | ||
onChange={this.setMaxFieldLen} | ||
disabled={!this.props.enabled} | ||
/> | ||
</div> | ||
<div style={{ marginTop: 5 }}> | ||
<Checkbox | ||
label={ | ||
( | ||
<span> | ||
Subquery Parenthesis on own line -{' '} | ||
<small> | ||
<code>fieldSubqueryParensOnOwnLine</code> | ||
</small> | ||
</span> | ||
) as any | ||
} | ||
checked={this.props.formatOptions.fieldSubqueryParensOnOwnLine} | ||
onChange={this.toggleSubqueryParens} | ||
disabled={!this.props.enabled} | ||
/> | ||
</div> | ||
<div style={{ marginTop: 5 }}> | ||
<Checkbox | ||
label={ | ||
( | ||
<span> | ||
Indent items in WHERE clause -{' '} | ||
<small> | ||
<code>whereClauseOperatorsIndented</code> | ||
</small> | ||
</span> | ||
) as any | ||
} | ||
checked={this.props.formatOptions.whereClauseOperatorsIndented} | ||
onChange={this.toggleWhereClauseIndent} | ||
disabled={!this.props.enabled} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters